aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test
diff options
context:
space:
mode:
authorStefan Daschek <stefan@die-antwort.eu>2015-07-08 14:59:47 +0200
committerStefan Daschek <stefan@die-antwort.eu>2015-07-09 14:51:13 +0200
commitbb851651f19ae91b800c7eff220690d8ca8fc368 (patch)
tree5dbd9d805f5564cfadd0a80db9e6e3453a71bde3 /actionview/test
parentc2b5aa041b04e65475dd3ebb9f33a68b26e25895 (diff)
downloadrails-bb851651f19ae91b800c7eff220690d8ca8fc368.tar.gz
rails-bb851651f19ae91b800c7eff220690d8ca8fc368.tar.bz2
rails-bb851651f19ae91b800c7eff220690d8ca8fc368.zip
Allow `pluralize` helper to take a locale.
This is already supported in `ActiveSupport::Inflector#pluralize` and `String#pluralize`, so we just forward the locale.
Diffstat (limited to 'actionview/test')
-rw-r--r--actionview/test/template/text_helper_test.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/actionview/test/template/text_helper_test.rb b/actionview/test/template/text_helper_test.rb
index f1b84c4786..5791f33069 100644
--- a/actionview/test/template/text_helper_test.rb
+++ b/actionview/test/template/text_helper_test.rb
@@ -383,6 +383,18 @@ class TextHelperTest < ActionView::TestCase
assert_equal("12 berries", pluralize(12, "berry"))
end
+ def test_pluralization_with_locale
+ ActiveSupport::Inflector.inflections(:de) do |inflect|
+ inflect.plural(/(person)$/i, '\1en')
+ inflect.singular(/(person)en$/i, '\1')
+ end
+
+ assert_equal("2 People", pluralize(2, "Person", locale: :en))
+ assert_equal("2 Personen", pluralize(2, "Person", locale: :de))
+
+ ActiveSupport::Inflector.inflections(:de).clear
+ end
+
def test_cycle_class
value = Cycle.new("one", 2, "3")
assert_equal("one", value.to_s)