aboutsummaryrefslogtreecommitdiffstats
path: root/actionview
diff options
context:
space:
mode:
Diffstat (limited to 'actionview')
-rw-r--r--actionview/CHANGELOG.md13
-rw-r--r--actionview/lib/action_view/helpers/asset_tag_helper.rb2
-rw-r--r--actionview/lib/action_view/helpers/form_options_helper.rb12
-rw-r--r--actionview/lib/action_view/helpers/number_helper.rb5
-rw-r--r--actionview/lib/action_view/helpers/text_helper.rb2
-rw-r--r--actionview/package.json2
-rw-r--r--actionview/test/template/form_options_helper_test.rb4
-rw-r--r--actionview/test/template/text_helper_test.rb2
8 files changed, 22 insertions, 20 deletions
diff --git a/actionview/CHANGELOG.md b/actionview/CHANGELOG.md
index 4c552c635a..46b3b1fa25 100644
--- a/actionview/CHANGELOG.md
+++ b/actionview/CHANGELOG.md
@@ -1,13 +1,12 @@
-* Deprecate exposing public methods in view's helpers.
+* Deprecate calling private model methods from view helpers.
- For example, in methods like `options_from_collection_for_select`
- and `collection_select` it is possible to call private methods from
- the objects used.
+ For example, in methods like `options_from_collection_for_select`
+ 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.
-
- *[Ana María Martínez Gómez](https://github.com/Ana06)*
+ Fixes #33546.
+ *Ana María Martínez Gómez*
* Fix issue with `button_to`'s `to_form_params`
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.
# * <tt>:skip_pipeline</tt> - This option is used to bypass the asset pipeline
# when it is set to true.
- # * <tt>:nonce<tt> - When set to true, adds an automatic nonce value if
+ # * <tt>:nonce</tt> - When set to true, adds an automatic nonce value if
# you have Content Security Policy enabled.
#
# ==== Examples
diff --git a/actionview/lib/action_view/helpers/form_options_helper.rb b/actionview/lib/action_view/helpers/form_options_helper.rb
index 2ecba2e337..2b9d55a019 100644
--- a/actionview/lib/action_view/helpers/form_options_helper.rb
+++ b/actionview/lib/action_view/helpers/form_options_helper.rb
@@ -806,13 +806,11 @@ module ActionView
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
+ item.public_send(value)
+ rescue NoMethodError
+ raise unless item.respond_to?(value, true) && !item.respond_to?(value)
+ ActiveSupport::Deprecation.warn "Using private methods from view helpers is deprecated (calling private #{item.class}##{value})"
+ item.send(value)
end
def prompt_text(prompt)
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.
# * <tt>:raise</tt> - If true, raises +InvalidNumberError+ when
# the argument is invalid.
+ # * <tt>:strip_insignificant_zeros</tt> - 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
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/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"
}
}
diff --git a/actionview/test/template/form_options_helper_test.rb b/actionview/test/template/form_options_helper_test.rb
index 7bce946d3b..8a0a706fef 100644
--- a/actionview/test/template/form_options_helper_test.rb
+++ b/actionview/test/template/form_options_helper_test.rb
@@ -74,11 +74,11 @@ 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") }
+ assert_deprecated("Using private methods from view helpers is deprecated (calling private Struct::Post#secret)") { 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") }
+ assert_deprecated("Using private methods from view helpers is deprecated (calling private Struct::Post#secret)") { options_from_collection_for_select(dummy_posts, "author_name", "secret") }
end
def test_collection_options_with_preselected_value
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