diff options
author | José Valim <jose.valim@gmail.com> | 2010-09-05 15:59:25 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-09-05 15:59:35 +0200 |
commit | 8a3461b8c1cb6371c809618420de9e69a71d183f (patch) | |
tree | 8497bf27d75cb866c459cb58f8e68a008d759fec /actionpack | |
parent | 9757bfff9b7fff21697228dd0920d8ea93fae969 (diff) | |
download | rails-8a3461b8c1cb6371c809618420de9e69a71d183f.tar.gz rails-8a3461b8c1cb6371c809618420de9e69a71d183f.tar.bz2 rails-8a3461b8c1cb6371c809618420de9e69a71d183f.zip |
Remove a few tests from old router that do not make sense with the new one.
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 24 | ||||
-rw-r--r-- | actionpack/test/controller/resources_test.rb | 54 | ||||
-rw-r--r-- | actionpack/test/controller/routing_test.rb | 16 |
3 files changed, 6 insertions, 88 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index fdcfe26781..8a161b0837 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -620,18 +620,9 @@ module ActionDispatch end def actions - only, except = @options.values_at(:only, :except) - if only == :all || except == :none - only = nil - except = [] - elsif only == :none || except == :all - only = [] - except = nil - end - - if only + if only = @options[:only] Array(only).map(&:to_sym) - elsif except + elsif except = @options[:except] default_actions - Array(except).map(&:to_sym) else default_actions @@ -783,7 +774,7 @@ module ActionDispatch end resource_scope(Resource.new(resources.pop, options)) do - instance_eval(&block) if block_given? + yield if block_given? collection_scope do get :index if parent_resource.actions.include?(:index) @@ -907,15 +898,6 @@ module ActionDispatch return self end - via = Array.wrap(options[:via]).map(&:to_sym) - if via.include?(:head) - raise ArgumentError, "HTTP method HEAD is invalid in route conditions. Rails processes HEAD requests the same as GETs, returning just the response headers" - end - - unless (invalid = via - HTTP_METHODS).empty? - raise ArgumentError, "Invalid HTTP method (#{invalid.join(', ')}) specified in :via" - end - on = options.delete(:on) if VALID_ON_OPTIONS.include?(on) args.push(options) diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb index 70d2ecdc3f..b59fd65a3e 100644 --- a/actionpack/test/controller/resources_test.rb +++ b/actionpack/test/controller/resources_test.rb @@ -301,28 +301,6 @@ class ResourcesTest < ActionController::TestCase end end - # def test_member_when_changed_default_restful_actions_and_path_names_not_specified - # default_path_names = ActionController::Base.resources_path_names - # ActionController::Base.resources_path_names = {:new => 'nuevo', :edit => 'editar'} - # - # with_restful_routing :messages do - # new_options = { :action => 'new', :controller => 'messages' } - # new_path = "/messages/nuevo" - # edit_options = { :action => 'edit', :id => '1', :controller => 'messages' } - # edit_path = "/messages/1/editar" - # - # assert_restful_routes_for :messages do |options| - # assert_recognizes(options.merge(new_options), :path => new_path, :method => :get) - # end - # - # assert_restful_routes_for :messages do |options| - # assert_recognizes(options.merge(edit_options), :path => edit_path, :method => :get) - # end - # end - # ensure - # ActionController::Base.resources_path_names = default_path_names - # end - def test_with_two_member_actions_with_same_method [:put, :post].each do |method| with_routing do |set| @@ -680,32 +658,6 @@ class ResourcesTest < ActionController::TestCase end end - def test_should_not_allow_invalid_head_method_for_member_routes - with_routing do |set| - assert_raise(ArgumentError) do - set.draw do - resources :messages do - match :something, :on => :member, :via => :head - end - end - end - end - end - - def test_should_not_allow_invalid_http_methods_for_member_routes - with_routing do |set| - assert_raise(ArgumentError) do - set.draw do - resources :messages do - member do - match :something, :via => [:invalid, :get] - end - end - end - end - end - end - def test_resource_action_separator with_routing do |set| set.draw do @@ -1009,7 +961,7 @@ class ResourcesTest < ActionController::TestCase def test_resource_has_only_collection_action with_routing do |set| set.draw do - resources :products, :except => :all do + resources :products, :only => [] do get :sale, :on => :collection end end @@ -1025,7 +977,7 @@ class ResourcesTest < ActionController::TestCase def test_resource_has_only_member_action with_routing do |set| set.draw do - resources :products, :except => :all do + resources :products, :only => [] do get :preview, :on => :member end end @@ -1041,7 +993,7 @@ class ResourcesTest < ActionController::TestCase def test_singleton_resource_has_only_member_action with_routing do |set| set.draw do - resource :account, :except => :all do + resource :account, :only => [] do member do get :signup end diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index 141feae87b..bb990586f7 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -862,14 +862,6 @@ class RouteSetTest < ActiveSupport::TestCase end end - def test_route_constraints_with_invalid_http_method_is_invalid - assert_raise ArgumentError do - set.draw do - match 'valid/route' => 'pages#show', :via => :invalid - end - end - end - def test_route_constraints_with_options_method_condition_is_valid assert_nothing_raised do set.draw do @@ -878,14 +870,6 @@ class RouteSetTest < ActiveSupport::TestCase end end - def test_route_constraints_with_head_method_condition_is_invalid - assert_raise ArgumentError do - set.draw do - match 'valid/route' => 'pages#show', :via => :head - end - end - end - def test_recognize_with_encoded_id_and_regex set.draw do match 'page/:id' => 'pages#show', :id => /[a-zA-Z0-9\+]+/ |