aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/routing_test.rb
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2010-08-24 07:27:54 +0100
committerJosé Valim <jose.valim@gmail.com>2010-08-24 10:26:25 -0300
commit2fb0cbec024c5b51451deab7e390e2d4f712cf8f (patch)
treea2b4c6a7ad31d887581b258a9dd03db7aa72fa15 /actionpack/test/dispatch/routing_test.rb
parenta0284791df3caed66e3cabb80a62680d69182ddb (diff)
downloadrails-2fb0cbec024c5b51451deab7e390e2d4f712cf8f.tar.gz
rails-2fb0cbec024c5b51451deab7e390e2d4f712cf8f.tar.bz2
rails-2fb0cbec024c5b51451deab7e390e2d4f712cf8f.zip
When custom resource actions are specified using strings add the default name and action if the string is a valid ruby method name.
[#5431 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.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index c529db4771..f4a839e097 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -212,11 +212,15 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get "overdue", :to => :overdue, :on => :collection
get "print" => "invoices#print", :as => :print, :on => :member
post "preview" => "invoices#preview", :as => :preview, :on => :new
+ get "aged/:months", :on => :collection, :action => :aged, :as => :aged
end
resources :notes, :shallow => true do
get "preview" => "notes#preview", :as => :preview, :on => :new
get "print" => "notes#print", :as => :print, :on => :member
end
+ get "inactive", :on => :collection
+ post "deactivate", :on => :member
+ get "old", :on => :collection, :as => :stale
end
namespace :api do
@@ -2034,6 +2038,24 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
verify_redirect 'http://www.example.com/countries/all/cities'
end
+ def test_custom_resource_actions_defined_using_string
+ get '/customers/inactive'
+ assert_equal 'customers#inactive', @response.body
+ assert_equal '/customers/inactive', inactive_customers_path
+
+ post '/customers/1/deactivate'
+ assert_equal 'customers#deactivate', @response.body
+ assert_equal '/customers/1/deactivate', deactivate_customer_path(:id => '1')
+
+ get '/customers/old'
+ assert_equal 'customers#old', @response.body
+ assert_equal '/customers/old', stale_customers_path
+
+ get '/customers/1/invoices/aged/3'
+ assert_equal 'invoices#aged', @response.body
+ assert_equal '/customers/1/invoices/aged/3', aged_customer_invoices_path(:customer_id => '1', :months => '3')
+ end
+
private
def with_test_routes
yield