few adjustments in routing
Oleg
committed May 12, 2011
commit ec477f40a9386ead94143e1f703336f17793c566
Showing 6
changed files with
27 additions
and 7 deletions
config/initializers/comfortable_mexican_sofa.rb
+1
-2
| @@ | @@ -17,8 +17,7 @@ ComfortableMexicanSofa.configure do |config| |
| # config.content_route_prefix = '' | |
| # Path: /cms-admin redirects to /cms-admin/pages but you can change it | |
| - | # You don't need to change it when changing admin_route_prefix |
| - | # config.admin_route_redirect = '/cms-admin/pages' |
| + | # config.admin_route_redirect = 'pages' |
| # If you enable this setting you'll be able to serve completely different set | |
| # of sites with their own layouts and pages. | |
config/routes.rb
+4
-2
| @@ | @@ -1,7 +1,9 @@ |
| Rails.application.routes.draw do | |
| namespace :cms_admin, :path => ComfortableMexicanSofa.config.admin_route_prefix, :except => :show do | |
| - | get '/' => redirect(ComfortableMexicanSofa.config.admin_route_redirect) |
| + | get '/' => redirect( |
| + | "/#{ComfortableMexicanSofa.config.admin_route_prefix}/#{ComfortableMexicanSofa.config.admin_route_redirect}" |
| + | ) |
| resources :pages do | |
| member do | |
| match :form_blocks | |
| @@ | @@ -26,7 +28,7 @@ Rails.application.routes.draw do |
| put :revert, :on => :member | |
| end | |
| end | |
| - | end unless ComfortableMexicanSofa.config.admin_route_prefix.nil? |
| + | end unless ComfortableMexicanSofa.config.admin_route_prefix.blank? |
| scope :controller => :cms_content do | |
| prefix = ComfortableMexicanSofa.config.content_route_prefix | |
comfortable_mexican_sofa/configuration.rb b/lib/comfortable_mexican_sofa/configuration.rb
+1
-1
| @@ | @@ -46,8 +46,8 @@ class ComfortableMexicanSofa::Configuration |
| @authentication = 'ComfortableMexicanSofa::HttpAuth' | |
| @seed_data_path = nil | |
| @admin_route_prefix = 'cms-admin' | |
| + | @admin_route_redirect = 'pages' |
| @content_route_prefix = '' | |
| - | @admin_route_redirect = "/#{@admin_route_prefix}/pages" |
| @enable_multiple_sites = false | |
| @allow_irb = false | |
| @enable_caching = true | |
test/integration/routing_extensions_test.rb
+19
-0
| @@ | @@ -31,4 +31,23 @@ class RoutingExtensionsTest < ActionDispatch::IntegrationTest |
| 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 | |
| \ No newline at end of file | |
test/test_helper.rb
+1
-1
| @@ | @@ -18,7 +18,7 @@ class ActiveSupport::TestCase |
| config.authentication = 'ComfortableMexicanSofa::HttpAuth' | |
| config.admin_route_prefix = 'cms-admin' | |
| config.content_route_prefix = '' | |
| - | config.admin_route_redirect = "/cms-admin/pages" |
| + | config.admin_route_redirect = 'pages' |
| config.enable_multiple_sites = false | |
| config.allow_irb = false | |
| config.enable_caching = true | |
test/unit/configuration_test.rb
+1
-1
| @@ | @@ -8,7 +8,7 @@ class ConfigurationTest < ActiveSupport::TestCase |
| assert_equal 'ComfortableMexicanSofa::HttpAuth', config.authentication | |
| assert_equal 'cms-admin', config.admin_route_prefix | |
| assert_equal '', config.content_route_prefix | |
| - | assert_equal '/cms-admin/pages', config.admin_route_redirect |
| + | assert_equal 'pages', config.admin_route_redirect |
| assert_equal false, config.enable_multiple_sites | |
| assert_equal false, config.allow_irb | |
| assert_equal true, config.enable_caching | |