Permalink
Browse files

Fix bug when url_for changes controller.

  • Loading branch information...
nbeloglazov authored and carlosantoniodasilva committed Apr 26, 2012
1 parent 88a296d commit 09c4dfa06bcf049ada7b127f70d3c5eb5e9cd91d
Showing with 11 additions and 2 deletions.
  1. +2 −2 actionpack/lib/action_dispatch/routing/route_set.rb
  2. +9 −0 actionpack/test/dispatch/routing_test.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
@@ -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' }

0 comments on commit 09c4dfa

Please sign in to comment.