diff options
Diffstat (limited to 'actionpack/test/dispatch')
-rw-r--r-- | actionpack/test/dispatch/routing_test.rb | 83 |
1 files changed, 81 insertions, 2 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index 1bfc92aa3d..d56612d6ec 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -298,8 +298,8 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest resource :dashboard, :constraints => { :ip => /192\.168\.1\.\d{1,3}/ } + resource :token, :module => :api scope :module => :api do - resource :token resources :errors, :shallow => true do resources :notices end @@ -349,6 +349,22 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest match ":controller(/:action(/:id))" end + scope :only => :index do + resources :clubs do + resources :players, :only => [:show] + resource :chairman, :only => [:show] + end + end + + scope :except => [:new, :create, :edit, :update] do + resources :sectors do + resources :companies, :except => :destroy do + resources :divisions, :only => :index + end + resource :leader, :except => :destroy + end + end + match '/:locale/*file.:format', :to => 'files#show', :file => /path\/to\/existing\/file/ end end @@ -1254,7 +1270,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest assert_equal 'pass', @response.headers['X-Cascade'] get '/products/0001/images' assert_equal 'images#index', @response.body - get '/products/0001/images/1' + get '/products/0001/images/0001' assert_equal 'images#show', @response.body get '/dashboard', {}, {'REMOTE_ADDR' => '10.0.0.100'} @@ -1640,6 +1656,69 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest assert_equal 'Not Found', @response.body assert_raises(ActionController::RoutingError){ movie_trailer_path(:movie_id => '00001') } end + + def test_only_option_should_be_overwritten + get '/clubs' + assert_equal 'clubs#index', @response.body + assert_equal '/clubs', clubs_path + + get '/clubs/1' + assert_equal 'Not Found', @response.body + assert_raise(NameError) { club_path(:id => '1') } + + get '/clubs/1/players' + assert_equal 'Not Found', @response.body + assert_raise(NameError) { club_players_path(:club_id => '1') } + + get '/clubs/1/players/2' + assert_equal 'players#show', @response.body + assert_equal '/clubs/1/players/2', club_player_path(:club_id => '1', :id => '2') + + get '/clubs/1/chairman/new' + assert_equal 'Not Found', @response.body + assert_raise(NameError) { new_club_chairman_path(:club_id => '1') } + + get '/clubs/1/chairman' + assert_equal 'chairmen#show', @response.body + assert_equal '/clubs/1/chairman', club_chairman_path(:club_id => '1') + end + + def test_except_option_should_be_overwritten + get '/sectors' + assert_equal 'sectors#index', @response.body + assert_equal '/sectors', sectors_path + + get '/sectors/new' + assert_equal 'Not Found', @response.body + assert_raise(NameError) { new_sector_path } + + delete '/sectors/1' + assert_equal 'sectors#destroy', @response.body + + get '/sectors/1/companies/new' + assert_equal 'companies#new', @response.body + assert_equal '/sectors/1/companies/new', new_sector_company_path + + delete '/sectors/1/companies/1' + assert_equal 'Not Found', @response.body + + get '/sectors/1/leader/new' + assert_equal 'leaders#new', @response.body + assert_equal '/sectors/1/leader/new', new_sector_leader_path + + delete '/sectors/1/leader' + assert_equal 'Not Found', @response.body + end + + def test_only_option_should_overwrite_except_option + get '/sectors/1/companies/2/divisions' + assert_equal 'divisions#index', @response.body + assert_equal '/sectors/1/companies/2/divisions', sector_company_divisions_path + + get '/sectors/1/companies/2/divisions/3' + assert_equal 'Not Found', @response.body + assert_raise(NameError) { sector_company_division_path(:sector_id => '1', :company_id => '2', :id => '3') } + end end private |