From 6e1a536ad46fcd26f90ce2c0c47c66df45e67012 Mon Sep 17 00:00:00 2001 From: emaxi Date: Sat, 11 Nov 2017 22:47:34 -0300 Subject: Add missing documentation options to number_to_currency [ci skip] --- actionview/lib/action_view/helpers/number_helper.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'actionview') diff --git a/actionview/lib/action_view/helpers/number_helper.rb b/actionview/lib/action_view/helpers/number_helper.rb index 4b53b8fe6e..35206b7e48 100644 --- a/actionview/lib/action_view/helpers/number_helper.rb +++ b/actionview/lib/action_view/helpers/number_helper.rb @@ -100,6 +100,9 @@ module ActionView # absolute value of the number. # * :raise - If true, raises +InvalidNumberError+ when # the argument is invalid. + # * :strip_insignificant_zeros - If +true+ removes + # insignificant zeros after the decimal separator (defaults to + # +false+). # # ==== Examples # @@ -117,6 +120,8 @@ module ActionView # # => R$1234567890,50 # number_to_currency(1234567890.50, unit: "R$", separator: ",", delimiter: "", format: "%n %u") # # => 1234567890,50 R$ + # number_to_currency(1234567890.50, strip_insignificant_zeros: true) + # # => "$1,234,567,890.5" def number_to_currency(number, options = {}) delegate_number_helper_method(:number_to_currency, number, options) end -- cgit v1.2.3 From 87b6e6aa4328f16edd68978079f473169cceecbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ana=20Mar=C3=ADa=20Mart=C3=ADnez=20G=C3=B3mez?= Date: Tue, 7 Aug 2018 17:23:57 +0200 Subject: Use public_send in value_for_collection Avoid exposing private methods in view's helpers. Fixes https://github.com/rails/rails/issues/33546 --- actionview/CHANGELOG.md | 10 ++++++++++ actionview/lib/action_view/helpers/form_options_helper.rb | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'actionview') diff --git a/actionview/CHANGELOG.md b/actionview/CHANGELOG.md index 6d45cc1d8a..8597fea48d 100644 --- a/actionview/CHANGELOG.md +++ b/actionview/CHANGELOG.md @@ -1,3 +1,13 @@ +* Stop exposing public methods in view's helpers. + + For example, in methods like `options_from_collection_for_select`, + it was possible to call private methods from the objects used. + + See [#33546](https://github.com/rails/rails/issues/33546) for details. + + *[Ana María Martínez Gómez](https://github.com/Ana06)* + + * Fix issue with `button_to`'s `to_form_params` `button_to` was throwing exception when invoked with `params` hash that diff --git a/actionview/lib/action_view/helpers/form_options_helper.rb b/actionview/lib/action_view/helpers/form_options_helper.rb index 7884a8d997..9c0238a01a 100644 --- a/actionview/lib/action_view/helpers/form_options_helper.rb +++ b/actionview/lib/action_view/helpers/form_options_helper.rb @@ -802,7 +802,7 @@ module ActionView end def value_for_collection(item, value) - value.respond_to?(:call) ? value.call(item) : item.send(value) + value.respond_to?(:call) ? value.call(item) : item.public_send(value) end def prompt_text(prompt) -- cgit v1.2.3 From a9764dcc07cf9d6280b313da734d98e096b7d122 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ana=20Mar=C3=ADa=20Mart=C3=ADnez=20G=C3=B3mez?= Date: Wed, 8 Aug 2018 10:08:43 +0200 Subject: Use public_send in extract_values_from_collection Avoid exposing private methods in view's helpers. However, as `extract_values_from_collection` is only called from `options_from_collection_for_select` where `value_for_collection` is previously called, this case was already covered. The change makes anyway sense for consistency and in case the code changes in the future. --- actionview/lib/action_view/helpers/form_options_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionview') diff --git a/actionview/lib/action_view/helpers/form_options_helper.rb b/actionview/lib/action_view/helpers/form_options_helper.rb index 9c0238a01a..0fd68b66d4 100644 --- a/actionview/lib/action_view/helpers/form_options_helper.rb +++ b/actionview/lib/action_view/helpers/form_options_helper.rb @@ -794,7 +794,7 @@ module ActionView def extract_values_from_collection(collection, value_method, selected) if selected.is_a?(Proc) collection.map do |element| - element.send(value_method) if selected.call(element) + element.public_send(value_method) if selected.call(element) end.compact else selected -- cgit v1.2.3 From 0c62e141a3fc9b2d00935bb99d2d5f465e1a4fb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ana=20Mar=C3=ADa=20Mart=C3=ADnez=20G=C3=B3mez?= Date: Wed, 8 Aug 2018 10:20:46 +0200 Subject: Add one more method affected in CHANGELOG --- actionview/CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'actionview') diff --git a/actionview/CHANGELOG.md b/actionview/CHANGELOG.md index 8597fea48d..9fc120acbc 100644 --- a/actionview/CHANGELOG.md +++ b/actionview/CHANGELOG.md @@ -1,7 +1,8 @@ * Stop exposing public methods in view's helpers. - For example, in methods like `options_from_collection_for_select`, - it was possible to call private methods from the objects used. + For example, in methods like `options_from_collection_for_select` + and `collection_select` it was possible to call private methods from + the objects used. See [#33546](https://github.com/rails/rails/issues/33546) for details. -- cgit v1.2.3 From 4ca9fa11f9a9b5604371f260515c28a0f29cd921 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ana=20Mar=C3=ADa=20Mart=C3=ADnez=20G=C3=B3mez?= Date: Wed, 8 Aug 2018 10:35:03 +0200 Subject: Deprecate use of private methods in view's helpers Instead of dropping it completely in case someone is relying (probably inadvertenly) on it. --- actionview/CHANGELOG.md | 4 ++-- actionview/lib/action_view/helpers/form_options_helper.rb | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'actionview') diff --git a/actionview/CHANGELOG.md b/actionview/CHANGELOG.md index 9fc120acbc..4c552c635a 100644 --- a/actionview/CHANGELOG.md +++ b/actionview/CHANGELOG.md @@ -1,7 +1,7 @@ -* Stop exposing public methods in view's helpers. +* Deprecate exposing public methods in view's helpers. For example, in methods like `options_from_collection_for_select` - and `collection_select` it was possible to call private methods from + and `collection_select` it is possible to call private methods from the objects used. See [#33546](https://github.com/rails/rails/issues/33546) for details. diff --git a/actionview/lib/action_view/helpers/form_options_helper.rb b/actionview/lib/action_view/helpers/form_options_helper.rb index 0fd68b66d4..2ecba2e337 100644 --- a/actionview/lib/action_view/helpers/form_options_helper.rb +++ b/actionview/lib/action_view/helpers/form_options_helper.rb @@ -794,7 +794,7 @@ module ActionView def extract_values_from_collection(collection, value_method, selected) if selected.is_a?(Proc) collection.map do |element| - element.public_send(value_method) if selected.call(element) + public_or_deprecated_send(element, value_method) if selected.call(element) end.compact else selected @@ -802,7 +802,17 @@ module ActionView end def value_for_collection(item, value) - value.respond_to?(:call) ? value.call(item) : item.public_send(value) + value.respond_to?(:call) ? value.call(item) : public_or_deprecated_send(item, value) + end + + def public_or_deprecated_send(item, value) + begin + item.public_send(value) + rescue NoMethodError + raise unless item.respond_to?(value, true) && !item.respond_to?(value) + ActiveSupport::Deprecation.warn "Using private methods in view's helpers is deprecated" + item.send(value) + end end def prompt_text(prompt) -- cgit v1.2.3 From 0853cdffa2f09f02e854baed35c3323b6b35006f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ana=20Mar=C3=ADa=20Mart=C3=ADnez=20G=C3=B3mez?= Date: Wed, 8 Aug 2018 17:46:53 +0200 Subject: Add tests for privates methods in view's helpers Test that using private methods in `options_from_collection_for_select` is deprecated. Make the unused `secret` paramether in the `Post` Struct private to use it in the test. --- actionview/test/template/form_options_helper_test.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'actionview') diff --git a/actionview/test/template/form_options_helper_test.rb b/actionview/test/template/form_options_helper_test.rb index 8f796bdb83..7bce946d3b 100644 --- a/actionview/test/template/form_options_helper_test.rb +++ b/actionview/test/template/form_options_helper_test.rb @@ -21,7 +21,12 @@ class FormOptionsHelperTest < ActionView::TestCase tests ActionView::Helpers::FormOptionsHelper silence_warnings do - Post = Struct.new("Post", :title, :author_name, :body, :secret, :written_on, :category, :origin, :allow_comments) + Post = Struct.new("Post", :title, :author_name, :body, :written_on, :category, :origin, :allow_comments) do + private + def secret + "This is super secret: #{author_name} is not the real author of #{title}" + end + end Continent = Struct.new("Continent", :continent_name, :countries) Country = Struct.new("Country", :country_id, :country_name) Firm = Struct.new("Firm", :time_zone) @@ -68,6 +73,14 @@ class FormOptionsHelperTest < ActionView::TestCase ) end + def test_collection_options_with_private_value_method + assert_deprecated(/Using private methods in view's helpers is deprecated/) { options_from_collection_for_select(dummy_posts, "secret", "title") } + end + + def test_collection_options_with_private_text_method + assert_deprecated(/Using private methods in view's helpers is deprecated/) { options_from_collection_for_select(dummy_posts, "author_name", "secret") } + end + def test_collection_options_with_preselected_value assert_dom_equal( "\n\n", -- cgit v1.2.3 From 88c4ea1d2d8267d3a6d0bfbbde1bafef79ddc298 Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Mon, 13 Aug 2018 10:22:25 +0900 Subject: Update coffeelint to 2.1.0 There was a warning when running `npm install` in Action View: coffee-script@1.11.1: CoffeeScript on NPM has moved to "coffeescript" (no hyphen) We are not requiring `coffee-script` explicitly, but `coffeelint` does. The latest version, 2.1.0, already fix the dependency package name, so we should upgrade to it to suppress the warning. --- actionview/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionview') diff --git a/actionview/package.json b/actionview/package.json index 624eb5de93..1f74df79d3 100644 --- a/actionview/package.json +++ b/actionview/package.json @@ -30,7 +30,7 @@ }, "homepage": "http://rubyonrails.org/", "devDependencies": { - "coffeelint": "^1.15.7", + "coffeelint": "^2.1.0", "eslint": "^2.13.1" } } -- cgit v1.2.3 From 87d5415f0aa3e6f9f74f645a47370dd854375a1a Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Sat, 18 Aug 2018 16:23:20 +0900 Subject: Fix unclosed tags [ci skip] --- actionview/lib/action_view/helpers/asset_tag_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionview') diff --git a/actionview/lib/action_view/helpers/asset_tag_helper.rb b/actionview/lib/action_view/helpers/asset_tag_helper.rb index 14bd8ffa84..cbcce4a4dc 100644 --- a/actionview/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionview/lib/action_view/helpers/asset_tag_helper.rb @@ -55,7 +55,7 @@ module ActionView # that path. # * :skip_pipeline - This option is used to bypass the asset pipeline # when it is set to true. - # * :nonce - When set to true, adds an automatic nonce value if + # * :nonce - When set to true, adds an automatic nonce value if # you have Content Security Policy enabled. # # ==== Examples -- cgit v1.2.3 From b2c1e29c14b91b290b30c928c63253d1555e0fd9 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Sun, 19 Aug 2018 08:12:05 +0900 Subject: Enable Style/ParenthesesAroundCondition cop To prevent style check in review like https://github.com/rails/rails/pull/33608#discussion_r211087605. --- actionview/lib/action_view/helpers/text_helper.rb | 2 +- actionview/test/template/text_helper_test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'actionview') diff --git a/actionview/lib/action_view/helpers/text_helper.rb b/actionview/lib/action_view/helpers/text_helper.rb index 77a1c1fed9..a338d076e4 100644 --- a/actionview/lib/action_view/helpers/text_helper.rb +++ b/actionview/lib/action_view/helpers/text_helper.rb @@ -228,7 +228,7 @@ module ActionView # pluralize(2, 'Person', locale: :de) # # => 2 Personen def pluralize(count, singular, plural_arg = nil, plural: plural_arg, locale: I18n.locale) - word = if (count == 1 || count =~ /^1(\.0+)?$/) + word = if count == 1 || count =~ /^1(\.0+)?$/ singular else plural || singular.pluralize(locale) diff --git a/actionview/test/template/text_helper_test.rb b/actionview/test/template/text_helper_test.rb index 45edfe18be..4d47706bda 100644 --- a/actionview/test/template/text_helper_test.rb +++ b/actionview/test/template/text_helper_test.rb @@ -9,7 +9,7 @@ class TextHelperTest < ActionView::TestCase super # This simulates the fact that instance variables are reset every time # a view is rendered. The cycle helper depends on this behavior. - @_cycles = nil if (defined? @_cycles) + @_cycles = nil if defined?(@_cycles) end def test_concat -- cgit v1.2.3 From c14859513a648270705b61210dc3ab2fe5d04004 Mon Sep 17 00:00:00 2001 From: Kevin Deisz Date: Fri, 24 Aug 2018 16:10:17 -0400 Subject: Convert over the rest of the whitelist references --- actionview/lib/action_view/helpers/sanitize_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actionview') diff --git a/actionview/lib/action_view/helpers/sanitize_helper.rb b/actionview/lib/action_view/helpers/sanitize_helper.rb index cb0c99c4cf..d27d5d7e12 100644 --- a/actionview/lib/action_view/helpers/sanitize_helper.rb +++ b/actionview/lib/action_view/helpers/sanitize_helper.rb @@ -10,7 +10,7 @@ module ActionView # These helper methods extend Action View making them callable within your template files. module SanitizeHelper extend ActiveSupport::Concern - # Sanitizes HTML input, stripping all tags and attributes that aren't whitelisted. + # Sanitizes HTML input, stripping all tags and attributes that aren't permitted. # # It also strips href/src attributes with unsafe protocols like # javascript:, while also protecting against attempts to use Unicode, @@ -40,7 +40,7 @@ module ActionView # # <%= sanitize @comment.body %> # - # Providing custom whitelisted tags and attributes: + # Providing custom lists of permitted tags and attributes: # # <%= sanitize @comment.body, tags: %w(strong em a), attributes: %w(href) %> # -- cgit v1.2.3 From cac2bb7f44a6b8e240034d1de89a41fe0dd9f0ec Mon Sep 17 00:00:00 2001 From: Kevin Deisz Date: Fri, 24 Aug 2018 16:13:57 -0400 Subject: Deprecate usage of ActionView::Template::Handlers::ERB::escape_whitelist --- actionview/lib/action_view/template/handlers/erb.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'actionview') diff --git a/actionview/lib/action_view/template/handlers/erb.rb b/actionview/lib/action_view/template/handlers/erb.rb index b7b749f9da..93edef9c26 100644 --- a/actionview/lib/action_view/template/handlers/erb.rb +++ b/actionview/lib/action_view/template/handlers/erb.rb @@ -14,7 +14,17 @@ module ActionView class_attribute :erb_implementation, default: Erubi # Do not escape templates of these mime types. - class_attribute :escape_whitelist, default: ["text/plain"] + class_attribute :escape_permit_list, default: ["text/plain"] + + [self, singleton_class].each do |base| + base.alias_method :escape_whitelist, :escape_permit_list + base.alias_method :escape_whitelist=, :escape_permit_list= + + base.deprecate( + escape_whitelist: 'use #escape_permit_list instead', + :escape_whitelist= => 'use #escape_permit_list= instead' + ) + end ENCODING_TAG = Regexp.new("\\A(<%#{ENCODING_FLAG}-?%>)[ \\t]*") @@ -47,7 +57,7 @@ module ActionView self.class.erb_implementation.new( erb, - escape: (self.class.escape_whitelist.include? template.type), + escape: (self.class.escape_permit_list.include? template.type), trim: (self.class.erb_trim_mode == "-") ).src end -- cgit v1.2.3 From 3a598ae6d12ea626d8452f948d7c5998312ee300 Mon Sep 17 00:00:00 2001 From: bogdanvlviv Date: Mon, 27 Aug 2018 14:03:51 +0300 Subject: Add `:namespace` option to the api docs of `form_with` [ci skip] --- actionview/lib/action_view/helpers/form_helper.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'actionview') diff --git a/actionview/lib/action_view/helpers/form_helper.rb b/actionview/lib/action_view/helpers/form_helper.rb index 07f3d98322..6e769aa560 100644 --- a/actionview/lib/action_view/helpers/form_helper.rb +++ b/actionview/lib/action_view/helpers/form_helper.rb @@ -590,6 +590,9 @@ module ActionView # Skipped if a :url is passed. # * :scope - The scope to prefix input field names with and # thereby how the submitted parameters are grouped in controllers. + # * :namespace - A namespace for your form to ensure uniqueness of + # id attributes on form elements. The namespace attribute will be prefixed + # with underscore on the generated HTML id. # * :model - A model object to infer the :url and # :scope by, plus fill out input field values. # So if a +title+ attribute is set to "Ahoy!" then a +title+ input -- cgit v1.2.3 From 7c9751d7fe3aec1e67004d1bb5e4a1702fcacafb Mon Sep 17 00:00:00 2001 From: Kevin Deisz Date: Mon, 27 Aug 2018 09:30:05 -0400 Subject: Permit list usage cleanup and clearer documentation --- actionview/lib/action_view/helpers/sanitize_helper.rb | 2 +- actionview/lib/action_view/template/handlers/erb.rb | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'actionview') diff --git a/actionview/lib/action_view/helpers/sanitize_helper.rb b/actionview/lib/action_view/helpers/sanitize_helper.rb index d27d5d7e12..f4fa133f55 100644 --- a/actionview/lib/action_view/helpers/sanitize_helper.rb +++ b/actionview/lib/action_view/helpers/sanitize_helper.rb @@ -10,7 +10,7 @@ module ActionView # These helper methods extend Action View making them callable within your template files. module SanitizeHelper extend ActiveSupport::Concern - # Sanitizes HTML input, stripping all tags and attributes that aren't permitted. + # Sanitizes HTML input, stripping all but known-safe tags and attributes. # # It also strips href/src attributes with unsafe protocols like # javascript:, while also protecting against attempts to use Unicode, diff --git a/actionview/lib/action_view/template/handlers/erb.rb b/actionview/lib/action_view/template/handlers/erb.rb index 93edef9c26..270be0a380 100644 --- a/actionview/lib/action_view/template/handlers/erb.rb +++ b/actionview/lib/action_view/template/handlers/erb.rb @@ -14,15 +14,15 @@ module ActionView class_attribute :erb_implementation, default: Erubi # Do not escape templates of these mime types. - class_attribute :escape_permit_list, default: ["text/plain"] + class_attribute :escape_ignore_list, default: ["text/plain"] [self, singleton_class].each do |base| - base.alias_method :escape_whitelist, :escape_permit_list - base.alias_method :escape_whitelist=, :escape_permit_list= + base.send(:alias_method, :escape_whitelist, :escape_ignore_list) + base.send(:alias_method, :escape_whitelist=, :escape_ignore_list=) base.deprecate( - escape_whitelist: 'use #escape_permit_list instead', - :escape_whitelist= => 'use #escape_permit_list= instead' + escape_whitelist: "use #escape_ignore_list instead", + :escape_whitelist= => "use #escape_ignore_list= instead" ) end @@ -57,7 +57,7 @@ module ActionView self.class.erb_implementation.new( erb, - escape: (self.class.escape_permit_list.include? template.type), + escape: (self.class.escape_ignore_list.include? template.type), trim: (self.class.erb_trim_mode == "-") ).src end -- cgit v1.2.3 From a01f4d53b35cc7c2bda045a5a782fffa22390e07 Mon Sep 17 00:00:00 2001 From: schneems Date: Thu, 6 Sep 2018 11:12:55 -0500 Subject: [ci skip] Clarify CaptureHelper#capture function --- actionview/lib/action_view/helpers/capture_helper.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'actionview') diff --git a/actionview/lib/action_view/helpers/capture_helper.rb b/actionview/lib/action_view/helpers/capture_helper.rb index 92f7ddb70d..63707280a3 100644 --- a/actionview/lib/action_view/helpers/capture_helper.rb +++ b/actionview/lib/action_view/helpers/capture_helper.rb @@ -36,6 +36,11 @@ module ActionView # # # + # The output of `capture` is the rendered string. For Example: + # + # puts @greeting + # # => "Welcome to my shiny new web page! The date and time is 2018-09-06 11:09:16 -0500" + # def capture(*args) value = nil buffer = with_output_buffer { value = yield(*args) } -- cgit v1.2.3 From 31cfd5e4fdd0017f101af8f2f3d6b52b6ea68c08 Mon Sep 17 00:00:00 2001 From: schneems Date: Thu, 6 Sep 2018 12:00:20 -0500 Subject: [ci skip] Doc ActionView::OutputBuffer --- actionview/lib/action_view/buffers.rb | 15 +++++++++++++++ actionview/lib/action_view/helpers/capture_helper.rb | 5 ++--- 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'actionview') diff --git a/actionview/lib/action_view/buffers.rb b/actionview/lib/action_view/buffers.rb index 2a378fdc3c..18eaee5d79 100644 --- a/actionview/lib/action_view/buffers.rb +++ b/actionview/lib/action_view/buffers.rb @@ -3,6 +3,21 @@ require "active_support/core_ext/string/output_safety" module ActionView + # Used as a buffer for views + # + # The main difference between this and ActiveSupport::SafeBuffer + # is for the methods `<<` and `safe_expr_append=` the inputs are + # checked for nil before they are assigned and `to_s` is called on + # the input. For example: + # + # obuf = ActionView::OutputBuffer.new "hello" + # obuf << 5 + # puts obuf # => "hello5" + # + # sbuf = ActiveSupport::SafeBuffer.new "hello" + # sbuf << 5 + # puts sbuf # => "hello\u0005" + # class OutputBuffer < ActiveSupport::SafeBuffer #:nodoc: def initialize(*) super diff --git a/actionview/lib/action_view/helpers/capture_helper.rb b/actionview/lib/action_view/helpers/capture_helper.rb index 63707280a3..c87c212cc7 100644 --- a/actionview/lib/action_view/helpers/capture_helper.rb +++ b/actionview/lib/action_view/helpers/capture_helper.rb @@ -36,10 +36,9 @@ module ActionView # # # - # The output of `capture` is the rendered string. For Example: + # The return of capture is the string generated by the block. For Example: # - # puts @greeting - # # => "Welcome to my shiny new web page! The date and time is 2018-09-06 11:09:16 -0500" + # @greeting # => "Welcome to my shiny new web page! The date and time is 2018-09-06 11:09:16 -0500" # def capture(*args) value = nil -- cgit v1.2.3 From 736edb982856f0de04d4566f657c0c84f145e7ef Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Fri, 7 Sep 2018 07:56:31 +0900 Subject: Formatting CHANGELOGs [ci skip] Fixing code block rendering, indentation, backticks, etc. --- actionview/CHANGELOG.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'actionview') diff --git a/actionview/CHANGELOG.md b/actionview/CHANGELOG.md index 46b3b1fa25..82add522df 100644 --- a/actionview/CHANGELOG.md +++ b/actionview/CHANGELOG.md @@ -76,7 +76,9 @@ *Simon Coffey* * Extract the `confirm` call in its own, overridable method in `rails_ujs`. - Example : + + Example: + Rails.confirm = function(message, element) { return (my_bootstrap_modal_confirm(message)); } @@ -84,7 +86,9 @@ *Mathieu Mahé* * Enable select tag helper to mark `prompt` option as `selected` and/or `disabled` for `required` - field. Example: + field. + + Example: select :post, :category, @@ -92,7 +96,9 @@ { selected: "", disabled: "", prompt: "Choose one" }, { required: true } - Placeholder option would be selected and disabled. The HTML produced: + Placeholder option would be selected and disabled. + + The HTML produced: }.dup + txt = +%{} if method && !%w(get post).include?(method.to_s) txt << %{} @@ -67,7 +67,7 @@ class FormHelperActiveRecordTest < ActionView::TestCase end def form_text(action = "/", id = nil, html_class = nil, remote = nil, multipart = nil, method = nil) - txt = %{
\n).dup + expected = +%(\n" @@ -223,7 +223,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_day_with_blank - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -232,7 +232,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_day_nil_with_blank - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -240,7 +240,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_day_with_two_digit_numbers - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -249,7 +249,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_day_with_html_options - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -258,7 +258,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_day_with_default_prompt - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -266,7 +266,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_day_with_custom_prompt - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -274,7 +274,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_day_with_generic_with_css_classes - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -282,7 +282,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_day_with_custom_with_css_classes - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -290,7 +290,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_month - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -299,7 +299,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_month_with_two_digit_numbers - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -308,7 +308,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_month_with_disabled - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -317,7 +317,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_month_with_field_name_override - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -326,7 +326,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_month_with_blank - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -335,7 +335,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_month_nil_with_blank - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -343,7 +343,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_month_with_numbers - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -352,7 +352,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_month_with_numbers_and_names - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -361,7 +361,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_month_with_format_string - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -371,7 +371,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_month_with_numbers_and_names_with_abbv - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -380,7 +380,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_month_with_abbv - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -391,7 +391,7 @@ class DateHelperTest < ActionView::TestCase def test_select_month_with_custom_names month_names = %w(nil Januar Februar Marts April Maj Juni Juli August September Oktober November December) - expected = %(\n) 1.upto(12) { |month| expected << %(\n) } expected << "\n" @@ -402,7 +402,7 @@ class DateHelperTest < ActionView::TestCase def test_select_month_with_zero_indexed_custom_names month_names = %w(Januar Februar Marts April Maj Juni Juli August September Oktober November December) - expected = %(\n) 1.upto(12) { |month| expected << %(\n) } expected << "\n" @@ -419,7 +419,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_month_with_html_options - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -427,7 +427,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_month_with_default_prompt - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -435,7 +435,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_month_with_custom_prompt - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -443,7 +443,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_month_with_generic_with_css_classes - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -451,7 +451,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_month_with_custom_with_css_classes - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -459,7 +459,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_year - expected = %(\n) expected << %(\n\n\n) expected << "\n" @@ -468,7 +468,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_year_with_disabled - expected = %(\n) expected << %(\n\n\n) expected << "\n" @@ -477,7 +477,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_year_with_field_name_override - expected = %(\n) expected << %(\n\n\n) expected << "\n" @@ -486,7 +486,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_year_with_type_discarding - expected = %(\n) expected << %(\n\n\n) expected << "\n" @@ -497,7 +497,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_year_descending - expected = %(\n) expected << %(\n\n\n) expected << "\n" @@ -514,7 +514,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_year_with_html_options - expected = %(\n) expected << %(\n\n\n) expected << "\n" @@ -522,7 +522,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_year_with_default_prompt - expected = %(\n) expected << %(\n\n\n\n) expected << "\n" @@ -530,7 +530,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_year_with_custom_prompt - expected = %(\n) expected << %(\n\n\n\n) expected << "\n" @@ -538,7 +538,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_year_with_generic_with_css_classes - expected = %(\n) expected << %(\n\n\n) expected << "\n" @@ -546,7 +546,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_year_with_custom_with_css_classes - expected = %(\n) expected << %(\n\n\n) expected << "\n" @@ -554,7 +554,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_year_with_position - expected = %(\n) expected << %(\n\n\n) expected << "\n" assert_dom_equal expected, select_year(Date.current, include_position: true, start_year: 2003, end_year: 2005) @@ -570,7 +570,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_hour - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -578,7 +578,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_hour_with_ampm - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -586,7 +586,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_hour_with_disabled - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -594,7 +594,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_hour_with_field_name_override - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -602,7 +602,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_hour_with_blank - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -610,7 +610,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_hour_nil_with_blank - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -618,7 +618,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_hour_with_html_options - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -626,7 +626,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_hour_with_default_prompt - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -634,7 +634,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_hour_with_custom_prompt - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -642,7 +642,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_hour_with_generic_with_css_classes - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -650,7 +650,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_hour_with_custom_with_css_classes - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -658,7 +658,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_minute - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -666,7 +666,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_minute_with_disabled - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -674,7 +674,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_minute_with_field_name_override - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -682,7 +682,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_minute_with_blank - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -690,7 +690,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_minute_with_blank_and_step - expected = %(\n) expected << %(\n\n\n\n\n) expected << "\n" @@ -698,7 +698,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_minute_nil_with_blank - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -706,7 +706,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_minute_nil_with_blank_and_step - expected = %(\n) expected << %(\n\n\n\n\n) expected << "\n" @@ -722,7 +722,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_minute_with_html_options - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -730,7 +730,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_minute_with_default_prompt - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -738,7 +738,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_minute_with_custom_prompt - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -746,7 +746,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_minute_with_generic_with_css_classes - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -754,7 +754,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_minute_with_custom_with_css_classes - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -762,7 +762,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_second - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -770,7 +770,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_second_with_disabled - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -778,7 +778,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_second_with_field_name_override - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -786,7 +786,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_second_with_blank - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -794,7 +794,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_second_nil_with_blank - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -802,7 +802,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_second_with_html_options - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -810,7 +810,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_second_with_default_prompt - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -818,7 +818,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_second_with_custom_prompt - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -826,7 +826,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_second_with_generic_with_css_classes - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -834,7 +834,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_second_with_custom_with_css_classes - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -842,7 +842,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_date - expected = %(\n) expected << %(\n\n\n) expected << "\n" @@ -867,7 +867,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_date_with_order - expected = %(\n) expected << %(\n\n\n\n\n\n\n\n\n\n\n\n) expected << "\n" @@ -884,7 +884,7 @@ class DateHelperTest < ActionView::TestCase def test_select_date_with_incomplete_order # Since the order is incomplete nothing will be shown - expected = %(\n).dup + expected = +%(\n) expected << %(\n) expected << %(\n) @@ -892,7 +892,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_date_with_disabled - expected = %(\n) expected << %(\n\n\n) expected << "\n" @@ -908,7 +908,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_date_with_no_start_year - expected = %(\n) (Date.today.year - 5).upto(Date.today.year + 1) do |y| if y == Date.today.year expected << %(\n) @@ -932,7 +932,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_date_with_no_end_year - expected = %(\n) 2003.upto(2008) do |y| if y == 2003 expected << %(\n) @@ -956,7 +956,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_date_with_no_start_or_end_year - expected = %(\n) (Date.today.year - 5).upto(Date.today.year + 5) do |y| if y == Date.today.year expected << %(\n) @@ -980,7 +980,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_date_with_zero_value - expected = %(\n) expected << %(\n\n\n) expected << "\n" @@ -996,7 +996,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_date_with_zero_value_and_no_start_year - expected = %(\n) (Date.today.year - 5).upto(Date.today.year + 1) { |y| expected << %(\n) } expected << "\n" @@ -1012,7 +1012,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_date_with_zero_value_and_no_end_year - expected = %(\n) last_year = Time.now.year + 5 2003.upto(last_year) { |y| expected << %(\n) } expected << "\n" @@ -1029,7 +1029,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_date_with_zero_value_and_no_start_and_end_year - expected = %(\n) (Date.today.year - 5).upto(Date.today.year + 5) { |y| expected << %(\n) } expected << "\n" @@ -1045,7 +1045,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_date_with_nil_value_and_no_start_and_end_year - expected = %(\n) (Date.today.year - 5).upto(Date.today.year + 5) { |y| expected << %(\n) } expected << "\n" @@ -1061,7 +1061,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_date_with_html_options - expected = %(\n) expected << %(\n\n\n) expected << "\n" @@ -1077,7 +1077,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_date_with_separator - expected = %(\n) expected << %(\n\n\n) expected << "\n" @@ -1097,7 +1097,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_date_with_separator_and_discard_day - expected = %(\n) expected << %(\n\n\n) expected << "\n" @@ -1113,7 +1113,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_date_with_separator_discard_month_and_day - expected = %(\n) expected << %(\n\n\n) expected << "\n" @@ -1124,7 +1124,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_date_with_hidden - expected = %(\n).dup + expected = +%(\n) expected << %(\n) expected << %(\n) @@ -1133,7 +1133,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_date_with_css_classes_option - expected = %(\n) expected << %(\n\n\n) expected << "\n" @@ -1149,7 +1149,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_date_with_custom_with_css_classes - expected = %(\n) expected << %(\n\n\n) expected << "\n" @@ -1165,7 +1165,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_date_with_css_classes_option_and_html_class_option - expected = %(\n) expected << %(\n\n\n) expected << "\n" @@ -1181,7 +1181,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_date_with_custom_with_css_classes_and_html_class_option - expected = %(\n) expected << %(\n\n\n) expected << "\n" @@ -1197,7 +1197,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_date_with_partial_with_css_classes_and_html_class_option - expected = %(\n) expected << %(\n\n\n) expected << "\n" @@ -1213,7 +1213,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_date_with_html_class_option - expected = %(\n) expected << %(\n\n\n) expected << "\n" @@ -1229,7 +1229,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_datetime - expected = %(\n) expected << %(\n\n\n) expected << "\n" @@ -1257,7 +1257,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_datetime_with_ampm - expected = %(\n) expected << %(\n\n\n) expected << "\n" @@ -1285,7 +1285,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_datetime_with_separators - expected = %(\n) expected << %(\n\n\n) expected << "\n" @@ -1313,7 +1313,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_datetime_with_nil_value_and_no_start_and_end_year - expected = %(\n) (Date.today.year - 5).upto(Date.today.year + 5) { |y| expected << %(\n) } expected << "\n" @@ -1341,7 +1341,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_datetime_with_html_options - expected = %(\n) expected << %(\n\n\n) expected << "\n" @@ -1369,7 +1369,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_datetime_with_all_separators - expected = %(\n) expected << %(\n\n\n) expected << "\n" @@ -1405,7 +1405,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_datetime_with_default_prompt - expected = %(\n) expected << %(\n\n\n\n) expected << "\n" @@ -1434,7 +1434,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_datetime_with_custom_prompt - expected = %(\n) expected << %(\n\n\n\n) expected << "\n" @@ -1463,7 +1463,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_datetime_with_generic_with_css_classes - expected = %(\n) expected << %(\n\n\n) expected << "\n" @@ -1491,7 +1491,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_datetime_with_custom_with_css_classes - expected = %(\n) expected << %(\n\n\n) expected << "\n" @@ -1519,7 +1519,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_datetime_with_custom_hours - expected = %(\n) expected << %(\n\n\n\n) expected << "\n" @@ -1548,7 +1548,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_datetime_with_hidden - expected = %(\n).dup + expected = +%(\n) expected << %(\n) expected << %(\n) expected << %(\n) @@ -1560,7 +1560,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_time - expected = %(\n).dup + expected = +%(\n) expected << %(\n) expected << %(\n) @@ -1579,7 +1579,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_time_with_ampm - expected = %(\n).dup + expected = +%(\n) expected << %(\n) expected << %(\n) @@ -1597,7 +1597,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_time_with_separator - expected = %(\n).dup + expected = +%(\n) expected << %(\n) expected << %(\n) expected << %(\n).dup + expected = +%(\n) expected << %(\n) expected << %(\n) @@ -1639,7 +1639,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_time_with_seconds_and_separator - expected = %(\n).dup + expected = +%(\n) expected << %(\n) expected << %(\n) @@ -1663,7 +1663,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_time_with_html_options - expected = %(\n).dup + expected = +%(\n) expected << %(\n) expected << %(\n) @@ -1686,7 +1686,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_time_with_default_prompt - expected = %(\n).dup + expected = +%(\n) expected << %(\n) expected << %(\n) @@ -1710,7 +1710,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_time_with_custom_prompt - expected = %(\n).dup + expected = +%(\n) expected << %(\n) expected << %(\n) @@ -1735,7 +1735,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_time_with_generic_with_css_classes - expected = %(\n).dup + expected = +%(\n) expected << %(\n) expected << %(\n) @@ -1759,7 +1759,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_time_with_custom_with_css_classes - expected = %(\n).dup + expected = +%(\n) expected << %(\n) expected << %(\n) @@ -1783,7 +1783,7 @@ class DateHelperTest < ActionView::TestCase end def test_select_time_with_hidden - expected = %(\n).dup + expected = +%(\n) expected << %(\n) expected << %(\n) expected << %(\n) @@ -1797,7 +1797,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.written_on = Date.new(2004, 6, 15) - expected = %{\n} expected << %{\n\n\n\n\n\n\n\n\n\n\n} expected << "\n" @@ -1817,7 +1817,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.written_on = Date.new(2004, 6, 15) - expected = %{\n} expected << %{\n\n\n\n\n\n\n\n\n\n\n} expected << "\n" @@ -1837,7 +1837,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.written_on = Date.new(2004, 6, 15) - expected = %{\n} expected << %{\n\n\n\n\n\n\n\n\n\n\n} expected << "\n" @@ -1875,7 +1875,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.written_on = Date.new(2004, 6, 15) - expected = "\n".dup + expected = +"\n" expected << %{\n".dup + expected = +"\n" expected << "\n" expected << %{\n".dup + expected = +"\n" expected << %{\n".dup + expected = +"\n" expected << %{\n\n\n\n\n\n\n\n\n\n\n\n\n}.dup + expected = +%{\n} expected << %{\n} expected << %{\n} @@ -1962,7 +1962,7 @@ class DateHelperTest < ActionView::TestCase concat f.date_select(:written_on) end - expected = %{\n}.dup + expected = +%{\n} expected << %{\n} expected << %{\n} @@ -1978,7 +1978,7 @@ class DateHelperTest < ActionView::TestCase concat f.date_select(:written_on) end - expected = %{\n}.dup + expected = +%{\n} expected << %{\n} expected << %{\n} @@ -1990,7 +1990,7 @@ class DateHelperTest < ActionView::TestCase @post.written_on = Date.new(2004, 6, 15) id = 456 - expected = %{\n} expected << %{\n\n\n\n\n\n\n\n\n\n\n} expected << "\n" @@ -2010,7 +2010,7 @@ class DateHelperTest < ActionView::TestCase @post.written_on = Date.new(2004, 6, 15) id = 123 - expected = %{\n} expected << %{\n\n\n\n\n\n\n\n\n\n\n} expected << "\n" @@ -2029,7 +2029,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.written_on = Date.new(2004, 6, 15) - expected = %{\n} 1.upto(31) { |i| expected << %(\n) } expected << "\n" @@ -2049,7 +2049,7 @@ class DateHelperTest < ActionView::TestCase start_year = Time.now.year - 5 end_year = Time.now.year + 5 - expected = %{\n} start_year.upto(end_year) { |i| expected << %(\n) } expected << "\n" @@ -2069,7 +2069,7 @@ class DateHelperTest < ActionView::TestCase start_year = Time.now.year - 5 end_year = Time.now.year + 5 - expected = %{\n} expected << "\n" start_year.upto(end_year) { |i| expected << %(\n) } expected << "\n" @@ -2113,7 +2113,7 @@ class DateHelperTest < ActionView::TestCase start_year = Time.now.year - 5 end_year = Time.now.year + 5 - expected = %{\n} expected << "\n" start_year.upto(end_year) { |i| expected << %(\n) } expected << "\n" @@ -2145,7 +2145,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.written_on = Date.new(2004, 6, 15) - expected = %{\n} expected << %{\n\n\n\n\n\n\n\n\n\n\n} expected << "\n" @@ -2164,7 +2164,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.written_on = Date.new(2004, 6, 15) - expected = %{\n} expected << %{\n\n\n\n\n\n\n\n\n\n\n} expected << "\n" @@ -2188,7 +2188,7 @@ class DateHelperTest < ActionView::TestCase concat f.date_select(:written_on, {}, { class: "selector" }) end - expected = %{\n} expected << %{\n\n\n\n\n\n\n\n\n\n\n} expected << "\n" @@ -2208,7 +2208,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.written_on = Date.new(2004, 6, 15) - expected = %{\n} expected << %{\n\n\n\n\n\n\n\n\n\n\n} expected << "\n" @@ -2232,7 +2232,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.written_on = Date.new(2004, 6, 15) - expected = %{\n} expected << %{\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n} expected << "\n" @@ -2255,7 +2255,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.written_on = Date.new(2004, 6, 15) - expected = %{\n} expected << %{\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n} expected << "\n" @@ -2273,7 +2273,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.written_on = Date.new(2004, 6, 15) - expected = %{\n} expected << %{\n\n\n\n\n\n\n\n\n\n\n\n} expected << "\n" @@ -2293,7 +2293,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.written_on = Date.new(2004, 6, 15) - expected = %{\n} expected << %{\n\n\n\n\n\n\n\n\n\n\n\n} expected << "\n" @@ -2313,7 +2313,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.written_on = Date.new(2004, 6, 15) - expected = %{\n} expected << %{\n\n\n\n\n\n\n\n\n\n\n} expected << "\n" @@ -2333,7 +2333,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.written_on = Date.new(2004, 6, 15) - expected = %{\n} expected << %{\n\n\n\n\n\n\n\n\n\n\n} expected << "\n" @@ -2353,7 +2353,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.written_on = Time.local(2004, 6, 15, 15, 16, 35) - expected = %{\n}.dup + expected = +%{\n} expected << %{\n} expected << %{\n} @@ -2372,7 +2372,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.written_on = Time.local(2004, 6, 15, 15, 16, 35) - expected = %{\n}.dup + expected = +%{\n} expected << %{\n} expected << %{\n} @@ -2391,7 +2391,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.written_on = Time.local(2004, 6, 15, 15, 16, 35) - expected = %{\n}.dup + expected = +%{\n} expected << %{\n} expected << %{\n} @@ -2410,7 +2410,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.written_on = Time.local(2004, 6, 15, 15, 16, 35) - expected = %(\n) 0.upto(23) { |i| expected << %(\n) } expected << "\n" expected << " : " @@ -2425,7 +2425,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.written_on = Time.local(2004, 6, 15, 15, 16, 35) - expected = %{\n}.dup + expected = +%{\n} expected << %{\n} expected << %{\n} @@ -2448,7 +2448,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.written_on = Time.local(2004, 6, 15, 15, 16, 35) - expected = %{\n}.dup + expected = +%{\n} expected << %{\n} expected << %{\n} @@ -2471,7 +2471,7 @@ class DateHelperTest < ActionView::TestCase concat f.time_select(:written_on, {}, { class: "selector" }) end - expected = %{\n}.dup + expected = +%{\n} expected << %{\n} expected << %{\n} @@ -2490,7 +2490,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.written_on = Time.local(2004, 6, 15, 15, 16, 35) - expected = %{\n}.dup + expected = +%{\n} expected << %{\n} expected << %{\n} @@ -2517,7 +2517,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.written_on = Time.local(2004, 6, 15, 15, 16, 35) - expected = %{\n}.dup + expected = +%{\n} expected << %{\n} expected << %{\n} @@ -2538,7 +2538,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.written_on = Time.local(2004, 6, 15, 15, 16, 35) - expected = %{\n}.dup + expected = +%{\n} expected << %{\n} expected << %{\n} @@ -2559,7 +2559,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.written_on = Time.local(2004, 6, 15, 15, 16, 35) - expected = %{\n}.dup + expected = +%{\n} expected << %{\n} expected << %{\n} @@ -2580,7 +2580,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.written_on = Time.local(2004, 6, 15, 15, 16, 35) - expected = %{\n}.dup + expected = +%{\n} expected << %{\n} expected << %{\n} @@ -2601,7 +2601,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.written_on = Time.local(2004, 6, 15, 15, 16, 35) - expected = %{\n}.dup + expected = +%{\n} expected << %{\n} expected << %{\n} @@ -2620,7 +2620,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.updated_at = Time.local(2004, 6, 15, 16, 35) - expected = %{\n} expected << %{\n\n\n\n\n\n\n\n\n\n\n} expected << "\n" @@ -2649,7 +2649,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.updated_at = Time.local(2004, 6, 15, 16, 35) - expected = %{\n} expected << %{\n\n\n\n\n\n\n\n\n\n\n} expected << "\n" @@ -2715,7 +2715,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new - expected = %{\n} expected << %{\n\n\n\n\n\n\n\n\n\n\n} expected << "\n" @@ -2750,7 +2750,7 @@ class DateHelperTest < ActionView::TestCase concat f.datetime_select(:updated_at, {}, { class: "selector" }) end - expected = %{\n}.dup + expected = +%{\n} expected << %{\n} expected << %{\n} expected << %{ — \n} @@ -2763,7 +2763,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.updated_at = Time.local(2004, 6, 15, 15, 16, 35) - expected = %{\n} expected << %{\n\n\n\n\n\n\n\n\n\n\n} expected << "\n" @@ -2816,7 +2816,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.updated_at = nil - expected = %{\n} expected << %{\n\n\n\n\n\n\n\n\n\n\n\n} expected << "\n" @@ -2845,7 +2845,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.updated_at = nil - expected = %{\n} expected << %{\n\n\n\n\n\n\n\n\n\n\n\n} expected << "\n" @@ -2874,7 +2874,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.written_on = Time.local(2004, 6, 15, 15, 16, 35) - expected = %{\n} expected << %{\n\n\n\n\n\n\n\n\n\n\n} expected << "\n" @@ -2903,7 +2903,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.written_on = Time.local(2004, 6, 15, 15, 16, 35) - expected = %{\n} expected << %{\n\n\n\n\n\n\n\n\n\n\n} expected << "\n" @@ -2929,7 +2929,7 @@ class DateHelperTest < ActionView::TestCase end def test_date_select_with_zero_value_and_no_start_year - expected = %(\n) (Date.today.year - 5).upto(Date.today.year + 1) { |y| expected << %(\n) } expected << "\n" @@ -2945,7 +2945,7 @@ class DateHelperTest < ActionView::TestCase end def test_date_select_with_zero_value_and_no_end_year - expected = %(\n) last_year = Time.now.year + 5 2003.upto(last_year) { |y| expected << %(\n) } expected << "\n" @@ -2962,7 +2962,7 @@ class DateHelperTest < ActionView::TestCase end def test_date_select_with_zero_value_and_no_start_and_end_year - expected = %(\n) (Date.today.year - 5).upto(Date.today.year + 5) { |y| expected << %(\n) } expected << "\n" @@ -2978,7 +2978,7 @@ class DateHelperTest < ActionView::TestCase end def test_date_select_with_nil_value_and_no_start_and_end_year - expected = %(\n) (Date.today.year - 5).upto(Date.today.year + 5) { |y| expected << %(\n) } expected << "\n" @@ -2994,7 +2994,7 @@ class DateHelperTest < ActionView::TestCase end def test_datetime_select_with_nil_value_and_no_start_and_end_year - expected = %(\n) (Date.today.year - 5).upto(Date.today.year + 5) { |y| expected << %(\n) } expected << "\n" @@ -3026,7 +3026,7 @@ class DateHelperTest < ActionView::TestCase @post.updated_at = Time.local(2004, 6, 15, 16, 35) id = 456 - expected = %{\n} expected << %{\n\n\n\n\n\n\n\n\n\n\n} expected << "\n" @@ -3060,7 +3060,7 @@ class DateHelperTest < ActionView::TestCase concat f.datetime_select(:updated_at) end - expected = %{\n} expected << %{\n\n\n\n\n\n\n\n\n\n\n} expected << "\n" @@ -3090,7 +3090,7 @@ class DateHelperTest < ActionView::TestCase @post.updated_at = Time.local(2004, 6, 15, 16, 35) id = @post.id - expected = %{\n} expected << %{\n\n\n\n\n\n\n\n\n\n\n} expected << "\n" @@ -3119,7 +3119,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.updated_at = Time.local(2004, 6, 15, 15, 16, 35) - expected = %{\n} 1999.upto(2009) { |i| expected << %(\n) } expected << "\n" expected << %{\n}.dup + expected = +%{\n} expected << %{\n" @@ -3175,7 +3175,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.updated_at = Time.local(2004, 6, 15, 15, 16, 35) - expected = %{\n} 1999.upto(2009) { |i| expected << %(\n) } expected << "\n" expected << %{\n} @@ -3198,7 +3198,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.updated_at = Time.local(2004, 6, 15, 15, 16, 35) - expected = %{\n}.dup + expected = +%{\n} expected << %{\n} expected << %{\n} @@ -3217,7 +3217,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.updated_at = Time.local(2004, 6, 15, 15, 16, 35) - expected = %{\n}.dup + expected = +%{\n} expected << %{\n} expected << %{\n} @@ -3236,7 +3236,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.updated_at = Time.local(2004, 6, 15, 15, 16, 35) - expected = %{\n} 1999.upto(2009) { |i| expected << %(\n) } expected << "\n" expected << %{\n}.dup + expected = +%{\n" expected << %{\n}.dup + expected = +%{\n" expected << %{\n}.dup + expected = +%{\n" expected << %{\n}.dup + expected = +%{\n} expected << %{\n" @@ -3353,7 +3353,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.updated_at = nil - expected = %{\n} 2001.upto(2011) { |i| expected << %(\n) } expected << "\n" expected << %{\n}.dup + expected = +%{\n" @@ -3400,7 +3400,7 @@ class DateHelperTest < ActionView::TestCase @post = Post.new @post.updated_at = nil - expected = %{\n} (Time.now.year - 5).upto(Time.now.year + 5) { |i| expected << %(\n) } expected << "\n" expected << %{\n}.dup + expected = +%{\n" diff --git a/actionview/test/template/form_helper/form_with_test.rb b/actionview/test/template/form_helper/form_with_test.rb index c30176349c..876e799d93 100644 --- a/actionview/test/template/form_helper/form_with_test.rb +++ b/actionview/test/template/form_helper/form_with_test.rb @@ -37,7 +37,7 @@ class FormWithActsLikeFormTagTest < FormWithTest method = options[:method] skip_enforcing_utf8 = options.fetch(:skip_enforcing_utf8, false) - "".dup.tap do |txt| + (+"").tap do |txt| unless skip_enforcing_utf8 txt << %{} end @@ -53,7 +53,7 @@ class FormWithActsLikeFormTagTest < FormWithTest method = method.to_s == "get" ? "get" : "post" - txt = %{}.dup + txt = +%{} end if method && !%w(get post).include?(method.to_s) @@ -2338,7 +2338,7 @@ class FormWithActsLikeFormForTest < FormWithTest end def form_text(action = "/", id = nil, html_class = nil, local = nil, multipart = nil, method = nil) - txt = %{}.dup + txt = +%{} else - txt = "".dup + txt = +"" end if method && !%w(get post).include?(method.to_s) @@ -3571,7 +3571,7 @@ class FormHelperTest < ActionView::TestCase end def form_text(action = "/", id = nil, html_class = nil, remote = nil, multipart = nil, method = nil) - txt = %{} end @@ -42,7 +42,7 @@ class FormTagHelperTest < ActionView::TestCase method = method.to_s == "get" ? "get" : "post" - txt = %{ tags), escape_javascript(%(dont tags)) - assert_equal %(unicode 
 newline), escape_javascript(%(unicode \342\200\250 newline).dup.force_encoding(Encoding::UTF_8).encode!) - assert_equal %(unicode 
 newline), escape_javascript(%(unicode \342\200\251 newline).dup.force_encoding(Encoding::UTF_8).encode!) + assert_equal %(unicode 
 newline), escape_javascript((+%(unicode \342\200\250 newline)).force_encoding(Encoding::UTF_8).encode!) + assert_equal %(unicode 
 newline), escape_javascript((+%(unicode \342\200\251 newline)).force_encoding(Encoding::UTF_8).encode!) assert_equal %(dont <\\/close> tags), j(%(dont tags)) end diff --git a/actionview/test/template/render_test.rb b/actionview/test/template/render_test.rb index 6ff7ddba0f..afe68b7ff0 100644 --- a/actionview/test/template/render_test.rb +++ b/actionview/test/template/render_test.rb @@ -585,7 +585,7 @@ module RenderTestCases def test_render_with_passing_couple_extensions_to_one_register_template_handler_function_call ActionView::Template.register_template_handler :foo1, :foo2, CustomHandler - assert_equal @view.render(inline: "Hello, World!".dup, type: :foo1), @view.render(inline: "Hello, World!".dup, type: :foo2) + assert_equal @view.render(inline: +"Hello, World!", type: :foo1), @view.render(inline: +"Hello, World!", type: :foo2) ensure ActionView::Template.unregister_template_handler :foo1, :foo2 end diff --git a/actionview/test/template/streaming_render_test.rb b/actionview/test/template/streaming_render_test.rb index ef000300cc..f196c42c4f 100644 --- a/actionview/test/template/streaming_render_test.rb +++ b/actionview/test/template/streaming_render_test.rb @@ -19,7 +19,7 @@ class SetupFiberedBase < ActiveSupport::TestCase def buffered_render(options) body = render_body(options) - string = "".dup + string = +"" body.each do |piece| string << piece end diff --git a/actionview/test/template/text_helper_test.rb b/actionview/test/template/text_helper_test.rb index 4d47706bda..c4e420a95b 100644 --- a/actionview/test/template/text_helper_test.rb +++ b/actionview/test/template/text_helper_test.rb @@ -13,7 +13,7 @@ class TextHelperTest < ActionView::TestCase end def test_concat - self.output_buffer = "foo".dup + self.output_buffer = +"foo" assert_equal "foobar", concat("bar") assert_equal "foobar", output_buffer end @@ -106,8 +106,8 @@ class TextHelperTest < ActionView::TestCase end def test_truncate_multibyte - assert_equal "\354\225\204\353\246\254\353\236\221 \354\225\204\353\246\254 ...".dup.force_encoding(Encoding::UTF_8), - truncate("\354\225\204\353\246\254\353\236\221 \354\225\204\353\246\254 \354\225\204\353\235\274\353\246\254\354\230\244".dup.force_encoding(Encoding::UTF_8), length: 10) + assert_equal (+"\354\225\204\353\246\254\353\236\221 \354\225\204\353\246\254 ...").force_encoding(Encoding::UTF_8), + truncate((+"\354\225\204\353\246\254\353\236\221 \354\225\204\353\246\254 \354\225\204\353\235\274\353\246\254\354\230\244").force_encoding(Encoding::UTF_8), length: 10) end def test_truncate_does_not_modify_the_options_hash @@ -327,7 +327,7 @@ class TextHelperTest < ActionView::TestCase end def test_excerpt_with_utf8 - assert_equal("...\357\254\203ciency could not be...".dup.force_encoding(Encoding::UTF_8), excerpt("That's why e\357\254\203ciency could not be helped".dup.force_encoding(Encoding::UTF_8), "could", radius: 8)) + assert_equal((+"...\357\254\203ciency could not be...").force_encoding(Encoding::UTF_8), excerpt((+"That's why e\357\254\203ciency could not be helped").force_encoding(Encoding::UTF_8), "could", radius: 8)) end def test_excerpt_does_not_modify_the_options_hash diff --git a/actionview/test/template/url_helper_test.rb b/actionview/test/template/url_helper_test.rb index 9d91dbb72b..7b77bae30d 100644 --- a/actionview/test/template/url_helper_test.rb +++ b/actionview/test/template/url_helper_test.rb @@ -548,7 +548,7 @@ class UrlHelperTest < ActiveSupport::TestCase def test_current_page_with_escaped_params_with_different_encoding @request = request_for_url("/") - @request.stub(:path, "/category/administra%c3%a7%c3%a3o".dup.force_encoding(Encoding::ASCII_8BIT)) do + @request.stub(:path, (+"/category/administra%c3%a7%c3%a3o").force_encoding(Encoding::ASCII_8BIT)) do assert current_page?(controller: "foo", action: "category", category: "administração") assert current_page?("http://www.example.com/category/administra%c3%a7%c3%a3o") end -- cgit v1.2.3 From 0fe2bb816f60f4daf5d0d24468af94be971d0eaf Mon Sep 17 00:00:00 2001 From: Sakshi Jain Date: Sat, 22 Sep 2018 17:15:29 +0530 Subject: Remove private def --- actionview/test/abstract_unit.rb | 18 ++++++++++-------- actionview/test/template/form_helper/form_with_test.rb | 14 ++++++++------ 2 files changed, 18 insertions(+), 14 deletions(-) (limited to 'actionview') diff --git a/actionview/test/abstract_unit.rb b/actionview/test/abstract_unit.rb index f20a66c2d2..db46420022 100644 --- a/actionview/test/abstract_unit.rb +++ b/actionview/test/abstract_unit.rb @@ -225,12 +225,14 @@ class ActiveSupport::TestCase include ActionDispatch::DrawOnce include ActiveSupport::Testing::MethodCallAssertions - # Skips the current run on Rubinius using Minitest::Assertions#skip - private def rubinius_skip(message = "") - skip message if RUBY_ENGINE == "rbx" - end - # Skips the current run on JRuby using Minitest::Assertions#skip - private def jruby_skip(message = "") - skip message if defined?(JRUBY_VERSION) - end + private + # Skips the current run on Rubinius using Minitest::Assertions#skip + def rubinius_skip(message = "") + skip message if RUBY_ENGINE == "rbx" + end + + # Skips the current run on JRuby using Minitest::Assertions#skip + def jruby_skip(message = "") + skip message if defined?(JRUBY_VERSION) + end end diff --git a/actionview/test/template/form_helper/form_with_test.rb b/actionview/test/template/form_helper/form_with_test.rb index c30176349c..85bd72e524 100644 --- a/actionview/test/template/form_helper/form_with_test.rb +++ b/actionview/test/template/form_helper/form_with_test.rb @@ -450,13 +450,15 @@ class FormWithActsLikeFormForTest < FormWithTest def test_form_with_doesnt_call_private_or_protected_properties_on_form_object_skipping_value obj = Class.new do - private def private_property - "That would be great." - end + private + def private_property + "That would be great." + end - protected def protected_property - "I believe you have my stapler." - end + protected + def protected_property + "I believe you have my stapler." + end end.new form_with(model: obj, scope: "other_name", url: "/", id: "edit-other-name") do |f| -- cgit v1.2.3 From 4f96e739c215331562c09cd215536c35a85508fd Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 24 Sep 2018 14:49:26 -0700 Subject: Remove deprecated catch-all route in the AV tests This commit removes a deprecated catch-all route in the AV tests. It defines and includes the necessary routes for each test such that we don't need the catch-all anymore. This also helps push us toward #33970 --- actionview/test/abstract_unit.rb | 79 ++++---------- .../test/actionpack/controller/capture_test.rb | 9 ++ .../test/actionpack/controller/layout_test.rb | 21 ++++ .../test/actionpack/controller/render_test.rb | 118 +++++++++++++++++++++ .../test/actionpack/controller/view_paths_test.rb | 10 ++ actionview/test/active_record_unit.rb | 12 +++ .../test/activerecord/controller_runtime_test.rb | 8 ++ .../activerecord/form_helper_activerecord_test.rb | 3 + .../test/activerecord/polymorphic_routes_test.rb | 8 +- .../test/activerecord/relation_cache_test.rb | 1 + ...nder_partial_with_record_identification_test.rb | 20 ++++ actionview/test/template/erb/form_for_test.rb | 6 +- actionview/test/template/erb/helper.rb | 11 +- .../test/template/form_helper/form_with_test.rb | 5 +- actionview/test/template/form_helper_test.rb | 1 + actionview/test/template/test_case_test.rb | 12 ++- actionview/test/template/url_helper_test.rb | 44 ++++++-- 17 files changed, 290 insertions(+), 78 deletions(-) (limited to 'actionview') diff --git a/actionview/test/abstract_unit.rb b/actionview/test/abstract_unit.rb index f20a66c2d2..f842e2c76d 100644 --- a/actionview/test/abstract_unit.rb +++ b/actionview/test/abstract_unit.rb @@ -65,43 +65,6 @@ module RenderERBUtils end end -SharedTestRoutes = ActionDispatch::Routing::RouteSet.new - -module ActionDispatch - module SharedRoutes - def before_setup - @routes = SharedTestRoutes - super - end - end - - # Hold off drawing routes until all the possible controller classes - # have been loaded. - module DrawOnce - class << self - attr_accessor :drew - end - self.drew = false - - def before_setup - super - return if DrawOnce.drew - - ActiveSupport::Deprecation.silence do - SharedTestRoutes.draw do - get ":controller(/:action)" - end - - ActionDispatch::IntegrationTest.app.routes.draw do - get ":controller(/:action)" - end - end - - DrawOnce.drew = true - end - end -end - class RoutedRackApp attr_reader :routes @@ -132,10 +95,11 @@ class BasicController end class ActionDispatch::IntegrationTest < ActiveSupport::TestCase - include ActionDispatch::SharedRoutes - def self.build_app(routes = nil) - RoutedRackApp.new(routes || ActionDispatch::Routing::RouteSet.new) do |middleware| + routes ||= ActionDispatch::Routing::RouteSet.new.tap { |rs| + rs.draw { } + } + RoutedRackApp.new(routes) do |middleware| middleware.use ActionDispatch::ShowExceptions, ActionDispatch::PublicExceptions.new("#{FIXTURE_LOAD_PATH}/public") middleware.use ActionDispatch::DebugExceptions middleware.use ActionDispatch::Callbacks @@ -151,13 +115,10 @@ class ActionDispatch::IntegrationTest < ActiveSupport::TestCase def with_routing(&block) temporary_routes = ActionDispatch::Routing::RouteSet.new old_app, self.class.app = self.class.app, self.class.build_app(temporary_routes) - old_routes = SharedTestRoutes - silence_warnings { Object.const_set(:SharedTestRoutes, temporary_routes) } yield temporary_routes ensure self.class.app = old_app - silence_warnings { Object.const_set(:SharedTestRoutes, old_routes) } end end @@ -165,30 +126,37 @@ ActionView::RoutingUrlFor.include(ActionDispatch::Routing::UrlFor) module ActionController class Base - # This stub emulates the Railtie including the URL helpers from a Rails application - include SharedTestRoutes.url_helpers - include SharedTestRoutes.mounted_helpers - self.view_paths = FIXTURE_LOAD_PATH def self.test_routes(&block) routes = ActionDispatch::Routing::RouteSet.new routes.draw(&block) include routes.url_helpers + routes end end class TestCase include ActionDispatch::TestProcess - include ActionDispatch::SharedRoutes - end -end -module ActionView - class TestCase - # Must repeat the setup because AV::TestCase is a duplication - # of AC::TestCase - include ActionDispatch::SharedRoutes + def self.with_routes(&block) + routes = ActionDispatch::Routing::RouteSet.new + routes.draw(&block) + include Module.new { + define_method(:setup) do + super() + @routes = routes + @controller.singleton_class.include @routes.url_helpers + end + } + routes + end + + def with_routes(&block) + @routes = ActionDispatch::Routing::RouteSet.new + @routes.draw(&block) + @routes + end end end @@ -222,7 +190,6 @@ module ActionDispatch end class ActiveSupport::TestCase - include ActionDispatch::DrawOnce include ActiveSupport::Testing::MethodCallAssertions # Skips the current run on Rubinius using Minitest::Assertions#skip diff --git a/actionview/test/actionpack/controller/capture_test.rb b/actionview/test/actionpack/controller/capture_test.rb index 09309e5b6d..d02125bafa 100644 --- a/actionview/test/actionpack/controller/capture_test.rb +++ b/actionview/test/actionpack/controller/capture_test.rb @@ -37,6 +37,15 @@ end class CaptureTest < ActionController::TestCase tests CaptureController + with_routes do + get :content_for, to: "test#content_for" + get :capturing, to: "test#capturing" + get :proper_block_detection, to: "test#proper_block_detection" + get :non_erb_block_content_for, to: "test#non_erb_block_content_for" + get :content_for_concatenated, to: "test#content_for_concatenated" + get :content_for_with_parameter, to: "test#content_for_with_parameter" + end + def setup super # enable a logger so that (e.g.) the benchmarking stuff runs, so we can get diff --git a/actionview/test/actionpack/controller/layout_test.rb b/actionview/test/actionpack/controller/layout_test.rb index ff66ff2a1a..14acb737f9 100644 --- a/actionview/test/actionpack/controller/layout_test.rb +++ b/actionview/test/actionpack/controller/layout_test.rb @@ -48,6 +48,10 @@ end class LayoutAutoDiscoveryTest < ActionController::TestCase include TemplateHandlerHelper + with_routes do + get :hello, to: 'views#hello' + end + def setup super @request.host = "www.nextangle.com" @@ -148,6 +152,11 @@ class LayoutSetInResponseTest < ActionController::TestCase include ActionView::Template::Handlers include TemplateHandlerHelper + with_routes do + get :hello, to: 'views#hello' + get :hello, to: 'views#goodbye' + end + def test_layout_set_when_using_default_layout @controller = DefaultLayoutController.new get :hello @@ -234,6 +243,10 @@ class SetsNonExistentLayoutFile < LayoutTest end class LayoutExceptionRaisedTest < ActionController::TestCase + with_routes do + get :hello, to: 'views#hello' + end + def test_exception_raised_when_layout_file_not_found @controller = SetsNonExistentLayoutFile.new assert_raise(ActionView::MissingTemplate) { get :hello } @@ -247,6 +260,10 @@ class LayoutStatusIsRendered < LayoutTest end class LayoutStatusIsRenderedTest < ActionController::TestCase + with_routes do + get :hello, to: 'views#hello' + end + def test_layout_status_is_rendered @controller = LayoutStatusIsRendered.new get :hello @@ -260,6 +277,10 @@ unless Gem.win_platform? end class LayoutSymlinkedIsRenderedTest < ActionController::TestCase + with_routes do + get :hello, to: 'views#hello' + end + def test_symlinked_layout_is_rendered @controller = LayoutSymlinkedTest.new get :hello diff --git a/actionview/test/actionpack/controller/render_test.rb b/actionview/test/actionpack/controller/render_test.rb index 3e6b55a87e..204903c60c 100644 --- a/actionview/test/actionpack/controller/render_test.rb +++ b/actionview/test/actionpack/controller/render_test.rb @@ -632,6 +632,124 @@ end class RenderTest < ActionController::TestCase tests TestController + with_routes do + get :"hyphen-ated", to: "test#hyphen-ated" + get :accessing_action_name_in_template, to: "test#accessing_action_name_in_template" + get :accessing_controller_name_in_template, to: "test#accessing_controller_name_in_template" + get :accessing_local_assigns_in_inline_template, to: "test#accessing_local_assigns_in_inline_template" + get :accessing_logger_in_template, to: "test#accessing_logger_in_template" + get :accessing_params_in_template, to: "test#accessing_params_in_template" + get :accessing_params_in_template_with_layout, to: "test#accessing_params_in_template_with_layout" + get :accessing_request_in_template, to: "test#accessing_request_in_template" + get :action_talk_to_layout, to: "test#action_talk_to_layout" + get :builder_layout_test, to: "test#builder_layout_test" + get :builder_partial_test, to: "test#builder_partial_test" + get :clone, to: "test#clone" + get :determine_layout, to: "test#determine_layout" + get :double_redirect, to: "test#double_redirect" + get :double_render, to: "test#double_render" + get :empty_partial_collection, to: "test#empty_partial_collection" + get :formatted_html_erb, to: "test#formatted_html_erb" + get :formatted_xml_erb, to: "test#formatted_xml_erb" + get :greeting, to: "test#greeting" + get :hello_in_a_string, to: "test#hello_in_a_string" + get :hello_world, to: "fun/games#hello_world" + get :hello_world, to: "test#hello_world" + get :hello_world_file, to: "test#hello_world_file" + get :hello_world_from_rxml_using_action, to: "test#hello_world_from_rxml_using_action" + get :hello_world_from_rxml_using_template, to: "test#hello_world_from_rxml_using_template" + get :hello_world_with_layout_false, to: "test#hello_world_with_layout_false" + get :layout_overriding_layout, to: "test#layout_overriding_layout" + get :layout_test, to: "test#layout_test" + get :layout_test_with_different_layout, to: "test#layout_test_with_different_layout" + get :layout_test_with_different_layout_and_string_action, to: "test#layout_test_with_different_layout_and_string_action" + get :layout_test_with_different_layout_and_symbol_action, to: "test#layout_test_with_different_layout_and_symbol_action" + get :missing_partial, to: "test#missing_partial" + get :nested_partial_with_form_builder, to: "fun/games#nested_partial_with_form_builder" + get :new, to: "quiz/questions#new" + get :partial, to: "test#partial" + get :partial_collection, to: "test#partial_collection" + get :partial_collection_shorthand_with_different_types_of_records, to: "test#partial_collection_shorthand_with_different_types_of_records" + get :partial_collection_shorthand_with_locals, to: "test#partial_collection_shorthand_with_locals" + get :partial_collection_with_as, to: "test#partial_collection_with_as" + get :partial_collection_with_as_and_counter, to: "test#partial_collection_with_as_and_counter" + get :partial_collection_with_as_and_iteration, to: "test#partial_collection_with_as_and_iteration" + get :partial_collection_with_counter, to: "test#partial_collection_with_counter" + get :partial_collection_with_iteration, to: "test#partial_collection_with_iteration" + get :partial_collection_with_locals, to: "test#partial_collection_with_locals" + get :partial_collection_with_spacer, to: "test#partial_collection_with_spacer" + get :partial_collection_with_spacer_which_uses_render, to: "test#partial_collection_with_spacer_which_uses_render" + get :partial_formats_html, to: "test#partial_formats_html" + get :partial_hash_collection, to: "test#partial_hash_collection" + get :partial_hash_collection_with_locals, to: "test#partial_hash_collection_with_locals" + get :partial_html_erb, to: "test#partial_html_erb" + get :partial_only, to: "test#partial_only" + get :partial_with_counter, to: "test#partial_with_counter" + get :partial_with_form_builder, to: "test#partial_with_form_builder" + get :partial_with_form_builder_subclass, to: "test#partial_with_form_builder_subclass" + get :partial_with_hash_object, to: "test#partial_with_hash_object" + get :partial_with_locals, to: "test#partial_with_locals" + get :partial_with_nested_object, to: "test#partial_with_nested_object" + get :partial_with_nested_object_shorthand, to: "test#partial_with_nested_object_shorthand" + get :partial_with_string_locals, to: "test#partial_with_string_locals" + get :partials_list, to: "test#partials_list" + get :render_action_hello_world, to: "test#render_action_hello_world" + get :render_action_hello_world_as_string, to: "test#render_action_hello_world_as_string" + get :render_action_hello_world_with_symbol, to: "test#render_action_hello_world_with_symbol" + get :render_action_upcased_hello_world, to: "test#render_action_upcased_hello_world" + get :render_and_redirect, to: "test#render_and_redirect" + get :render_call_to_partial_with_layout, to: "test#render_call_to_partial_with_layout" + get :render_call_to_partial_with_layout_in_main_layout_and_within_content_for_layout, to: "test#render_call_to_partial_with_layout_in_main_layout_and_within_content_for_layout" + get :render_custom_code, to: "test#render_custom_code" + get :render_file_as_string_with_locals, to: "test#render_file_as_string_with_locals" + get :render_file_from_template, to: "test#render_file_from_template" + get :render_file_not_using_full_path, to: "test#render_file_not_using_full_path" + get :render_file_not_using_full_path_with_dot_in_path, to: "test#render_file_not_using_full_path_with_dot_in_path" + get :render_file_using_pathname, to: "test#render_file_using_pathname" + get :render_file_with_instance_variables, to: "test#render_file_with_instance_variables" + get :render_file_with_locals, to: "test#render_file_with_locals" + get :render_hello_world, to: "test#render_hello_world" + get :render_hello_world_from_variable, to: "test#render_hello_world_from_variable" + get :render_hello_world_with_forward_slash, to: "test#render_hello_world_with_forward_slash" + get :render_implicit_html_template_from_xhr_request, to: "test#render_implicit_html_template_from_xhr_request" + get :render_implicit_js_template_without_layout, to: "test#render_implicit_js_template_without_layout" + get :render_line_offset, to: "test#render_line_offset" + get :render_nothing_with_appendix, to: "test#render_nothing_with_appendix" + get :render_template_in_top_directory, to: "test#render_template_in_top_directory" + get :render_template_in_top_directory_with_slash, to: "test#render_template_in_top_directory_with_slash" + get :render_template_within_a_template_with_other_format, to: "test#render_template_within_a_template_with_other_format" + get :render_text_hello_world, to: "test#render_text_hello_world" + get :render_text_hello_world_with_layout, to: "test#render_text_hello_world_with_layout" + get :render_text_with_assigns, to: "test#render_text_with_assigns" + get :render_text_with_false, to: "test#render_text_with_false" + get :render_text_with_nil, to: "test#render_text_with_nil" + get :render_text_with_resource, to: "test#render_text_with_resource" + get :render_to_string_and_render, to: "test#render_to_string_and_render" + get :render_to_string_and_render_with_different_formats, to: "test#render_to_string_and_render_with_different_formats" + get :render_to_string_test, to: "test#render_to_string_test" + get :render_to_string_with_assigns, to: "test#render_to_string_with_assigns" + get :render_to_string_with_caught_exception, to: "test#render_to_string_with_caught_exception" + get :render_to_string_with_exception, to: "test#render_to_string_with_exception" + get :render_to_string_with_inline_and_render, to: "test#render_to_string_with_inline_and_render" + get :render_to_string_with_partial, to: "test#render_to_string_with_partial" + get :render_to_string_with_template_and_html_partial, to: "test#render_to_string_with_template_and_html_partial" + get :render_using_layout_around_block, to: "test#render_using_layout_around_block" + get :render_using_layout_around_block_in_main_layout_and_within_content_for_layout, to: "test#render_using_layout_around_block_in_main_layout_and_within_content_for_layout" + get :render_with_assigns_option, to: "test#render_with_assigns_option" + get :render_with_explicit_escaped_template, to: "test#render_with_explicit_escaped_template" + get :render_with_explicit_string_template, to: "test#render_with_explicit_string_template" + get :render_with_explicit_template, to: "test#render_with_explicit_template" + get :render_with_explicit_template_with_locals, to: "test#render_with_explicit_template_with_locals" + get :render_with_explicit_unescaped_template, to: "test#render_with_explicit_unescaped_template" + get :render_with_filters, to: "test#render_with_filters" + get :render_xml_hello, to: "test#render_xml_hello" + get :render_xml_hello_as_string_template, to: "test#render_xml_hello_as_string_template" + get :rendering_nothing_on_layout, to: "test#rendering_nothing_on_layout" + get :rendering_with_conflicting_local_vars, to: "test#rendering_with_conflicting_local_vars" + get :rendering_without_layout, to: "test#rendering_without_layout" + get :yield_content_for, to: "test#yield_content_for" + end + def setup # enable a logger so that (e.g.) the benchmarking stuff runs, so we can get # a more accurate simulation of what happens in "real life". diff --git a/actionview/test/actionpack/controller/view_paths_test.rb b/actionview/test/actionpack/controller/view_paths_test.rb index 45c662f0ce..7f3fe0fa08 100644 --- a/actionview/test/actionpack/controller/view_paths_test.rb +++ b/actionview/test/actionpack/controller/view_paths_test.rb @@ -24,11 +24,17 @@ class ViewLoadPathsTest < ActionController::TestCase end end + with_routes do + get :hello_world, to: "test#hello_world" + get :hello_world_at_request_time, to: "test#hello_world_at_request_time" + end + def setup @controller = TestController.new @request = ActionController::TestRequest.create(@controller.class) @response = ActionDispatch::TestResponse.new @paths = TestController.view_paths + super end def teardown @@ -109,6 +115,10 @@ class ViewLoadPathsTest < ActionController::TestCase def test_view_paths_override_for_layouts_in_controllers_with_a_module @controller = Test::SubController.new + with_routes do + get :hello_world, to: "view_load_paths_test/test/sub#hello_world" + end + Test::SubController.view_paths = [ "#{FIXTURE_LOAD_PATH}/override", FIXTURE_LOAD_PATH, "#{FIXTURE_LOAD_PATH}/override2" ] get :hello_world assert_response :success diff --git a/actionview/test/active_record_unit.rb b/actionview/test/active_record_unit.rb index 7f48b515a0..e4ea6a426d 100644 --- a/actionview/test/active_record_unit.rb +++ b/actionview/test/active_record_unit.rb @@ -74,6 +74,18 @@ end class ActiveRecordTestCase < ActionController::TestCase include ActiveRecord::TestFixtures + def self.tests(controller) + super + if defined? controller::ROUTES + include Module.new { + define_method(:setup) do + super() + @routes = controller::ROUTES + end + } + end + end + # Set our fixture path if ActiveRecordTestConnector.able_to_connect self.fixture_path = [FIXTURE_LOAD_PATH] diff --git a/actionview/test/activerecord/controller_runtime_test.rb b/actionview/test/activerecord/controller_runtime_test.rb index 42b171ea07..7cbd3aaf89 100644 --- a/actionview/test/activerecord/controller_runtime_test.rb +++ b/actionview/test/activerecord/controller_runtime_test.rb @@ -39,6 +39,14 @@ class ControllerRuntimeLogSubscriberTest < ActionController::TestCase include ActiveSupport::LogSubscriber::TestHelper tests LogSubscriberController + with_routes do + get :show, to: "#{LogSubscriberController.controller_path}#show" + get :zero, to: "#{LogSubscriberController.controller_path}#zero" + get :db_after_render, to: "#{LogSubscriberController.controller_path}#db_after_render" + get :redirect, to: "#{LogSubscriberController.controller_path}#redirect" + post :create, to: "#{LogSubscriberController.controller_path}#create" + end + def setup @old_logger = ActionController::Base.logger super diff --git a/actionview/test/activerecord/form_helper_activerecord_test.rb b/actionview/test/activerecord/form_helper_activerecord_test.rb index 1472ee8def..22626de6cb 100644 --- a/actionview/test/activerecord/form_helper_activerecord_test.rb +++ b/actionview/test/activerecord/form_helper_activerecord_test.rb @@ -23,9 +23,12 @@ class FormHelperActiveRecordTest < ActionView::TestCase @developer.projects << @project @developer.save + super + @controller.singleton_class.include Routes.url_helpers end def teardown + super Project.delete(321) Developer.delete(123) end diff --git a/actionview/test/activerecord/polymorphic_routes_test.rb b/actionview/test/activerecord/polymorphic_routes_test.rb index 4b931f793f..724129a7d9 100644 --- a/actionview/test/activerecord/polymorphic_routes_test.rb +++ b/actionview/test/activerecord/polymorphic_routes_test.rb @@ -62,10 +62,14 @@ module Weblog end class PolymorphicRoutesTest < ActionController::TestCase - include SharedTestRoutes.url_helpers + Routes = ActionDispatch::Routing::RouteSet.new + Routes.draw { } + include Routes.url_helpers + default_url_options[:host] = "example.com" def setup + super @project = Project.new @task = Task.new @step = Step.new @@ -763,9 +767,11 @@ class DirectRoutesTest < ActionView::TestCase include Routes.url_helpers def setup + super @category = Category.new("1") @collection = Collection.new("2") @product = Product.new("3") + @controller.singleton_class.include Routes.url_helpers end def test_direct_routes diff --git a/actionview/test/activerecord/relation_cache_test.rb b/actionview/test/activerecord/relation_cache_test.rb index 56e17e67a8..a6befc3ee5 100644 --- a/actionview/test/activerecord/relation_cache_test.rb +++ b/actionview/test/activerecord/relation_cache_test.rb @@ -6,6 +6,7 @@ class RelationCacheTest < ActionView::TestCase tests ActionView::Helpers::CacheHelper def setup + super view_paths = ActionController::Base.view_paths lookup_context = ActionView::LookupContext.new(view_paths, {}, ["test"]) @view_renderer = ActionView::Renderer.new(lookup_context) diff --git a/actionview/test/activerecord/render_partial_with_record_identification_test.rb b/actionview/test/activerecord/render_partial_with_record_identification_test.rb index 3a698fa42e..2bb3cfeb5b 100644 --- a/actionview/test/activerecord/render_partial_with_record_identification_test.rb +++ b/actionview/test/activerecord/render_partial_with_record_identification_test.rb @@ -3,6 +3,16 @@ require "active_record_unit" class RenderPartialWithRecordIdentificationController < ActionController::Base + ROUTES = test_routes do + get :render_with_record_collection, to: "render_partial_with_record_identification#render_with_record_collection" + get :render_with_scope, to: "render_partial_with_record_identification#render_with_scope" + get :render_with_record, to: "render_partial_with_record_identification#render_with_record" + get :render_with_has_many_association, to: "render_partial_with_record_identification#render_with_has_many_association" + get :render_with_has_many_and_belongs_to_association, to: "render_partial_with_record_identification#render_with_has_many_and_belongs_to_association" + get :render_with_has_one_association, to: "render_partial_with_record_identification#render_with_has_one_association" + get :render_with_record_collection_and_spacer_template, to: "render_partial_with_record_identification#render_with_record_collection_and_spacer_template" + end + def render_with_has_many_and_belongs_to_association @developer = Developer.find(1) render partial: @developer.projects @@ -89,6 +99,11 @@ end module Fun class NestedController < ActionController::Base + ROUTES = test_routes do + get :render_with_record_in_nested_controller, to: "fun/nested#render_with_record_in_nested_controller" + get :render_with_record_collection_in_nested_controller, to: "fun/nested#render_with_record_collection_in_nested_controller" + end + def render_with_record_in_nested_controller render partial: Game.new("Pong") end @@ -100,6 +115,11 @@ module Fun module Serious class NestedDeeperController < ActionController::Base + ROUTES = test_routes do + get :render_with_record_in_deeper_nested_controller, to: "fun/serious/nested_deeper#render_with_record_in_deeper_nested_controller" + get :render_with_record_collection_in_deeper_nested_controller, to: "fun/serious/nested_deeper#render_with_record_collection_in_deeper_nested_controller" + end + def render_with_record_in_deeper_nested_controller render partial: Game.new("Chess") end diff --git a/actionview/test/template/erb/form_for_test.rb b/actionview/test/template/erb/form_for_test.rb index b6ecf003a5..b3a47e17a4 100644 --- a/actionview/test/template/erb/form_for_test.rb +++ b/actionview/test/template/erb/form_for_test.rb @@ -6,7 +6,11 @@ require "template/erb/helper" module ERBTest class TagHelperTest < BlockTestCase test "form_for works" do - output = render_content "form_for(:staticpage, :url => {:controller => 'blah', :action => 'update'})", "" + routes = ActionDispatch::Routing::RouteSet.new + routes.draw do + get "/blah/update", to: "blah#update" + end + output = render_content "form_for(:staticpage, :url => {:controller => 'blah', :action => 'update'})", "", routes assert_match %r{.*}, output end end diff --git a/actionview/test/template/erb/helper.rb b/actionview/test/template/erb/helper.rb index 57d6cb1be3..727cc3dcf2 100644 --- a/actionview/test/template/erb/helper.rb +++ b/actionview/test/template/erb/helper.rb @@ -3,7 +3,6 @@ module ERBTest class ViewContext include ActionView::Helpers::UrlHelper - include SharedTestRoutes.url_helpers include ActionView::Helpers::TagHelper include ActionView::Helpers::JavaScriptHelper include ActionView::Helpers::FormHelper @@ -14,9 +13,15 @@ module ERBTest end class BlockTestCase < ActiveSupport::TestCase - def render_content(start, inside) + def render_content(start, inside, routes = nil) + routes ||= ActionDispatch::Routing::RouteSet.new.tap do |rs| + rs.draw { } + end + context = Class.new(ViewContext) { + include routes.url_helpers + }.new template = block_helper(start, inside) - ActionView::Template::Handlers::ERB.erb_implementation.new(template).evaluate(ViewContext.new) + ActionView::Template::Handlers::ERB.erb_implementation.new(template).evaluate(context) end def block_helper(str, rest) diff --git a/actionview/test/template/form_helper/form_with_test.rb b/actionview/test/template/form_helper/form_with_test.rb index c30176349c..c807f81052 100644 --- a/actionview/test/template/form_helper/form_with_test.rb +++ b/actionview/test/template/form_helper/form_with_test.rb @@ -290,6 +290,7 @@ class FormWithActsLikeFormForTest < FormWithTest @post_delegator.title = "Hello World" @car = Car.new("#000FFF") + @controller.singleton_class.include Routes.url_helpers end Routes = ActionDispatch::Routing::RouteSet.new @@ -308,10 +309,6 @@ class FormWithActsLikeFormForTest < FormWithTest root to: "main#index" end - def _routes - Routes - end - include Routes.url_helpers def url_for(object) diff --git a/actionview/test/template/form_helper_test.rb b/actionview/test/template/form_helper_test.rb index 38bb1e1d24..09da067495 100644 --- a/actionview/test/template/form_helper_test.rb +++ b/actionview/test/template/form_helper_test.rb @@ -140,6 +140,7 @@ class FormHelperTest < ActionView::TestCase @post_delegator.title = "Hello World" @car = Car.new("#000FFF") + @controller.singleton_class.include Routes.url_helpers end Routes = ActionDispatch::Routing::RouteSet.new diff --git a/actionview/test/template/test_case_test.rb b/actionview/test/template/test_case_test.rb index d98fd4f9a2..27f5a7cc3e 100644 --- a/actionview/test/template/test_case_test.rb +++ b/actionview/test/template/test_case_test.rb @@ -217,8 +217,14 @@ module ActionView test "is able to use routes" do controller.request.assign_parameters(@routes, "foo", "index", {}, "/foo", []) - assert_equal "/foo", url_for - assert_equal "/bar", url_for(controller: "bar") + with_routing do |set| + set.draw { + get :foo, to: "foo#index" + get :bar, to: "bar#index" + } + assert_equal "/foo", url_for + assert_equal "/bar", url_for(controller: "bar") + end end test "is able to use named routes" do @@ -244,6 +250,8 @@ module ActionView set.draw { mount app => "/foo", :as => "foo_app" } + singleton_class.include set.mounted_helpers + assert_equal "/foo/bar", foo_app.bar_path end end diff --git a/actionview/test/template/url_helper_test.rb b/actionview/test/template/url_helper_test.rb index 9d91dbb72b..dd52b8b6a3 100644 --- a/actionview/test/template/url_helper_test.rb +++ b/actionview/test/template/url_helper_test.rb @@ -704,7 +704,7 @@ end class UrlHelperControllerTest < ActionController::TestCase class UrlHelperController < ActionController::Base - test_routes do + ROUTES = test_routes do get "url_helper_controller_test/url_helper/show/:id", to: "url_helper_controller_test/url_helper#show", as: :show @@ -768,6 +768,11 @@ class UrlHelperControllerTest < ActionController::TestCase helper_method :override_url_helper_path end + def setup + super + @routes = UrlHelperController::ROUTES + end + tests UrlHelperController def test_url_for_shows_only_path @@ -828,7 +833,7 @@ class UrlHelperControllerTest < ActionController::TestCase end class TasksController < ActionController::Base - test_routes do + ROUTES = test_routes do resources :tasks end @@ -850,6 +855,11 @@ end class LinkToUnlessCurrentWithControllerTest < ActionController::TestCase tests TasksController + def setup + super + @routes = TasksController::ROUTES + end + def test_link_to_unless_current_to_current get :index assert_equal "tasks\ntasks", @response.body @@ -882,7 +892,7 @@ class Session end class WorkshopsController < ActionController::Base - test_routes do + ROUTES = test_routes do resources :workshops do resources :sessions end @@ -905,7 +915,7 @@ class WorkshopsController < ActionController::Base end class SessionsController < ActionController::Base - test_routes do + ROUTES = test_routes do resources :workshops do resources :sessions end @@ -932,6 +942,11 @@ class SessionsController < ActionController::Base end class PolymorphicControllerTest < ActionController::TestCase + def setup + super + @routes = WorkshopsController::ROUTES + end + def test_new_resource @controller = WorkshopsController.new @@ -946,6 +961,20 @@ class PolymorphicControllerTest < ActionController::TestCase assert_equal %{/workshops/1\nWorkshop}, @response.body end + def test_current_page_when_options_does_not_respond_to_to_hash + @controller = WorkshopsController.new + + get :edit, params: { id: 1 } + assert_equal "false", @response.body + end +end + +class PolymorphicSessionsControllerTest < ActionController::TestCase + def setup + super + @routes = SessionsController::ROUTES + end + def test_new_nested_resource @controller = SessionsController.new @@ -966,11 +995,4 @@ class PolymorphicControllerTest < ActionController::TestCase get :edit, params: { workshop_id: 1, id: 1, format: "json" } assert_equal %{/workshops/1/sessions/1.json\nSession}, @response.body end - - def test_current_page_when_options_does_not_respond_to_to_hash - @controller = WorkshopsController.new - - get :edit, params: { id: 1 } - assert_equal "false", @response.body - end end -- cgit v1.2.3 From 3301804ff6abcd5aae06cc5acbb82bc6a472f008 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 24 Sep 2018 16:01:34 -0700 Subject: make bot happy --- actionview/test/abstract_unit.rb | 2 +- actionview/test/actionpack/controller/layout_test.rb | 12 ++++++------ actionview/test/activerecord/polymorphic_routes_test.rb | 2 +- actionview/test/template/erb/helper.rb | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'actionview') diff --git a/actionview/test/abstract_unit.rb b/actionview/test/abstract_unit.rb index f842e2c76d..1d0edc0c1d 100644 --- a/actionview/test/abstract_unit.rb +++ b/actionview/test/abstract_unit.rb @@ -97,7 +97,7 @@ end class ActionDispatch::IntegrationTest < ActiveSupport::TestCase def self.build_app(routes = nil) routes ||= ActionDispatch::Routing::RouteSet.new.tap { |rs| - rs.draw { } + rs.draw {} } RoutedRackApp.new(routes) do |middleware| middleware.use ActionDispatch::ShowExceptions, ActionDispatch::PublicExceptions.new("#{FIXTURE_LOAD_PATH}/public") diff --git a/actionview/test/actionpack/controller/layout_test.rb b/actionview/test/actionpack/controller/layout_test.rb index 14acb737f9..6d5c97b7fd 100644 --- a/actionview/test/actionpack/controller/layout_test.rb +++ b/actionview/test/actionpack/controller/layout_test.rb @@ -49,7 +49,7 @@ class LayoutAutoDiscoveryTest < ActionController::TestCase include TemplateHandlerHelper with_routes do - get :hello, to: 'views#hello' + get :hello, to: "views#hello" end def setup @@ -153,8 +153,8 @@ class LayoutSetInResponseTest < ActionController::TestCase include TemplateHandlerHelper with_routes do - get :hello, to: 'views#hello' - get :hello, to: 'views#goodbye' + get :hello, to: "views#hello" + get :hello, to: "views#goodbye" end def test_layout_set_when_using_default_layout @@ -244,7 +244,7 @@ end class LayoutExceptionRaisedTest < ActionController::TestCase with_routes do - get :hello, to: 'views#hello' + get :hello, to: "views#hello" end def test_exception_raised_when_layout_file_not_found @@ -261,7 +261,7 @@ end class LayoutStatusIsRenderedTest < ActionController::TestCase with_routes do - get :hello, to: 'views#hello' + get :hello, to: "views#hello" end def test_layout_status_is_rendered @@ -278,7 +278,7 @@ unless Gem.win_platform? class LayoutSymlinkedIsRenderedTest < ActionController::TestCase with_routes do - get :hello, to: 'views#hello' + get :hello, to: "views#hello" end def test_symlinked_layout_is_rendered diff --git a/actionview/test/activerecord/polymorphic_routes_test.rb b/actionview/test/activerecord/polymorphic_routes_test.rb index 724129a7d9..25e05f6222 100644 --- a/actionview/test/activerecord/polymorphic_routes_test.rb +++ b/actionview/test/activerecord/polymorphic_routes_test.rb @@ -63,7 +63,7 @@ end class PolymorphicRoutesTest < ActionController::TestCase Routes = ActionDispatch::Routing::RouteSet.new - Routes.draw { } + Routes.draw {} include Routes.url_helpers default_url_options[:host] = "example.com" diff --git a/actionview/test/template/erb/helper.rb b/actionview/test/template/erb/helper.rb index 727cc3dcf2..2d31b19be8 100644 --- a/actionview/test/template/erb/helper.rb +++ b/actionview/test/template/erb/helper.rb @@ -15,7 +15,7 @@ module ERBTest class BlockTestCase < ActiveSupport::TestCase def render_content(start, inside, routes = nil) routes ||= ActionDispatch::Routing::RouteSet.new.tap do |rs| - rs.draw { } + rs.draw {} end context = Class.new(ViewContext) { include routes.url_helpers -- cgit v1.2.3 From 6f36168ecaa3fd68bfc8b5ead76e32aa8dc51252 Mon Sep 17 00:00:00 2001 From: Juanito Fatas Date: Tue, 25 Sep 2018 15:15:35 +0900 Subject: Fix a content_for test description --- actionview/test/template/capture_helper_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionview') diff --git a/actionview/test/template/capture_helper_test.rb b/actionview/test/template/capture_helper_test.rb index 131e49327e..5c01b78ebb 100644 --- a/actionview/test/template/capture_helper_test.rb +++ b/actionview/test/template/capture_helper_test.rb @@ -40,7 +40,7 @@ class CaptureHelperTest < ActionView::TestCase assert_equal "<em>bar</em>", string end - def test_capture_used_for_read + def test_content_for_used_for_read content_for :foo, "foo" assert_equal "foo", content_for(:foo) -- cgit v1.2.3 From f679933daa257a23095a6d7ad04aa2cbd3c7907e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Tue, 25 Sep 2018 13:18:20 -0400 Subject: Change the empty block style to have space inside of the block --- actionview/test/activerecord/debug_helper_test.rb | 2 +- actionview/test/template/capture_helper_test.rb | 2 +- actionview/test/template/form_helper/form_with_test.rb | 16 ++++++++-------- actionview/test/template/form_helper_test.rb | 14 +++++++------- actionview/test/template/form_options_helper_test.rb | 2 +- actionview/test/template/test_case_test.rb | 2 +- 6 files changed, 19 insertions(+), 19 deletions(-) (limited to 'actionview') diff --git a/actionview/test/activerecord/debug_helper_test.rb b/actionview/test/activerecord/debug_helper_test.rb index 4be1023733..87a1791573 100644 --- a/actionview/test/activerecord/debug_helper_test.rb +++ b/actionview/test/activerecord/debug_helper_test.rb @@ -13,7 +13,7 @@ class DebugHelperTest < ActionView::TestCase end def test_debug_with_marshal_error - obj = -> {} + obj = -> { } assert_match obj.inspect, Nokogiri.XML(debug(obj)).content end end diff --git a/actionview/test/template/capture_helper_test.rb b/actionview/test/template/capture_helper_test.rb index 131e49327e..3d96c81be9 100644 --- a/actionview/test/template/capture_helper_test.rb +++ b/actionview/test/template/capture_helper_test.rb @@ -219,7 +219,7 @@ class CaptureHelperTest < ActionView::TestCase def test_with_output_buffer_does_not_assume_there_is_an_output_buffer assert_nil @av.output_buffer - assert_equal "", @av.with_output_buffer {} + assert_equal "", @av.with_output_buffer { } end def alt_encoding(output_buffer) diff --git a/actionview/test/template/form_helper/form_with_test.rb b/actionview/test/template/form_helper/form_with_test.rb index f38833f256..f84c9b2b73 100644 --- a/actionview/test/template/form_helper/form_with_test.rb +++ b/actionview/test/template/form_helper/form_with_test.rb @@ -2246,7 +2246,7 @@ class FormWithActsLikeFormForTest < FormWithTest post.persisted = false def post.to_key; nil; end - form_with(model: post) {} + form_with(model: post) { } expected = whole_form("/posts") assert_dom_equal expected, output_buffer @@ -2254,14 +2254,14 @@ class FormWithActsLikeFormForTest < FormWithTest def test_form_with_with_existing_object_in_list @comment.save - form_with(model: [@post, @comment]) {} + form_with(model: [@post, @comment]) { } expected = whole_form(post_comment_path(@post, @comment), method: "patch") assert_dom_equal expected, output_buffer end def test_form_with_with_new_object_in_list - form_with(model: [@post, @comment]) {} + form_with(model: [@post, @comment]) { } expected = whole_form(post_comments_path(@post)) assert_dom_equal expected, output_buffer @@ -2269,14 +2269,14 @@ class FormWithActsLikeFormForTest < FormWithTest def test_form_with_with_existing_object_and_namespace_in_list @comment.save - form_with(model: [:admin, @post, @comment]) {} + form_with(model: [:admin, @post, @comment]) { } expected = whole_form(admin_post_comment_path(@post, @comment), method: "patch") assert_dom_equal expected, output_buffer end def test_form_with_with_new_object_and_namespace_in_list - form_with(model: [:admin, @post, @comment]) {} + form_with(model: [:admin, @post, @comment]) { } expected = whole_form(admin_post_comments_path(@post)) assert_dom_equal expected, output_buffer @@ -2290,13 +2290,13 @@ class FormWithActsLikeFormForTest < FormWithTest end def test_form_with_with_default_method_as_patch - form_with(model: @post) {} + form_with(model: @post) { } expected = whole_form("/posts/123", method: "patch") assert_dom_equal expected, output_buffer end def test_form_with_with_data_attributes - form_with(model: @post, data: { behavior: "stuff" }) {} + form_with(model: @post, data: { behavior: "stuff" }) { } assert_match %r|data-behavior="stuff"|, output_buffer assert_match %r|data-remote="true"|, output_buffer end @@ -2315,7 +2315,7 @@ class FormWithActsLikeFormForTest < FormWithTest end end - form_with(model: @post, builder: builder_class) {} + form_with(model: @post, builder: builder_class) { } assert_equal 1, initialization_count, "form builder instantiated more than once" end diff --git a/actionview/test/template/form_helper_test.rb b/actionview/test/template/form_helper_test.rb index 601fa6e8eb..5972946074 100644 --- a/actionview/test/template/form_helper_test.rb +++ b/actionview/test/template/form_helper_test.rb @@ -3488,14 +3488,14 @@ class FormHelperTest < ActionView::TestCase def test_form_for_with_existing_object_in_list @comment.save - form_for([@post, @comment]) {} + form_for([@post, @comment]) { } expected = whole_form(post_comment_path(@post, @comment), "edit_comment_1", "edit_comment", method: "patch") assert_dom_equal expected, output_buffer end def test_form_for_with_new_object_in_list - form_for([@post, @comment]) {} + form_for([@post, @comment]) { } expected = whole_form(post_comments_path(@post), "new_comment", "new_comment") assert_dom_equal expected, output_buffer @@ -3503,14 +3503,14 @@ class FormHelperTest < ActionView::TestCase def test_form_for_with_existing_object_and_namespace_in_list @comment.save - form_for([:admin, @post, @comment]) {} + form_for([:admin, @post, @comment]) { } expected = whole_form(admin_post_comment_path(@post, @comment), "edit_comment_1", "edit_comment", method: "patch") assert_dom_equal expected, output_buffer end def test_form_for_with_new_object_and_namespace_in_list - form_for([:admin, @post, @comment]) {} + form_for([:admin, @post, @comment]) { } expected = whole_form(admin_post_comments_path(@post), "new_comment", "new_comment") assert_dom_equal expected, output_buffer @@ -3524,13 +3524,13 @@ class FormHelperTest < ActionView::TestCase end def test_form_for_with_default_method_as_patch - form_for(@post) {} + form_for(@post) { } expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") assert_dom_equal expected, output_buffer end def test_form_for_with_data_attributes - form_for(@post, data: { behavior: "stuff" }, remote: true) {} + form_for(@post, data: { behavior: "stuff" }, remote: true) { } assert_match %r|data-behavior="stuff"|, output_buffer assert_match %r|data-remote="true"|, output_buffer end @@ -3549,7 +3549,7 @@ class FormHelperTest < ActionView::TestCase end end - form_for(@post, builder: builder_class) {} + form_for(@post, builder: builder_class) { } assert_equal 1, initialization_count, "form builder instantiated more than once" end diff --git a/actionview/test/template/form_options_helper_test.rb b/actionview/test/template/form_options_helper_test.rb index 8a0a706fef..a2d1474a94 100644 --- a/actionview/test/template/form_options_helper_test.rb +++ b/actionview/test/template/form_options_helper_test.rb @@ -668,7 +668,7 @@ class FormOptionsHelperTest < ActionView::TestCase @post = Post.new output_buffer = fields_for :post, @post do |f| - concat(f.select(:category) {}) + concat(f.select(:category) { }) end assert_dom_equal( diff --git a/actionview/test/template/test_case_test.rb b/actionview/test/template/test_case_test.rb index 27f5a7cc3e..976b6bc77e 100644 --- a/actionview/test/template/test_case_test.rb +++ b/actionview/test/template/test_case_test.rb @@ -242,7 +242,7 @@ module ActionView @routes ||= ActionDispatch::Routing::RouteSet.new end - routes.draw { get "bar", to: lambda {} } + routes.draw { get "bar", to: lambda { } } def self.call(*) end -- cgit v1.2.3 From 49f9dff9b6ba1451d8c85927d5f75327bd2322d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Tue, 25 Sep 2018 13:21:40 -0400 Subject: Fix more offences --- actionview/test/abstract_unit.rb | 2 +- actionview/test/activerecord/polymorphic_routes_test.rb | 2 +- actionview/test/template/erb/helper.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'actionview') diff --git a/actionview/test/abstract_unit.rb b/actionview/test/abstract_unit.rb index 6dbebb3c02..f90626ad9e 100644 --- a/actionview/test/abstract_unit.rb +++ b/actionview/test/abstract_unit.rb @@ -97,7 +97,7 @@ end class ActionDispatch::IntegrationTest < ActiveSupport::TestCase def self.build_app(routes = nil) routes ||= ActionDispatch::Routing::RouteSet.new.tap { |rs| - rs.draw {} + rs.draw { } } RoutedRackApp.new(routes) do |middleware| middleware.use ActionDispatch::ShowExceptions, ActionDispatch::PublicExceptions.new("#{FIXTURE_LOAD_PATH}/public") diff --git a/actionview/test/activerecord/polymorphic_routes_test.rb b/actionview/test/activerecord/polymorphic_routes_test.rb index 25e05f6222..724129a7d9 100644 --- a/actionview/test/activerecord/polymorphic_routes_test.rb +++ b/actionview/test/activerecord/polymorphic_routes_test.rb @@ -63,7 +63,7 @@ end class PolymorphicRoutesTest < ActionController::TestCase Routes = ActionDispatch::Routing::RouteSet.new - Routes.draw {} + Routes.draw { } include Routes.url_helpers default_url_options[:host] = "example.com" diff --git a/actionview/test/template/erb/helper.rb b/actionview/test/template/erb/helper.rb index 2d31b19be8..727cc3dcf2 100644 --- a/actionview/test/template/erb/helper.rb +++ b/actionview/test/template/erb/helper.rb @@ -15,7 +15,7 @@ module ERBTest class BlockTestCase < ActiveSupport::TestCase def render_content(start, inside, routes = nil) routes ||= ActionDispatch::Routing::RouteSet.new.tap do |rs| - rs.draw {} + rs.draw { } end context = Class.new(ViewContext) { include routes.url_helpers -- cgit v1.2.3 From 8e07711d65a10be697020cc775e966bc2df87b7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrik=20B=C3=B3na?= Date: Thu, 14 Dec 2017 10:14:24 +0100 Subject: Do not enable disabled elements for XHR redirects Fixes #29473. --- .../javascripts/rails-ujs/features/disable.coffee | 11 ++++++++++- actionview/test/ujs/public/test/data-disable.js | 17 +++++++++++++++++ actionview/test/ujs/public/test/settings.js | 4 ++++ actionview/test/ujs/server.rb | 7 ++++++- 4 files changed, 37 insertions(+), 2 deletions(-) (limited to 'actionview') diff --git a/actionview/app/assets/javascripts/rails-ujs/features/disable.coffee b/actionview/app/assets/javascripts/rails-ujs/features/disable.coffee index 90aa3bdf0e..a8c692ee62 100644 --- a/actionview/app/assets/javascripts/rails-ujs/features/disable.coffee +++ b/actionview/app/assets/javascripts/rails-ujs/features/disable.coffee @@ -8,7 +8,12 @@ Rails.handleDisabledElement = (e) -> # Unified function to enable an element (link, button and form) Rails.enableElement = (e) -> - element = if e instanceof Event then e.target else e + if e instanceof Event + return if isXhrRedirect(e) + element = e.target + else + element = e + if matches(element, Rails.linkDisableSelector) enableLinkElement(element) else if matches(element, Rails.buttonDisableSelector) or matches(element, Rails.formEnableSelector) @@ -80,3 +85,7 @@ enableFormElement = (element) -> setData(element, 'ujs:enable-with', null) # clean up cache element.disabled = false setData(element, 'ujs:disabled', null) + +isXhrRedirect = (event) -> + xhr = event.detail?[0] + xhr?.getResponseHeader("X-Xhr-Redirect")? diff --git a/actionview/test/ujs/public/test/data-disable.js b/actionview/test/ujs/public/test/data-disable.js index e9919764b6..88dc801b2f 100644 --- a/actionview/test/ujs/public/test/data-disable.js +++ b/actionview/test/ujs/public/test/data-disable.js @@ -320,3 +320,20 @@ asyncTest('button[data-remote][data-disable] re-enables when `ajax:error` event start() }, 30) }) + +asyncTest('do not enable elements for XHR redirects', 6, function() { + var link = $('a[data-disable]').attr('data-remote', true).attr('href', '/echo?with_xhr_redirect=true') + + App.checkEnabledState(link, 'Click me') + + link + .bindNative('ajax:send', function() { + App.checkDisabledState(link, 'Click me') + }) + .triggerNative('click') + + setTimeout(function() { + App.checkDisabledState(link, 'Click me') + start() + }, 30) +}) diff --git a/actionview/test/ujs/public/test/settings.js b/actionview/test/ujs/public/test/settings.js index b1ce3b8c64..05677f2595 100644 --- a/actionview/test/ujs/public/test/settings.js +++ b/actionview/test/ujs/public/test/settings.js @@ -1,4 +1,5 @@ var App = App || {} +var Turbolinks = Turbolinks || {} App.assertCallbackInvoked = function(callbackName) { ok(true, callbackName + ' callback should have been invoked') @@ -116,3 +117,6 @@ $.fn.extend({ return this } }) + +Turbolinks.clearCache = function() {} +Turbolinks.visit = function() {} diff --git a/actionview/test/ujs/server.rb b/actionview/test/ujs/server.rb index 48e9bcb65f..56f436c8b8 100644 --- a/actionview/test/ujs/server.rb +++ b/actionview/test/ujs/server.rb @@ -64,7 +64,12 @@ class TestsController < ActionController::Base if params[:content_type] && params[:content] render inline: params[:content], content_type: params[:content_type] elsif request.xhr? - render json: JSON.generate(data) + if params[:with_xhr_redirect] + response.set_header("X-Xhr-Redirect", "http://example.com/") + render inline: %{Turbolinks.clearCache()\nTurbolinks.visit("http://example.com/", {"action":"replace"})} + else + render json: JSON.generate(data) + end elsif params[:iframe] payload = JSON.generate(data).gsub("<", "<").gsub(">", ">") html = <<-HTML -- cgit v1.2.3 From aa3dcabd874a3e82e455e85a1c94a7abaac2900a Mon Sep 17 00:00:00 2001 From: Yasuo Honda Date: Wed, 28 Feb 2018 04:33:37 +0000 Subject: Add `Style/RedundantFreeze` to remove redudant `.freeze` Since Rails 6.0 will support Ruby 2.4.1 or higher `# frozen_string_literal: true` magic comment is enough to make string object frozen. This magic comment is enabled by `Style/FrozenStringLiteralComment` cop. * Exclude these files not to auto correct false positive `Regexp#freeze` - 'actionpack/lib/action_dispatch/journey/router/utils.rb' - 'activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb' It has been fixed by https://github.com/rubocop-hq/rubocop/pull/6333 Once the newer version of RuboCop released and available at Code Climate these exclude entries should be removed. * Replace `String#freeze` with `String#-@` manually if explicit frozen string objects are required - 'actionpack/test/controller/test_case_test.rb' - 'activemodel/test/cases/type/string_test.rb' - 'activesupport/lib/active_support/core_ext/string/strip.rb' - 'activesupport/test/core_ext/string_ext_test.rb' - 'railties/test/generators/actions_test.rb' --- .../lib/action_view/helpers/asset_tag_helper.rb | 4 ++-- .../lib/action_view/helpers/asset_url_helper.rb | 2 +- actionview/lib/action_view/helpers/date_helper.rb | 16 ++++++++-------- .../lib/action_view/helpers/form_options_helper.rb | 8 ++++---- .../lib/action_view/helpers/form_tag_helper.rb | 8 ++++---- .../lib/action_view/helpers/javascript_helper.rb | 2 +- actionview/lib/action_view/helpers/tag_helper.rb | 4 ++-- actionview/lib/action_view/helpers/url_helper.rb | 22 +++++++++++----------- actionview/lib/action_view/lookup_context.rb | 6 +++--- actionview/lib/action_view/record_identifier.rb | 4 ++-- .../lib/action_view/renderer/partial_renderer.rb | 2 +- actionview/lib/action_view/template.rb | 8 ++++---- actionview/lib/action_view/template/resolver.rb | 4 ++-- actionview/test/template/text_helper_test.rb | 4 ++-- 14 files changed, 47 insertions(+), 47 deletions(-) (limited to 'actionview') diff --git a/actionview/lib/action_view/helpers/asset_tag_helper.rb b/actionview/lib/action_view/helpers/asset_tag_helper.rb index cbcce4a4dc..3d7c8dae75 100644 --- a/actionview/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionview/lib/action_view/helpers/asset_tag_helper.rb @@ -98,7 +98,7 @@ module ActionView if tag_options["nonce"] == true tag_options["nonce"] = content_security_policy_nonce end - content_tag("script".freeze, "", tag_options) + content_tag("script", "", tag_options) }.join("\n").html_safe request.send_early_hints("Link" => early_hints_links.join("\n")) if respond_to?(:request) && request @@ -375,7 +375,7 @@ module ActionView def image_alt(src) ActiveSupport::Deprecation.warn("image_alt is deprecated and will be removed from Rails 6.0. You must explicitly set alt text on images.") - File.basename(src, ".*".freeze).sub(/-[[:xdigit:]]{32,64}\z/, "".freeze).tr("-_".freeze, " ".freeze).capitalize + File.basename(src, ".*").sub(/-[[:xdigit:]]{32,64}\z/, "").tr("-_", " ").capitalize end # Returns an HTML video tag for the +sources+. If +sources+ is a string, diff --git a/actionview/lib/action_view/helpers/asset_url_helper.rb b/actionview/lib/action_view/helpers/asset_url_helper.rb index 1808765666..cc62783d60 100644 --- a/actionview/lib/action_view/helpers/asset_url_helper.rb +++ b/actionview/lib/action_view/helpers/asset_url_helper.rb @@ -188,7 +188,7 @@ module ActionView return "" if source.blank? return source if URI_REGEXP.match?(source) - tail, source = source[/([\?#].+)$/], source.sub(/([\?#].+)$/, "".freeze) + tail, source = source[/([\?#].+)$/], source.sub(/([\?#].+)$/, "") if extname = compute_asset_extname(source, options) source = "#{source}#{extname}" diff --git a/actionview/lib/action_view/helpers/date_helper.rb b/actionview/lib/action_view/helpers/date_helper.rb index ecdad14f90..9d5e5eaba3 100644 --- a/actionview/lib/action_view/helpers/date_helper.rb +++ b/actionview/lib/action_view/helpers/date_helper.rb @@ -684,7 +684,7 @@ module ActionView format = options.delete(:format) || :long content = args.first || I18n.l(date_or_time, format: format) - content_tag("time".freeze, content, options.reverse_merge(datetime: date_or_time.iso8601), &block) + content_tag("time", content, options.reverse_merge(datetime: date_or_time.iso8601), &block) end private @@ -703,7 +703,7 @@ module ActionView class DateTimeSelector #:nodoc: include ActionView::Helpers::TagHelper - DEFAULT_PREFIX = "date".freeze + DEFAULT_PREFIX = "date" POSITION = { year: 1, month: 2, day: 3, hour: 4, minute: 5, second: 6 }.freeze @@ -824,7 +824,7 @@ module ActionView 1.upto(12) do |month_number| options = { value: month_number } options[:selected] = "selected" if month == month_number - month_options << content_tag("option".freeze, month_name(month_number), options) + "\n" + month_options << content_tag("option", month_name(month_number), options) + "\n" end build_select(:month, month_options.join) end @@ -1006,7 +1006,7 @@ module ActionView tag_options[:selected] = "selected" if selected == i text = options[:use_two_digit_numbers] ? sprintf("%02d", i) : value text = options[:ampm] ? AMPM_TRANSLATION[i] : text - select_options << content_tag("option".freeze, text, tag_options) + select_options << content_tag("option", text, tag_options) end (select_options.join("\n") + "\n").html_safe @@ -1034,7 +1034,7 @@ module ActionView tag_options = { value: value } tag_options[:selected] = "selected" if selected == value text = year_name(value) - select_options << content_tag("option".freeze, text, tag_options) + select_options << content_tag("option", text, tag_options) end (select_options.join("\n") + "\n").html_safe @@ -1054,11 +1054,11 @@ module ActionView select_options[:class] = css_class_attribute(type, select_options[:class], @options[:with_css_classes]) if @options[:with_css_classes] select_html = +"\n" - select_html << content_tag("option".freeze, "", value: "") + "\n" if @options[:include_blank] + select_html << content_tag("option", "", value: "") + "\n" if @options[:include_blank] select_html << prompt_option_tag(type, @options[:prompt]) + "\n" if @options[:prompt] select_html << select_options_as_html - (content_tag("select".freeze, select_html.html_safe, select_options) + "\n").html_safe + (content_tag("select", select_html.html_safe, select_options) + "\n").html_safe end # Builds the css class value for the select element @@ -1091,7 +1091,7 @@ module ActionView I18n.translate(:"datetime.prompts.#{type}", locale: @options[:locale]) end - prompt ? content_tag("option".freeze, prompt, value: "") : "" + prompt ? content_tag("option", prompt, value: "") : "" end # Builds hidden input tag for date part and value. diff --git a/actionview/lib/action_view/helpers/form_options_helper.rb b/actionview/lib/action_view/helpers/form_options_helper.rb index 2b9d55a019..ebdd96f570 100644 --- a/actionview/lib/action_view/helpers/form_options_helper.rb +++ b/actionview/lib/action_view/helpers/form_options_helper.rb @@ -463,7 +463,7 @@ module ActionView option_tags = options_from_collection_for_select( value_for_collection(group, group_method), option_key_method, option_value_method, selected_key) - content_tag("optgroup".freeze, option_tags, label: value_for_collection(group, group_label_method)) + content_tag("optgroup", option_tags, label: value_for_collection(group, group_label_method)) end.join.html_safe end @@ -535,7 +535,7 @@ module ActionView body = "".html_safe if prompt - body.safe_concat content_tag("option".freeze, prompt_text(prompt), value: "") + body.safe_concat content_tag("option", prompt_text(prompt), value: "") end grouped_options.each do |container| @@ -548,7 +548,7 @@ module ActionView end html_attributes = { label: label }.merge!(html_attributes) - body.safe_concat content_tag("optgroup".freeze, options_for_select(container, selected_key), html_attributes) + body.safe_concat content_tag("optgroup", options_for_select(container, selected_key), html_attributes) end body @@ -584,7 +584,7 @@ module ActionView end zone_options.safe_concat options_for_select(convert_zones[priority_zones], selected) - zone_options.safe_concat content_tag("option".freeze, "-------------", value: "", disabled: true) + zone_options.safe_concat content_tag("option", "-------------", value: "", disabled: true) zone_options.safe_concat "\n" zones = zones - priority_zones diff --git a/actionview/lib/action_view/helpers/form_tag_helper.rb b/actionview/lib/action_view/helpers/form_tag_helper.rb index ba09738beb..c0996049f0 100644 --- a/actionview/lib/action_view/helpers/form_tag_helper.rb +++ b/actionview/lib/action_view/helpers/form_tag_helper.rb @@ -146,15 +146,15 @@ module ActionView end if include_blank - option_tags = content_tag("option".freeze, include_blank, options_for_blank_options_tag).safe_concat(option_tags) + option_tags = content_tag("option", include_blank, options_for_blank_options_tag).safe_concat(option_tags) end end if prompt = options.delete(:prompt) - option_tags = content_tag("option".freeze, prompt, value: "").safe_concat(option_tags) + option_tags = content_tag("option", prompt, value: "").safe_concat(option_tags) end - content_tag "select".freeze, option_tags, { "name" => html_name, "id" => sanitize_to_id(name) }.update(options.stringify_keys) + content_tag "select", option_tags, { "name" => html_name, "id" => sanitize_to_id(name) }.update(options.stringify_keys) end # Creates a standard text field; use these text fields to input smaller chunks of text like a username @@ -577,7 +577,7 @@ module ActionView # # =>

def field_set_tag(legend = nil, options = nil, &block) output = tag(:fieldset, options, true) - output.safe_concat(content_tag("legend".freeze, legend)) unless legend.blank? + output.safe_concat(content_tag("legend", legend)) unless legend.blank? output.concat(capture(&block)) if block_given? output.safe_concat("") end diff --git a/actionview/lib/action_view/helpers/javascript_helper.rb b/actionview/lib/action_view/helpers/javascript_helper.rb index ac6ec5a86c..b680cb1bd3 100644 --- a/actionview/lib/action_view/helpers/javascript_helper.rb +++ b/actionview/lib/action_view/helpers/javascript_helper.rb @@ -84,7 +84,7 @@ module ActionView html_options[:nonce] = content_security_policy_nonce end - content_tag("script".freeze, javascript_cdata_section(content), html_options) + content_tag("script", javascript_cdata_section(content), html_options) end def javascript_cdata_section(content) #:nodoc: diff --git a/actionview/lib/action_view/helpers/tag_helper.rb b/actionview/lib/action_view/helpers/tag_helper.rb index a93d7faa32..3979721d34 100644 --- a/actionview/lib/action_view/helpers/tag_helper.rb +++ b/actionview/lib/action_view/helpers/tag_helper.rb @@ -86,11 +86,11 @@ module ActionView def tag_option(key, value, escape) if value.is_a?(Array) - value = escape ? safe_join(value, " ".freeze) : value.join(" ".freeze) + value = escape ? safe_join(value, " ") : value.join(" ") else value = escape ? ERB::Util.unwrapped_html_escape(value) : value.to_s.dup end - value.gsub!('"'.freeze, """.freeze) + value.gsub!('"', """) %(#{key}="#{value}") end diff --git a/actionview/lib/action_view/helpers/url_helper.rb b/actionview/lib/action_view/helpers/url_helper.rb index 52bffaab84..948dd1551f 100644 --- a/actionview/lib/action_view/helpers/url_helper.rb +++ b/actionview/lib/action_view/helpers/url_helper.rb @@ -200,9 +200,9 @@ module ActionView html_options = convert_options_to_data_attributes(options, html_options) url = url_for(options) - html_options["href".freeze] ||= url + html_options["href"] ||= url - content_tag("a".freeze, name || url, html_options, &block) + content_tag("a", name || url, html_options, &block) end # Generates a form containing a single button that submits to the URL created @@ -308,7 +308,7 @@ module ActionView params = html_options.delete("params") method = html_options.delete("method").to_s - method_tag = BUTTON_TAG_METHOD_VERBS.include?(method) ? method_tag(method) : "".freeze.html_safe + method_tag = BUTTON_TAG_METHOD_VERBS.include?(method) ? method_tag(method) : "".html_safe form_method = method == "get" ? "get" : "post" form_options = html_options.delete("form") || {} @@ -321,7 +321,7 @@ module ActionView request_method = method.empty? ? "post" : method token_tag(nil, form_options: { action: url, method: request_method }) else - "".freeze + "" end html_options = convert_options_to_data_attributes(options, html_options) @@ -487,12 +487,12 @@ module ActionView option = html_options.delete(item).presence || next "#{item.dasherize}=#{ERB::Util.url_encode(option)}" }.compact - extras = extras.empty? ? "".freeze : "?" + extras.join("&") + extras = extras.empty? ? "" : "?" + extras.join("&") 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) + content_tag("a", name || email_address, html_options, &block) end # True if the current request URI was generated by the given +options+. @@ -575,21 +575,21 @@ module ActionView def convert_options_to_data_attributes(options, html_options) if html_options html_options = html_options.stringify_keys - html_options["data-remote"] = "true".freeze if link_to_remote_options?(options) || link_to_remote_options?(html_options) + html_options["data-remote"] = "true" if link_to_remote_options?(options) || link_to_remote_options?(html_options) - method = html_options.delete("method".freeze) + method = html_options.delete("method") add_method_to_attributes!(html_options, method) if method html_options else - link_to_remote_options?(options) ? { "data-remote" => "true".freeze } : {} + link_to_remote_options?(options) ? { "data-remote" => "true" } : {} end end def link_to_remote_options?(options) if options.is_a?(Hash) - options.delete("remote".freeze) || options.delete(:remote) + options.delete("remote") || options.delete(:remote) end end @@ -622,7 +622,7 @@ module ActionView token ||= form_authenticity_token(form_options: form_options) tag(:input, type: "hidden", name: request_forgery_protection_token.to_s, value: token) else - "".freeze + "" end end diff --git a/actionview/lib/action_view/lookup_context.rb b/actionview/lib/action_view/lookup_context.rb index 0e56eca35c..af67ffa12d 100644 --- a/actionview/lib/action_view/lookup_context.rb +++ b/actionview/lib/action_view/lookup_context.rb @@ -202,13 +202,13 @@ module ActionView # name instead of the prefix. def normalize_name(name, prefixes) prefixes = prefixes.presence - parts = name.to_s.split("/".freeze) + parts = name.to_s.split("/") parts.shift if parts.first.empty? name = parts.pop return name, prefixes || [""] if parts.empty? - parts = parts.join("/".freeze) + parts = parts.join("/") prefixes = prefixes ? prefixes.map { |p| "#{p}/#{parts}" } : [parts] return name, prefixes @@ -245,7 +245,7 @@ module ActionView # add :html as fallback to :js. def formats=(values) if values - values.concat(default_formats) if values.delete "*/*".freeze + values.concat(default_formats) if values.delete "*/*" if values == [:js] values << :html @html_fallback_for_js = true diff --git a/actionview/lib/action_view/record_identifier.rb b/actionview/lib/action_view/record_identifier.rb index 1310a1ce0a..ee39b6050d 100644 --- a/actionview/lib/action_view/record_identifier.rb +++ b/actionview/lib/action_view/record_identifier.rb @@ -59,8 +59,8 @@ module ActionView include ModelNaming - JOIN = "_".freeze - NEW = "new".freeze + JOIN = "_" + NEW = "new" # The DOM class convention is to use the singular form of an object or class. # diff --git a/actionview/lib/action_view/renderer/partial_renderer.rb b/actionview/lib/action_view/renderer/partial_renderer.rb index d7f97c3b50..cb850d75ee 100644 --- a/actionview/lib/action_view/renderer/partial_renderer.rb +++ b/actionview/lib/action_view/renderer/partial_renderer.rb @@ -523,7 +523,7 @@ module ActionView def retrieve_variable(path, as) variable = as || begin - base = path[-1] == "/".freeze ? "".freeze : File.basename(path) + base = path[-1] == "/" ? "" : File.basename(path) raise_invalid_identifier(path) unless base =~ /\A_?(.*?)(?:\.\w+)*\z/ $1.to_sym end diff --git a/actionview/lib/action_view/template.rb b/actionview/lib/action_view/template.rb index 18a5dae270..f41bbf7fac 100644 --- a/actionview/lib/action_view/template.rb +++ b/actionview/lib/action_view/template.rb @@ -188,7 +188,7 @@ module ActionView end def inspect - @inspect ||= defined?(Rails.root) ? identifier.sub("#{Rails.root}/", "".freeze) : identifier + @inspect ||= defined?(Rails.root) ? identifier.sub("#{Rails.root}/", "") : identifier end # This method is responsible for properly setting the encoding of the @@ -341,13 +341,13 @@ module ActionView def method_name @method_name ||= begin m = +"_#{identifier_method_name}__#{@identifier.hash}_#{__id__}" - m.tr!("-".freeze, "_".freeze) + m.tr!("-", "_") m end end def identifier_method_name - inspect.tr("^a-z_".freeze, "_".freeze) + inspect.tr("^a-z_", "_") end def instrument(action, &block) # :doc: @@ -355,7 +355,7 @@ module ActionView end def instrument_render_template(&block) - ActiveSupport::Notifications.instrument("!render_template.action_view".freeze, instrument_payload, &block) + ActiveSupport::Notifications.instrument("!render_template.action_view", instrument_payload, &block) end def instrument_payload diff --git a/actionview/lib/action_view/template/resolver.rb b/actionview/lib/action_view/template/resolver.rb index 5027303e86..08dd6fb510 100644 --- a/actionview/lib/action_view/template/resolver.rb +++ b/actionview/lib/action_view/template/resolver.rb @@ -282,7 +282,7 @@ module ActionView end def escape_entry(entry) - entry.gsub(/[*?{}\[\]]/, '\\\\\\&'.freeze) + entry.gsub(/[*?{}\[\]]/, '\\\\\\&') end # Returns the file mtime from the filesystem. @@ -294,7 +294,7 @@ module ActionView # from the path, or the handler, we should return the array of formats given # to the resolver. def extract_handler_and_format_and_variant(path) - pieces = File.basename(path).split(".".freeze) + pieces = File.basename(path).split(".") pieces.shift extension = pieces.pop diff --git a/actionview/test/template/text_helper_test.rb b/actionview/test/template/text_helper_test.rb index c4e420a95b..2925489f5d 100644 --- a/actionview/test/template/text_helper_test.rb +++ b/actionview/test/template/text_helper_test.rb @@ -34,10 +34,10 @@ class TextHelperTest < ActionView::TestCase assert_equal "

A paragraph

\n\n

and another one!

", simple_format("A paragraph\n\nand another one!") assert_equal "

A paragraph\n
With a newline

", simple_format("A paragraph\n With a newline") - text = "A\nB\nC\nD".freeze + text = "A\nB\nC\nD" assert_equal "

A\n
B\n
C\n
D

", simple_format(text) - text = "A\r\n \nB\n\n\r\n\t\nC\nD".freeze + text = "A\r\n \nB\n\n\r\n\t\nC\nD" assert_equal "

A\n
\n
B

\n\n

\t\n
C\n
D

", simple_format(text) assert_equal '

This is a classy test

', simple_format("This is a classy test", class: "test") -- cgit v1.2.3 From 9d7d6336d79149c9932854517a777c3b304d7fdf Mon Sep 17 00:00:00 2001 From: lsylvester Date: Mon, 1 Oct 2018 09:50:57 +1000 Subject: make actionview templates marshalable so that they can be serialized during the parallel tests (#34030) --- actionview/lib/action_view/template.rb | 9 +++++++++ actionview/test/template/template_test.rb | 7 +++++++ 2 files changed, 16 insertions(+) (limited to 'actionview') diff --git a/actionview/lib/action_view/template.rb b/actionview/lib/action_view/template.rb index 18a5dae270..2dfb14ab46 100644 --- a/actionview/lib/action_view/template.rb +++ b/actionview/lib/action_view/template.rb @@ -235,6 +235,15 @@ module ActionView end end + def marshal_dump + [ @source, @identifier, @handler, @compiled, @original_encoding, @locals, @virtual_path, @updated_at, @formats, @variants ] + end + + def marshal_load(array) + @source, @identifier, @handler, @compiled, @original_encoding, @locals, @virtual_path, @updated_at, @formats, @variants = *array + @compile_mutex = Mutex.new + end + private # Compile a template. This method ensures a template is compiled diff --git a/actionview/test/template/template_test.rb b/actionview/test/template/template_test.rb index 3dc14e36e0..b348d1f17b 100644 --- a/actionview/test/template/template_test.rb +++ b/actionview/test/template/template_test.rb @@ -196,6 +196,13 @@ class TestERBTemplate < ActiveSupport::TestCase assert_match(Regexp.new("\xFC"), e.message) end + def test_template_is_marshalable + template = new_template + serialized = Marshal.load(Marshal.dump(template)) + assert_equal template.identifier, serialized.identifier + assert_equal template.source, serialized.source + end + def with_external_encoding(encoding) old = Encoding.default_external Encoding::Converter.new old, encoding if old != encoding -- cgit v1.2.3 From b707a6d0eb7a694595152c5ca18f1e72e0bc2f7e Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 30 Sep 2018 16:55:16 -0700 Subject: Explain why we have explicit marshaling methods --- actionview/lib/action_view/template.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'actionview') diff --git a/actionview/lib/action_view/template.rb b/actionview/lib/action_view/template.rb index 2dfb14ab46..f5f64263da 100644 --- a/actionview/lib/action_view/template.rb +++ b/actionview/lib/action_view/template.rb @@ -235,11 +235,15 @@ module ActionView end end - def marshal_dump + + # Exceptions are marshaled when using the parallel test runner with DRb, so we need + # to ensure that references to the template object can be marshaled as well. This means forgoing + # the marshalling of the compiler mutex and instantiating that again on unmarshaling. + def marshal_dump # :nodoc: [ @source, @identifier, @handler, @compiled, @original_encoding, @locals, @virtual_path, @updated_at, @formats, @variants ] end - def marshal_load(array) + def marshal_load(array) # :nodoc: @source, @identifier, @handler, @compiled, @original_encoding, @locals, @virtual_path, @updated_at, @formats, @variants = *array @compile_mutex = Mutex.new end -- cgit v1.2.3 From 3c4b729f48c0320499f16a2e6f50a3d27bde1114 Mon Sep 17 00:00:00 2001 From: Sharang Dashputre Date: Tue, 2 Oct 2018 13:39:40 +0530 Subject: Fix spellings for 'unmarshall(ing/ed)' & 'marshall(ing/ed)' --- actionview/lib/action_view/template.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'actionview') diff --git a/actionview/lib/action_view/template.rb b/actionview/lib/action_view/template.rb index 69a64948cc..d7aee18a84 100644 --- a/actionview/lib/action_view/template.rb +++ b/actionview/lib/action_view/template.rb @@ -236,9 +236,9 @@ module ActionView end - # Exceptions are marshaled when using the parallel test runner with DRb, so we need - # to ensure that references to the template object can be marshaled as well. This means forgoing - # the marshalling of the compiler mutex and instantiating that again on unmarshaling. + # Exceptions are marshalled when using the parallel test runner with DRb, so we need + # to ensure that references to the template object can be marshalled as well. This means forgoing + # the marshalling of the compiler mutex and instantiating that again on unmarshalling. def marshal_dump # :nodoc: [ @source, @identifier, @handler, @compiled, @original_encoding, @locals, @virtual_path, @updated_at, @formats, @variants ] end -- cgit v1.2.3