Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undeprecate plural positional argument #26578

Merged
merged 1 commit into from
Oct 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 1 addition & 8 deletions actionview/lib/action_view/helpers/text_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,7 @@ def excerpt(text, phrase, options = {})
#
# pluralize(2, 'Person', locale: :de)
# # => 2 Personen
def pluralize(count, singular, deprecated_plural = nil, plural: nil, locale: I18n.locale)
if deprecated_plural
ActiveSupport::Deprecation.warn("Passing plural as a positional argument " \
"is deprecated and will be removed in Rails 5.1. Use e.g. " \
"pluralize(1, 'person', plural: 'people') instead.")
plural ||= deprecated_plural
end

def pluralize(count, singular, plural_arg = nil, plural: plural_arg, locale: I18n.locale)
word = if (count == 1 || count =~ /^1(\.0+)?$/)
singular
else
Expand Down
8 changes: 2 additions & 6 deletions actionview/test/template/text_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,8 @@ def test_pluralization
assert_equal("1.25 counts", pluralize("1.25", "count"))
assert_equal("1.0 count", pluralize("1.0", "count"))
assert_equal("1.00 count", pluralize("1.00", "count"))
assert_equal("2 counters", pluralize(2, "count", "counters"))
assert_equal("0 counters", pluralize(nil, "count", "counters"))
assert_equal("2 counters", pluralize(2, "count", plural: "counters"))
assert_equal("0 counters", pluralize(nil, "count", plural: "counters"))
assert_equal("2 people", pluralize(2, "person"))
Expand All @@ -405,12 +407,6 @@ def test_localized_pluralization
end
end

def test_deprecated_plural_as_positional_argument
assert_deprecated do
pluralize(2, "count", "counters")
end
end

def test_cycle_class
value = Cycle.new("one", 2, "3")
assert_equal("one", value.to_s)
Expand Down