Permalink
Browse files

Don't ignore nil positional arguments for url helpers - fixes #6196.

  • Loading branch information...
1 parent 7336b33 commit e98893b189ee075475139cf4574f7fcc9f30608a @pixeltrix pixeltrix committed May 10, 2012
Showing with 34 additions and 1 deletion.
  1. +1 −1 actionpack/lib/action_dispatch/routing/route_set.rb
  2. +33 −0 actionpack/test/dispatch/routing_test.rb
@@ -172,7 +172,7 @@ def #{selector}(*args)
options = args.extract_options!
result = #{options.inspect}
- if args.any?
+ if args.size > 0
result[:_positional_args] = args
result[:_positional_keys] = #{route.segment_keys.inspect}
end
@@ -2571,3 +2571,36 @@ def app; Routes end
assert_equal "bar", @request.params[:bar]
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" do
+ get "/categories/1"
+ assert_response :success
+ assert_raises(ActionController::RoutingError) { product_path(nil) }
+ end
+end

0 comments on commit e98893b

Please sign in to comment.