aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPawel Pierzchala <pawel.pierzchala@llp.pl>2011-09-21 18:12:55 +0200
committerPawel Pierzchala <pawel.pierzchala@llp.pl>2011-09-22 09:57:00 +0200
commit019eea4a388442a004287ad2e73772f3fefc7028 (patch)
tree1f6f20b6d495ed9280c603009547010f66b047ea
parent2bf33bd4bcd488a35e641b32dd667f3092ea9197 (diff)
downloadrails-019eea4a388442a004287ad2e73772f3fefc7028.tar.gz
rails-019eea4a388442a004287ad2e73772f3fefc7028.tar.bz2
rails-019eea4a388442a004287ad2e73772f3fefc7028.zip
Fix named routes modifying arguments
-rw-r--r--actionpack/lib/action_dispatch/routing/route_set.rb7
-rw-r--r--actionpack/test/dispatch/routing_test.rb11
2 files changed, 15 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb
index 46a68a32ae..e921269331 100644
--- a/actionpack/lib/action_dispatch/routing/route_set.rb
+++ b/actionpack/lib/action_dispatch/routing/route_set.rb
@@ -165,13 +165,14 @@ module ActionDispatch
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
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index 9685b24c1c..c0b74bc9f9 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -863,6 +863,17 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
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)