aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test/dispatch')
-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