diff options
author | José Valim <jose.valim@plataformatec.com.br> | 2012-07-31 05:46:25 -0700 |
---|---|---|
committer | José Valim <jose.valim@plataformatec.com.br> | 2012-07-31 05:46:25 -0700 |
commit | 13af5aceffb7197230c0934becaa4e9e20cfda23 (patch) | |
tree | cb26a237300c6498ac4407282b2fb9cbe5924c3c /activesupport/test | |
parent | b09d6aae9ebf851b9cd682df50bbfe43391222b5 (diff) | |
parent | 7db0b073fec6bc3e6f213b58c76e7f43fcc2ab97 (diff) | |
download | rails-13af5aceffb7197230c0934becaa4e9e20cfda23.tar.gz rails-13af5aceffb7197230c0934becaa4e9e20cfda23.tar.bz2 rails-13af5aceffb7197230c0934becaa4e9e20cfda23.zip |
Merge pull request #7197 from davidcelis/i18n_inflector
Make ActiveSupport::Inflector locale aware and multilingual
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/inflector_test.rb | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/activesupport/test/inflector_test.rb b/activesupport/test/inflector_test.rb index 1f32e4ff92..cd91002147 100644 --- a/activesupport/test/inflector_test.rb +++ b/activesupport/test/inflector_test.rb @@ -354,6 +354,35 @@ class InflectorTest < ActiveSupport::TestCase RUBY end + def test_inflector_locality + ActiveSupport::Inflector.inflections(:es) do |inflect| + inflect.plural(/$/, 's') + inflect.plural(/z$/i, 'ces') + + inflect.singular(/s$/, '') + inflect.singular(/es$/, '') + + inflect.irregular('el', 'los') + end + + assert_equal('hijos', 'hijo'.pluralize(:es)) + assert_equal('luces', 'luz'.pluralize(:es)) + assert_equal('luzs', 'luz'.pluralize) + + assert_equal('sociedad', 'sociedades'.singularize(:es)) + assert_equal('sociedade', 'sociedades'.singularize) + + assert_equal('los', 'el'.pluralize(:es)) + assert_equal('els', 'el'.pluralize) + + ActiveSupport::Inflector.inflections(:es) { |inflect| inflect.clear } + + assert ActiveSupport::Inflector.inflections(:es).plurals.empty? + assert ActiveSupport::Inflector.inflections(:es).singulars.empty? + assert !ActiveSupport::Inflector.inflections.plurals.empty? + assert !ActiveSupport::Inflector.inflections.singulars.empty? + end + def test_clear_all with_dup do ActiveSupport::Inflector.inflections do |inflect| @@ -467,7 +496,7 @@ class InflectorTest < ActiveSupport::TestCase # there are module functions that access ActiveSupport::Inflector.inflections, # so we need to replace the singleton itself. def with_dup - original = ActiveSupport::Inflector.inflections + original = ActiveSupport::Inflector::Inflections.instance_variable_get(:@__instance__) ActiveSupport::Inflector::Inflections.instance_variable_set(:@__instance__, original.dup) ensure ActiveSupport::Inflector::Inflections.instance_variable_set(:@__instance__, original) |