diff options
Diffstat (limited to 'actionview')
-rw-r--r-- | actionview/CHANGELOG.md | 4 | ||||
-rw-r--r-- | actionview/lib/action_view/helpers/form_helper.rb | 2 | ||||
-rw-r--r-- | actionview/lib/action_view/helpers/url_helper.rb | 4 | ||||
-rw-r--r-- | actionview/lib/action_view/record_identifier.rb | 2 | ||||
-rw-r--r-- | actionview/lib/action_view/routing_url_for.rb | 5 | ||||
-rw-r--r-- | actionview/lib/action_view/template.rb | 2 | ||||
-rw-r--r-- | actionview/test/template/number_helper_test.rb | 1 | ||||
-rw-r--r-- | actionview/test/template/url_helper_test.rb | 20 |
8 files changed, 29 insertions, 11 deletions
diff --git a/actionview/CHANGELOG.md b/actionview/CHANGELOG.md index f97ca88b87..9ea250643a 100644 --- a/actionview/CHANGELOG.md +++ b/actionview/CHANGELOG.md @@ -1,3 +1,7 @@ +* `url_for` does not modify its arguments when generating polymorphic URLs. + + *Bernerd Schaefer* + * `number_to_currency` and `number_with_delimiter` now accept custom `delimiter_pattern` option to handle placement of delimiter, to support currency formats like INR diff --git a/actionview/lib/action_view/helpers/form_helper.rb b/actionview/lib/action_view/helpers/form_helper.rb index 3a9acafaa2..ebf5ea5b77 100644 --- a/actionview/lib/action_view/helpers/form_helper.rb +++ b/actionview/lib/action_view/helpers/form_helper.rb @@ -1880,7 +1880,7 @@ module ActionView # create: "Add %{model}" # # ==== Examples - # button("Create a post") + # button("Create post") # # => <button name='button' type='submit'>Create post</button> # # button do diff --git a/actionview/lib/action_view/helpers/url_helper.rb b/actionview/lib/action_view/helpers/url_helper.rb index 477d676e21..5684de35e8 100644 --- a/actionview/lib/action_view/helpers/url_helper.rb +++ b/actionview/lib/action_view/helpers/url_helper.rb @@ -464,11 +464,11 @@ module ActionView extras = %w{ cc bcc body subject reply_to }.map! { |item| option = html_options.delete(item).presence || next - "#{item.dasherize}=#{Rack::Utils.escape_path(option)}" + "#{item.dasherize}=#{ERB::Util.url_encode(option)}" }.compact extras = extras.empty? ? '' : '?' + extras.join('&') - encoded_email_address = Rack::Utils.escape_path(email_address) + encoded_email_address = ERB::Util.url_encode(email_address).gsub("%40", "@") html_options["href"] = "mailto:#{encoded_email_address}#{extras}" content_tag("a".freeze, name || email_address, html_options, &block) diff --git a/actionview/lib/action_view/record_identifier.rb b/actionview/lib/action_view/record_identifier.rb index 6c6e69101b..4b44eb5520 100644 --- a/actionview/lib/action_view/record_identifier.rb +++ b/actionview/lib/action_view/record_identifier.rb @@ -11,7 +11,7 @@ module ActionView # <%= post.body %> # <% end %> # - # When +post+ is a new, unsaved ActiveRecord::Base intance, the resulting HTML + # When +post+ is a new, unsaved ActiveRecord::Base instance, the resulting HTML # is: # # <div id="new_post" class="post"> diff --git a/actionview/lib/action_view/routing_url_for.rb b/actionview/lib/action_view/routing_url_for.rb index 20d6b9a64c..b4cbc80bd5 100644 --- a/actionview/lib/action_view/routing_url_for.rb +++ b/actionview/lib/action_view/routing_url_for.rb @@ -105,10 +105,11 @@ module ActionView when :back _back_url when Array + components = options.dup if _generate_paths_by_default - polymorphic_path(options, options.extract_options!) + polymorphic_path(components, components.extract_options!) else - polymorphic_url(options, options.extract_options!) + polymorphic_url(components, components.extract_options!) end else method = _generate_paths_by_default ? :path : :url diff --git a/actionview/lib/action_view/template.rb b/actionview/lib/action_view/template.rb index e232808dcb..0ed208f27e 100644 --- a/actionview/lib/action_view/template.rb +++ b/actionview/lib/action_view/template.rb @@ -141,7 +141,7 @@ module ActionView @compile_mutex = Mutex.new end - # Returns if the underlying handler supports streaming. If so, + # Returns whether the underlying handler supports streaming. If so, # a streaming buffer *may* be passed when it start rendering. def supports_streaming? handler.respond_to?(:supports_streaming?) && handler.supports_streaming? diff --git a/actionview/test/template/number_helper_test.rb b/actionview/test/template/number_helper_test.rb index 631d45586b..ace3e950b8 100644 --- a/actionview/test/template/number_helper_test.rb +++ b/actionview/test/template/number_helper_test.rb @@ -1,4 +1,3 @@ -# encoding: utf-8 require "abstract_unit" class NumberHelperTest < ActionView::TestCase diff --git a/actionview/test/template/url_helper_test.rb b/actionview/test/template/url_helper_test.rb index 2bd3098217..50b7865f88 100644 --- a/actionview/test/template/url_helper_test.rb +++ b/actionview/test/template/url_helper_test.rb @@ -501,14 +501,14 @@ class UrlHelperTest < ActiveSupport::TestCase def test_mail_to_with_special_characters assert_dom_equal( - %(<a href="mailto:%23!$%25&'*+-/=?%5E_%60%7B%7D%7C~@example.org">#!$%&'*+-/=?^_`{}|~@example.org</a>), + %{<a href="mailto:%23%21%24%25%26%27%2A%2B-%2F%3D%3F%5E_%60%7B%7D%7C%7E@example.org">#!$%&'*+-/=?^_`{}|~@example.org</a>}, mail_to("#!$%&'*+-/=?^_`{}|~@example.org") ) end def test_mail_with_options assert_dom_equal( - %{<a href="mailto:me@example.com?cc=ccaddress@example.com&bcc=bccaddress@example.com&body=This%20is%20the%20body%20of%20the%20message.&subject=This%20is%20an%20example%20email&reply-to=foo@bar.com">My email</a>}, + %{<a href="mailto:me@example.com?cc=ccaddress%40example.com&bcc=bccaddress%40example.com&body=This%20is%20the%20body%20of%20the%20message.&subject=This%20is%20an%20example%20email&reply-to=foo%40bar.com">My email</a>}, mail_to("me@example.com", "My email", cc: "ccaddress@example.com", bcc: "bccaddress@example.com", subject: "This is an example email", body: "This is the body of the message.", reply_to: "foo@bar.com") ) @@ -533,7 +533,7 @@ class UrlHelperTest < ActiveSupport::TestCase end def test_mail_to_with_block_and_options - assert_dom_equal %{<a class="special" href="mailto:me@example.com?cc=ccaddress@example.com"><span>Email me</span></a>}, + assert_dom_equal %{<a class="special" href="mailto:me@example.com?cc=ccaddress%40example.com"><span>Email me</span></a>}, mail_to('me@example.com', cc: "ccaddress@example.com", class: "special") { content_tag(:span, 'Email me') } end @@ -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 |