aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/routing_test.rb
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2010-06-08 18:00:43 +0100
committerJosé Valim <jose.valim@gmail.com>2010-06-08 19:33:27 +0200
commita7edddf605d2ffbb6669365dcd23d6e4c6c2cf84 (patch)
treef6312ad53906fb488dd52e0ab61d8eadae1b2710 /actionpack/test/dispatch/routing_test.rb
parent47bf19c8485ecead7280019c4815a2ed4f2161d5 (diff)
downloadrails-a7edddf605d2ffbb6669365dcd23d6e4c6c2cf84.tar.gz
rails-a7edddf605d2ffbb6669365dcd23d6e4c6c2cf84.tar.bz2
rails-a7edddf605d2ffbb6669365dcd23d6e4c6c2cf84.zip
Fix resources ignoring scope options
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack/test/dispatch/routing_test.rb')
-rw-r--r--actionpack/test/dispatch/routing_test.rb34
1 files changed, 30 insertions, 4 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index ecc73f1fbc..a294535e88 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -229,10 +229,13 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
root :to => 'projects#index'
end
- resources :products, :constraints => { :id => /\d{4}/ } do
- root :to => "products#root"
- get :favorite, :on => :collection
- resources :images
+ scope :only => [:index, :show] do
+ resources :products, :constraints => { :id => /\d{4}/ } do
+ root :to => "products#root"
+ get :favorite, :on => :collection
+ resources :images
+ end
+ resource :account
end
resource :dashboard, :constraints => { :ip => /192\.168\.1\.\d{1,3}/ }
@@ -1123,6 +1126,29 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end
end
+ def test_resource_merges_options_from_scope
+ with_test_routes do
+ assert_raise(NameError) { new_account_path }
+
+ get '/account/new'
+ assert_equal 404, status
+ end
+ end
+
+ def test_resources_merges_options_from_scope
+ with_test_routes do
+ assert_raise(NoMethodError) { edit_product_path('1') }
+
+ get '/products/1/edit'
+ assert_equal 404, status
+
+ assert_raise(NoMethodError) { edit_product_image_path('1', '2') }
+
+ post '/products/1/images/2/edit'
+ assert_equal 404, status
+ end
+ end
+
private
def with_test_routes
yield