aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorBernerd Schaefer <bj.schaefer@gmail.com>2015-09-04 12:23:29 -0700
committerBernerd Schaefer <bj.schaefer@gmail.com>2015-09-04 13:42:32 -0700
commitee63532d40c9e06d5b38e9a2e98e00fbbe084064 (patch)
tree102ecaa1c09ef3cdc7bf7941912986160f673e94 /actionpack/test
parent451b954c2f072d08e13fc2552f3dfa35d93b0935 (diff)
downloadrails-ee63532d40c9e06d5b38e9a2e98e00fbbe084064.tar.gz
rails-ee63532d40c9e06d5b38e9a2e98e00fbbe084064.tar.bz2
rails-ee63532d40c9e06d5b38e9a2e98e00fbbe084064.zip
`url_for` does not modify polymorphic options
The `url_for` methods in `actionpack` and `actionview` now make a copy of the provided options before generating polymorphic paths or URLs. The bug in the previous behavior is most noticeable in a case like: url_options = [:new, :post, param: 'value'] if current_page?(url_options) css_class = "active" end link_to "New Post", url_options, class: css_class
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/controller/url_for_test.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/actionpack/test/controller/url_for_test.rb b/actionpack/test/controller/url_for_test.rb
index 31677f202d..78e883f134 100644
--- a/actionpack/test/controller/url_for_test.rb
+++ b/actionpack/test/controller/url_for_test.rb
@@ -451,6 +451,26 @@ module AbstractController
end
end
+ def test_url_for_with_array_is_unmodified
+ with_routing do |set|
+ set.draw do
+ namespace :admin do
+ resources :posts
+ end
+ end
+
+ kls = Class.new { include set.url_helpers }
+ kls.default_url_options[:host] = 'www.basecamphq.com'
+
+ original_components = [:new, :admin, :post, { param: 'value' }]
+ components = original_components.dup
+
+ kls.new.url_for(components)
+
+ assert_equal(original_components, components)
+ end
+ end
+
private
def extract_params(url)
url.split('?', 2).last.split('&').sort