aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/routing_test.rb
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2010-04-05 06:48:02 +0100
committerJosé Valim <jose.valim@gmail.com>2010-06-08 09:11:39 +0200
commit4740fbac85d6190cccd244f943d7a578c607b806 (patch)
tree90a540b0227c04ff25648cb8895a248dcc4e15a7 /actionpack/test/dispatch/routing_test.rb
parent67f411c57b98f926d39042ba003cefdba14be603 (diff)
downloadrails-4740fbac85d6190cccd244f943d7a578c607b806.tar.gz
rails-4740fbac85d6190cccd244f943d7a578c607b806.tar.bz2
rails-4740fbac85d6190cccd244f943d7a578c607b806.zip
Add support for actions on a new resource to the new routing DSL [#4328 state:resolved]
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.rb50
1 files changed, 48 insertions, 2 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index 82c45f3161..ecc73f1fbc 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -96,8 +96,17 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end
scope 'pt', :name_prefix => 'pt' do
- resources :projects, :path_names => { :edit => 'editar' }, :path => 'projetos'
- resource :admin, :path_names => { :new => 'novo' }, :path => 'administrador'
+ resources :projects, :path_names => { :edit => 'editar', :new => 'novo' }, :path => 'projetos' do
+ post :preview, :on => :new
+ end
+ resource :admin, :path_names => { :new => 'novo' }, :path => 'administrador' do
+ post :preview, :on => :new
+ end
+ resources :products, :path_names => { :new => 'novo' } do
+ new do
+ post :preview
+ end
+ end
end
resources :projects, :controller => :project do
@@ -146,6 +155,10 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end
resources :replies do
+ new do
+ post :preview
+ end
+
member do
put :answer, :to => :mark_as_answer
delete :answer, :to => :unmark_as_answer
@@ -234,6 +247,14 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end
match "whatever/:controller(/:action(/:id))"
+
+ resource :profile do
+ get :settings
+
+ new do
+ post :preview
+ end
+ end
end
end
@@ -1077,6 +1098,31 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end
end
+ def test_resource_new_actions
+ with_test_routes do
+ assert_equal '/replies/new/preview', preview_new_reply_path
+ assert_equal '/pt/projetos/novo/preview', preview_new_pt_project_path
+ assert_equal '/pt/administrador/novo/preview', preview_new_pt_admin_path
+ assert_equal '/pt/products/novo/preview', preview_new_pt_product_path
+ assert_equal '/profile/new/preview', preview_new_profile_path
+
+ post '/replies/new/preview'
+ assert_equal 'replies#preview', @response.body
+
+ post '/pt/projetos/novo/preview'
+ assert_equal 'projects#preview', @response.body
+
+ post '/pt/administrador/novo/preview'
+ assert_equal 'admins#preview', @response.body
+
+ post '/pt/products/novo/preview'
+ assert_equal 'products#preview', @response.body
+
+ post '/profile/new/preview'
+ assert_equal 'profiles#preview', @response.body
+ end
+ end
+
private
def with_test_routes
yield