diff options
author | José Valim <jose.valim@gmail.com> | 2010-01-14 01:31:17 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-01-14 01:31:17 +0100 |
commit | 35933822dec7be3f895c7a3f1440d72c982aebdd (patch) | |
tree | df9417f88ac481120bc049790185840f15fa4e42 /actionpack/test/dispatch | |
parent | 2835ec6134b1e5b706824b568dfaba24672b7409 (diff) | |
download | rails-35933822dec7be3f895c7a3f1440d72c982aebdd.tar.gz rails-35933822dec7be3f895c7a3f1440d72c982aebdd.tar.bz2 rails-35933822dec7be3f895c7a3f1440d72c982aebdd.zip |
Ensure optional path scopes are properly handled.
Diffstat (limited to 'actionpack/test/dispatch')
-rw-r--r-- | actionpack/test/dispatch/routing_test.rb | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index 6a25deb40c..984cbffd9f 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -129,6 +129,16 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest resources :rooms end + scope '(:locale)', :locale => /en|pl/ do + resources :descriptions + end + + namespace :admin do + scope '(/:locale)', :locale => /en|pl/ do + resources :descriptions + end + end + match '/info' => 'projects#info', :as => 'info' root :to => 'projects#index' @@ -594,6 +604,48 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest self.host = previous_host end + def test_optional_scoped_path + with_test_routes do + assert_equal '/en/descriptions', descriptions_path("en") + assert_equal '/descriptions', descriptions_path(nil) + assert_equal '/en/descriptions/1', description_path("en", 1) + assert_equal '/descriptions/1', description_path(nil, 1) + + get '/en/descriptions' + assert_equal 'descriptions#index', @response.body + + get '/descriptions' + assert_equal 'descriptions#index', @response.body + + get '/en/descriptions/1' + assert_equal 'descriptions#show', @response.body + + get '/descriptions/1' + assert_equal 'descriptions#show', @response.body + end + end + + def test_nested_optional_scoped_path + with_test_routes do + assert_equal '/admin/en/descriptions', admin_descriptions_path("en") + assert_equal '/admin/descriptions', admin_descriptions_path(nil) + assert_equal '/admin/en/descriptions/1', admin_description_path("en", 1) + assert_equal '/admin/descriptions/1', admin_description_path(nil, 1) + + get '/admin/en/descriptions' + assert_equal 'admin/descriptions#index', @response.body + + get '/admin/descriptions' + assert_equal 'admin/descriptions#index', @response.body + + get '/admin/en/descriptions/1' + assert_equal 'admin/descriptions#show', @response.body + + get '/admin/descriptions/1' + assert_equal 'admin/descriptions#show', @response.body + end + end + private def with_test_routes real_routes, temp_routes = ActionController::Routing::Routes, Routes |