aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/routing_test.rb
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2010-09-18 17:49:46 +0100
committerAndrew White <andyw@pixeltrix.co.uk>2010-09-18 17:49:46 +0100
commit0bffd7d933a46df958c3e6bae1d9871aca515a12 (patch)
tree9d82a3b2e71a8275db33ace3585455a9f531362d /actionpack/test/dispatch/routing_test.rb
parent013ed1c0503e59dc8f1cfff1bd00d0e579c604a1 (diff)
downloadrails-0bffd7d933a46df958c3e6bae1d9871aca515a12.tar.gz
rails-0bffd7d933a46df958c3e6bae1d9871aca515a12.tar.bz2
rails-0bffd7d933a46df958c3e6bae1d9871aca515a12.zip
Raise ArgumentError instead of normalizing controller name when there is a leading slash [#5651 state:resolved]
Diffstat (limited to 'actionpack/test/dispatch/routing_test.rb')
-rw-r--r--actionpack/test/dispatch/routing_test.rb36
1 files changed, 30 insertions, 6 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index b5a4674a16..3daabf7a64 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -457,8 +457,6 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
match '/cities', :to => 'countries#cities'
end
- match '/feeds/:service', :to => '/api/feeds#show', :as => :feed
-
match '/countries/:country/(*other)', :to => redirect{ |params, req| params[:other] ? "/countries/all/#{params[:other]}" : '/countries/all' }
match '/:locale/*file.:format', :to => 'files#show', :file => /path\/to\/existing\/file/
@@ -2130,10 +2128,36 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
assert_raises(ActionController::RoutingError){ list_todo_path(:list_id => '2', :id => '1') }
end
- def test_controller_has_leading_slash_removed
- get '/feeds/twitter.xml'
- assert_equal 'api/feeds#show', @response.body
- assert_equal '/feeds/twitter.xml', feed_path(:service => 'twitter', :format => 'xml')
+ def test_controller_name_with_leading_slash_raise_error
+ assert_raise(ArgumentError) do
+ self.class.stub_controllers do |routes|
+ routes.draw { get '/feeds/:service', :to => '/feeds#show' }
+ end
+ end
+
+ assert_raise(ArgumentError) do
+ self.class.stub_controllers do |routes|
+ routes.draw { get '/feeds/:service', :controller => '/feeds', :action => 'show' }
+ end
+ end
+
+ assert_raise(ArgumentError) do
+ self.class.stub_controllers do |routes|
+ routes.draw { get '/api/feeds/:service', :to => '/api/feeds#show' }
+ end
+ end
+
+ assert_raise(ArgumentError) do
+ self.class.stub_controllers do |routes|
+ routes.draw { controller("/feeds") { get '/feeds/:service', :to => :show } }
+ end
+ end
+
+ assert_raise(ArgumentError) do
+ self.class.stub_controllers do |routes|
+ routes.draw { resources :feeds, :controller => '/feeds' }
+ end
+ end
end
private