aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/routing_test.rb
diff options
context:
space:
mode:
authorJavier Martín <elretirao@elretirao.net>2010-08-18 13:35:05 +0100
committerSantiago Pastorino <santiago@wyeworks.com>2010-08-18 13:56:46 -0300
commit3e871eee8048c0e11e270ae4fbcbe40226148c33 (patch)
tree4dc514a0312ba1a454c162543c989216bfa83b58 /actionpack/test/dispatch/routing_test.rb
parentcad8bef5ea064f30fae70a37e58dd87a07f4946d (diff)
downloadrails-3e871eee8048c0e11e270ae4fbcbe40226148c33.tar.gz
rails-3e871eee8048c0e11e270ae4fbcbe40226148c33.tar.bz2
rails-3e871eee8048c0e11e270ae4fbcbe40226148c33.zip
Don't pluralize resource methods [#4704 state:resolved]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
Diffstat (limited to 'actionpack/test/dispatch/routing_test.rb')
-rw-r--r--actionpack/test/dispatch/routing_test.rb62
1 files changed, 62 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index 4dabe1531c..31702cfd33 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -337,6 +337,14 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
resources :content
+ namespace :transport do
+ resources :taxis
+ end
+
+ namespace :medical do
+ resource :taxis
+ end
+
scope :constraints => { :id => /\d+/ } do
get '/tickets', :to => 'tickets#index', :as => :tickets
end
@@ -1884,6 +1892,60 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end
end
+ def test_resources_are_not_pluralized
+ with_test_routes do
+ get '/transport/taxis'
+ assert_equal 'transport/taxis#index', @response.body
+ assert_equal '/transport/taxis', transport_taxis_path
+
+ get '/transport/taxis/new'
+ assert_equal 'transport/taxis#new', @response.body
+ assert_equal '/transport/taxis/new', new_transport_taxi_path
+
+ post '/transport/taxis'
+ assert_equal 'transport/taxis#create', @response.body
+
+ get '/transport/taxis/1'
+ assert_equal 'transport/taxis#show', @response.body
+ assert_equal '/transport/taxis/1', transport_taxi_path(:id => '1')
+
+ get '/transport/taxis/1/edit'
+ assert_equal 'transport/taxis#edit', @response.body
+ assert_equal '/transport/taxis/1/edit', edit_transport_taxi_path(:id => '1')
+
+ put '/transport/taxis/1'
+ assert_equal 'transport/taxis#update', @response.body
+
+ delete '/transport/taxis/1'
+ assert_equal 'transport/taxis#destroy', @response.body
+ end
+ end
+
+ def test_singleton_resources_are_not_singularized
+ with_test_routes do
+ get '/medical/taxis/new'
+ assert_equal 'medical/taxes#new', @response.body
+ assert_equal '/medical/taxis/new', new_medical_taxis_path
+
+ post '/medical/taxis'
+ assert_equal 'medical/taxes#create', @response.body
+
+ get '/medical/taxis'
+ assert_equal 'medical/taxes#show', @response.body
+ assert_equal '/medical/taxis', medical_taxis_path
+
+ get '/medical/taxis/edit'
+ assert_equal 'medical/taxes#edit', @response.body
+ assert_equal '/medical/taxis/edit', edit_medical_taxis_path
+
+ put '/medical/taxis'
+ assert_equal 'medical/taxes#update', @response.body
+
+ delete '/medical/taxis'
+ assert_equal 'medical/taxes#destroy', @response.body
+ end
+ end
+
private
def with_test_routes
yield