Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix bug when url_for changes controller.

  • Loading branch information...
commit 09c4dfa06bcf049ada7b127f70d3c5eb5e9cd91d 1 parent 88a296d
@nbeloglazov nbeloglazov authored carlosantoniodasilva committed
View
4 actionpack/lib/action_dispatch/routing/route_set.rb
@@ -476,11 +476,11 @@ def normalize_options!
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
View
9 actionpack/test/dispatch/routing_test.rb
@@ -887,6 +887,15 @@ def test_url_for_with_no_side_effects
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' }
Please sign in to comment.
Something went wrong with that request. Please try again.