diff options
Diffstat (limited to 'actionview')
-rw-r--r-- | actionview/lib/action_view/digestor.rb | 4 | ||||
-rw-r--r-- | actionview/lib/action_view/helpers/form_options_helper.rb | 6 | ||||
-rw-r--r-- | actionview/lib/action_view/helpers/tag_helper.rb | 13 | ||||
-rw-r--r-- | actionview/lib/action_view/helpers/url_helper.rb | 2 | ||||
-rw-r--r-- | actionview/lib/action_view/layouts.rb | 5 | ||||
-rw-r--r-- | actionview/test/activerecord/controller_runtime_test.rb | 2 | ||||
-rw-r--r-- | actionview/test/template/url_helper_test.rb | 6 |
7 files changed, 26 insertions, 12 deletions
diff --git a/actionview/lib/action_view/digestor.rb b/actionview/lib/action_view/digestor.rb index f3c29d663c..cadef22022 100644 --- a/actionview/lib/action_view/digestor.rb +++ b/actionview/lib/action_view/digestor.rb @@ -12,7 +12,6 @@ module ActionView # * <tt>name</tt> - Template name # * <tt>finder</tt> - An instance of <tt>ActionView::LookupContext</tt> # * <tt>dependencies</tt> - An array of dependent views - # * <tt>partial</tt> - Specifies whether the template is a partial def digest(name:, finder:, dependencies: []) dependencies ||= [] cache_key = [ name, finder.rendered_format, dependencies ].flatten.compact.join('.') @@ -42,8 +41,7 @@ module ActionView options = {} options[:formats] = [finder.rendered_format] if finder.rendered_format - if finder.disable_cache { finder.exists?(logical_name, [], partial, [], options) } - template = finder.disable_cache { finder.find(logical_name, [], partial, [], options) } + if template = finder.disable_cache { finder.find_all(logical_name, [], partial, [], options).first } finder.rendered_format ||= template.formats.first if node = seen[template.identifier] # handle cycles in the tree diff --git a/actionview/lib/action_view/helpers/form_options_helper.rb b/actionview/lib/action_view/helpers/form_options_helper.rb index 06b696f281..0cd3207b12 100644 --- a/actionview/lib/action_view/helpers/form_options_helper.rb +++ b/actionview/lib/action_view/helpers/form_options_helper.rb @@ -651,12 +651,12 @@ module ActionView # The HTML specification says when nothing is select on a collection of radio buttons # web browsers do not send any value to server. # Unfortunately this introduces a gotcha: - # if a +User+ model has a +category_id+ field, and in the form none category is selected no +category_id+ parameter is sent. So, - # any strong parameters idiom like + # if a +User+ model has a +category_id+ field and in the form no category is selected, no +category_id+ parameter is sent. So, + # any strong parameters idiom like: # # params.require(:user).permit(...) # - # will raise an error since no +{user: ...}+ will be present. + # will raise an error since no <tt>{user: ...}</tt> will be present. # # To prevent this the helper generates an auxiliary hidden field before # every collection of radio buttons. The hidden field has the same name as collection radio button and blank value. diff --git a/actionview/lib/action_view/helpers/tag_helper.rb b/actionview/lib/action_view/helpers/tag_helper.rb index 0633cfc2b4..4ba37fd5e5 100644 --- a/actionview/lib/action_view/helpers/tag_helper.rb +++ b/actionview/lib/action_view/helpers/tag_helper.rb @@ -115,6 +115,7 @@ module ActionView # Returns an HTML tag. # # === Building HTML tags + # # Builds HTML5 compliant tags with a tag proxy. Every tag can be built with: # # tag.<tag name>(optional content, options) @@ -122,6 +123,7 @@ module ActionView # where tag name can be e.g. br, div, section, article, or any tag really. # # ==== Passing content + # # Tags can pass content to embed within it: # # tag.h1 'All titles fit to print' # => <h1>All titles fit to print</h1> @@ -136,6 +138,7 @@ module ActionView # # => <p>The next great American novel starts here.</p> # # ==== Options + # # Any passed options become attributes on the generated tag. # # tag.section class: %w( kitties puppies ) @@ -177,7 +180,7 @@ module ActionView # # => <img src="open & shut.png"> # # The tag builder respects - # [HTML5 void elements](https://www.w3.org/TR/html5/syntax.html#void-elements) + # {HTML5 void elements}[https://www.w3.org/TR/html5/syntax.html#void-elements] # if no content is passed, and omits closing tags for those elements. # # # A standard element: @@ -187,18 +190,19 @@ module ActionView # tag.br # => <br> # # === Legacy syntax + # # The following format is for legacy syntax support. It will be deprecated in future versions of Rails. # - # tag(tag_name, options) + # tag(name, options = nil, open = false, escape = true) # - # === Building HTML tags - # Returns an empty HTML tag of type +name+ which by default is XHTML + # It returns an empty HTML tag of type +name+ which by default is XHTML # compliant. Set +open+ to true to create an open tag compatible # with HTML 4.0 and below. Add HTML attributes by passing an attributes # hash to +options+. Set +escape+ to false to disable attribute value # escaping. # # ==== Options + # # You can use symbols or strings for the attribute names. # # Use +true+ with boolean attributes that can render with no value, like @@ -208,6 +212,7 @@ module ActionView # pointing to a hash of sub-attributes. # # ==== Examples + # # tag("br") # # => <br /> # diff --git a/actionview/lib/action_view/helpers/url_helper.rb b/actionview/lib/action_view/helpers/url_helper.rb index 11c7daf4da..fb6426b997 100644 --- a/actionview/lib/action_view/helpers/url_helper.rb +++ b/actionview/lib/action_view/helpers/url_helper.rb @@ -548,6 +548,8 @@ module ActionView request_uri = url_string.index("?") ? request.fullpath : request.path request_uri = URI.parser.unescape(request_uri).force_encoding(Encoding::BINARY) + url_string.chomp!("/") if url_string.start_with?("/") && url_string != "/" + if url_string =~ /^\w+:\/\// url_string == "#{request.protocol}#{request.host_with_port}#{request_uri}" else diff --git a/actionview/lib/action_view/layouts.rb b/actionview/lib/action_view/layouts.rb index a74a5e05f3..8db1674187 100644 --- a/actionview/lib/action_view/layouts.rb +++ b/actionview/lib/action_view/layouts.rb @@ -248,11 +248,14 @@ module ActionView # # If the specified layout is a: # String:: the String is the template name - # Symbol:: call the method specified by the symbol, which will return the template name + # Symbol:: call the method specified by the symbol + # Proc:: call the passed Proc # false:: There is no layout # true:: raise an ArgumentError # nil:: Force default layout behavior with inheritance # + # Return value of Proc & Symbol arguments should be String, false, true or nil + # with the same meaning as described above. # ==== Parameters # * <tt>layout</tt> - The layout to use. # diff --git a/actionview/test/activerecord/controller_runtime_test.rb b/actionview/test/activerecord/controller_runtime_test.rb index af91348d76..a61181df88 100644 --- a/actionview/test/activerecord/controller_runtime_test.rb +++ b/actionview/test/activerecord/controller_runtime_test.rb @@ -38,8 +38,8 @@ class ControllerRuntimeLogSubscriberTest < ActionController::TestCase tests LogSubscriberController def setup - super @old_logger = ActionController::Base.logger + super ActionController::LogSubscriber.attach_to :action_controller end diff --git a/actionview/test/template/url_helper_test.rb b/actionview/test/template/url_helper_test.rb index ab56d80de3..6060ea2f1e 100644 --- a/actionview/test/template/url_helper_test.rb +++ b/actionview/test/template/url_helper_test.rb @@ -503,6 +503,12 @@ class UrlHelperTest < ActiveSupport::TestCase assert current_page?(controller: 'foo', action: 'category', category: 'administraĆ§Ć£o', callback_url: 'http://example.com/foo') end + def test_current_page_with_trailing_slash + @request = request_for_url("/posts") + + assert current_page?("/posts/") + end + def test_link_unless_current @request = request_for_url("/") |