aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test/template/url_helper_test.rb
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 /actionview/test/template/url_helper_test.rb
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 'actionview/test/template/url_helper_test.rb')
-rw-r--r--actionview/test/template/url_helper_test.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/actionview/test/template/url_helper_test.rb b/actionview/test/template/url_helper_test.rb
index 027b72b354..50b7865f88 100644
--- a/actionview/test/template/url_helper_test.rb
+++ b/actionview/test/template/url_helper_test.rb
@@ -785,6 +785,13 @@ class SessionsController < ActionController::Base
@session = Session.new(params[:id])
render inline: "<%= url_for([@workshop, @session]) %>\n<%= link_to('Session', [@workshop, @session]) %>"
end
+
+ def edit
+ @workshop = Workshop.new(params[:workshop_id])
+ @session = Session.new(params[:id])
+ @url = [@workshop, @session, format: params[:format]]
+ render inline: "<%= url_for(@url) %>\n<%= link_to('Session', @url) %>"
+ end
end
class PolymorphicControllerTest < ActionController::TestCase
@@ -815,4 +822,11 @@ class PolymorphicControllerTest < ActionController::TestCase
get :show, params: { workshop_id: 1, id: 1 }
assert_equal %{/workshops/1/sessions/1\n<a href="/workshops/1/sessions/1">Session</a>}, @response.body
end
+
+ def test_existing_nested_resource_with_params
+ @controller = SessionsController.new
+
+ get :edit, params: { workshop_id: 1, id: 1, format: "json" }
+ assert_equal %{/workshops/1/sessions/1.json\n<a href="/workshops/1/sessions/1.json">Session</a>}, @response.body
+ end
end