aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/routing_test.rb
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2012-05-10 22:52:00 +0100
committerAndrew White <andyw@pixeltrix.co.uk>2012-05-10 22:52:00 +0100
commit09a48b2324207ccbf6f421e5e7caf7655f1e905a (patch)
tree44b3894414cb0bfc1ee33bf7e31e69bad8c63f91 /actionpack/test/dispatch/routing_test.rb
parente306ca3627965bf038d6b39a9480ae57bff9c18e (diff)
downloadrails-09a48b2324207ccbf6f421e5e7caf7655f1e905a.tar.gz
rails-09a48b2324207ccbf6f421e5e7caf7655f1e905a.tar.bz2
rails-09a48b2324207ccbf6f421e5e7caf7655f1e905a.zip
Don't ignore nil positional arguments for url helpers - fixes #6196.
Diffstat (limited to 'actionpack/test/dispatch/routing_test.rb')
-rw-r--r--actionpack/test/dispatch/routing_test.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index d356187ca8..6f22cb3ea8 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -2571,3 +2571,38 @@ class TestOptimizedNamedRoutes < ActionDispatch::IntegrationTest
assert_equal '/foo', foo_path
end
end
+
+class TestNamedRouteUrlHelpers < ActionDispatch::IntegrationTest
+ class CategoriesController < ActionController::Base
+ def show
+ render :text => "categories#show"
+ end
+ end
+
+ class ProductsController < ActionController::Base
+ def show
+ render :text => "products#show"
+ end
+ end
+
+ Routes = ActionDispatch::Routing::RouteSet.new.tap do |app|
+ app.draw do
+ scope :module => "test_named_route_url_helpers" do
+ get "/categories/:id" => 'categories#show', :as => :category
+ get "/products/:id" => 'products#show', :as => :product
+ end
+ end
+ end
+
+ def app; Routes end
+
+ include Routes.url_helpers
+
+ test "url helpers do not ignore nil parameters when using non-optimized routes" do
+ Routes.stubs(:optimize_routes_generation?).returns(false)
+
+ get "/categories/1"
+ assert_response :success
+ assert_raises(ActionController::RoutingError) { product_path(nil) }
+ end
+end