From 9651ca751c71cb132c47a32291b9647365b617f5 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Tue, 22 Jun 2010 19:29:07 -0300 Subject: Add the :path option to match routes when given as symbols. This is specially useful in http helpers for generating routes in scenarios like: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit resources :users, :path => 'usuarios' do get :search, :on => :collection, :path => 'pesquisar' end Signed-off-by: José Valim --- actionpack/test/dispatch/routing_test.rb | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'actionpack/test/dispatch/routing_test.rb') diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index 4277321707..58a1fa0518 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -74,9 +74,12 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest scope 'pt', :as => 'pt' do resources :projects, :path_names => { :edit => 'editar', :new => 'novo' }, :path => 'projetos' do post :preview, :on => :new + put :close, :on => :member, :path => 'fechar' + get :open, :on => :new, :path => 'abrir' end - resource :admin, :path_names => { :new => 'novo' }, :path => 'administrador' do + resource :admin, :path_names => { :new => 'novo', :activate => 'ativar' }, :path => 'administrador' do post :preview, :on => :new + put :activate, :on => :member end resources :products, :path_names => { :new => 'novo' } do new do @@ -854,6 +857,22 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest get '/pt/administrador/novo' assert_equal 'admins#new', @response.body assert_equal '/pt/administrador/novo', new_pt_admin_path + + put '/pt/administrador/ativar' + assert_equal 'admins#activate', @response.body + assert_equal '/pt/administrador/ativar', activate_pt_admin_path + end + end + + def test_path_option_override + with_test_routes do + get '/pt/projetos/novo/abrir' + assert_equal 'projects#open', @response.body + assert_equal '/pt/projetos/novo/abrir', open_new_pt_project_path + + put '/pt/projetos/1/fechar' + assert_equal 'projects#close', @response.body + assert_equal '/pt/projetos/1/fechar', close_pt_project_path(1) end end -- cgit v1.2.3