aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/lib/action_dispatch/routing/route_set.rb4
-rw-r--r--actionpack/test/dispatch/routing_test.rb9
2 files changed, 11 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb
index 8fc0f283fc..a2044cc33b 100644
--- a/actionpack/lib/action_dispatch/routing/route_set.rb
+++ b/actionpack/lib/action_dispatch/routing/route_set.rb
@@ -494,11 +494,11 @@ module ActionDispatch
if options[:controller]
options[:action] ||= 'index'
- options[:controller] = options[:controller].to_s
+ options[:controller] = options[:controller].to_s.dup
end
if options[:action]
- options[:action] = options[:action].to_s
+ options[:action] = options[:action].to_s.dup
end
end
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index e5345754cd..6d0cfe9b8a 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -829,6 +829,15 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
assert_equal original_options, options
end
+ # checks that url_for doesn't change controller and action
+ def test_url_for_with_no_side_effects_on_strings
+ # freeze controller and action to be sure they are not changed
+ # we'll get RuntimeError if somebody tries to modify them
+ options = {:controller => '/projects'.freeze, :action => 'status'.freeze}
+
+ url_for 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' }