Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix named routes modifying arguments

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
commit d87921318cefc323732b5813f7255d7d660c7a5c 1 parent 49584b2
Pawel Pierzchala authored josevalim committed
View
7 actionpack/lib/action_dispatch/routing/route_set.rb
@@ -164,13 +164,14 @@ def define_hash_access(route, name, kind, options)
remove_possible_method :#{selector}
def #{selector}(*args)
options = args.extract_options!
+ result = #{options.inspect}
if args.any?
- options[:_positional_args] = args
- options[:_positional_keys] = #{route.segment_keys.inspect}
+ result[:_positional_args] = args
+ result[:_positional_keys] = #{route.segment_keys.inspect}
end
- options ? #{options.inspect}.merge(options) : #{options.inspect}
+ result.merge(options)
end
protected :#{selector}
END_EVAL
View
11 actionpack/test/dispatch/routing_test.rb
@@ -863,6 +863,17 @@ def test_url_for_with_no_side_effects
assert_equal original_options, options
end
+ # tests the arguments modification free version of define_hash_access
+ def test_named_route_with_no_side_effects
+ original_options = { :host => 'test.host' }
+ options = original_options.dup
+
+ profile_customer_url("customer_model", options)
+
+ # verify that the options passed in have not changed from the original ones
+ assert_equal original_options, options
+ end
+
def test_projects_status
with_test_routes do
assert_equal '/projects/status', url_for(:controller => 'projects', :action => 'status', :only_path => true)
Please sign in to comment.
Something went wrong with that request. Please try again.