Sha256: cc1a809ff6df99621cbf81b65ed527707c1fa1497f68c76d53f684727a3bc0d7

Contents?: true

Size: 1.57 KB

Versions: 4

Compression:

Stored size: 1.57 KB

Contents

require File.expand_path('../test_helper', File.dirname(__FILE__))

class RoutingExtensionsTest < ActionDispatch::IntegrationTest
  
  def teardown
    reset_config
    load(File.expand_path('config/routes.rb', Rails.root))
  end
  
  def test_get_public_with_content_route_prefix
    ComfortableMexicanSofa.config.content_route_prefix = 'custom'
    load(File.expand_path('config/routes.rb', Rails.root))
    
    get '/custom'
    assert_response :success
    assert assigns(:cms_page)
    assert_equal '/', assigns(:cms_page).full_path
    
    get '/custom/child-page'
    assert_response :success
    assert assigns(:cms_page)
    assert_equal '/child-page', assigns(:cms_page).full_path
  end
  
  def test_get_admin_with_admin_route_prefix
    ComfortableMexicanSofa.config.admin_route_prefix = 'custom-admin'
    load(File.expand_path('config/routes.rb', Rails.root))
    
    assert_equal '/custom-admin/pages', cms_admin_pages_path
    http_auth :get, cms_admin_pages_path
    assert_response :success
  end
  
  def test_get_admin_with_admin_route_redirect
    ComfortableMexicanSofa.config.admin_route_redirect = 'snippets'
    load(File.expand_path('config/routes.rb', Rails.root))
    
    http_auth :get, '/cms-admin'
    assert_response :redirect
    assert_redirected_to cms_admin_snippets_path
  end
  
  def test_get_admin_with_admin_route_prefix_disabled
    ComfortableMexicanSofa.config.admin_route_prefix = ''
    load(File.expand_path('config/routes.rb', Rails.root))
    
    assert !respond_to?(:cms_admin_path)
    
    http_auth :get, '/cms-admin'
    assert_response 404
  end
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-1.2.5 test/integration/routing_extensions_test.rb
comfortable_mexican_sofa-1.2.4 test/integration/routing_extensions_test.rb
comfortable_mexican_sofa-1.2.3 test/integration/routing_extensions_test.rb
comfortable_mexican_sofa-1.2.2 test/integration/routing_extensions_test.rb