Sha256: a4691011f2674051711f784a6af9a43a46259033f2e016e5d3a451b76d325e06
Contents?: true
Size: 1.91 KB
Versions: 2
Compression:
Stored size: 1.91 KB
Contents
# encoding: utf-8 require File.expand_path(File.dirname(__FILE__) + '/../../../test_helper') setup_active_record class I18nActiveRecordMissingTest < Test::Unit::TestCase def setup store_translations(:en, :i18n => { :plural => { :keys => [:zero, :one, :other] } }) I18n.backend = I18n::Backend::Chain.new(I18n.backend) I18n.backend.meta_class.send(:include, I18n::Backend::ActiveRecord::Missing) I18n::Backend::ActiveRecord::Translation.delete_all end def test_can_persist_interpolations translation = I18n::Backend::ActiveRecord::Translation.new \ :key => 'foo', :value => 'bar', :locale => :en translation.interpolations = %w{ count name } translation.save assert translation.valid? end def test_lookup_persists_key I18n.t('foo.bar.baz') assert_equal 1, I18n::Backend::ActiveRecord::Translation.count end def test_lookup_does_not_persist_key_twice 2.times { I18n.t('foo.bar.baz') } assert_equal 1, I18n::Backend::ActiveRecord::Translation.count end def test_persists_interpolation_keys_when_looked_up_directly I18n.t('foo.bar.baz', :cow => "lucy" ) # creates stub translation. translation_stub = I18n::Backend::ActiveRecord::Translation.locale(:en).lookup('foo.bar.baz').first assert translation_stub.interpolates?(:cow) end def test_creates_one_stub_per_pluralization I18n.t('foo', :count => 999) translations = I18n::Backend::ActiveRecord::Translation.locale(:en).find_all_by_key %w{ foo.zero foo.one foo.other } assert_equal 3, translations.length end def test_creates_no_stub_for_base_key_in_pluralization I18n.t('foo', :count => 999) translations = I18n::Backend::ActiveRecord::Translation.locale(:en).find_by_key %w{ foo.zero foo.one foo.other } assert !I18n::Backend::ActiveRecord::Translation.locale(:en).find_by_key("foo") end end if defined?(ActiveRecord)
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
activesupport-2.3.6.pre | lib/active_support/vendor/i18n-0.3.3/test/cases/backend/active_record/missing_test.rb |
i18n-0.3.3 | test/cases/backend/active_record/missing_test.rb |