Skip to content

Commit

Permalink
Adds fallback tests for empty and nil translations
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeroen Jacobs committed May 26, 2011
1 parent 5372725 commit 10e71a2
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/globalize3/fallbacks_test.rb
Expand Up @@ -102,6 +102,28 @@ def teardown
I18n.locale = :'de-DE'
assert_equal 'bar', child.content
end

test 'fallbacks with nil translations' do
I18n.fallbacks.map :'de-DE' => [ :'en-US' ]
post = Post.create :title => 'foo'

I18n.locale = :'de-DE'
assert_equal 'foo', post.title

post.update_attribute :title, nil
assert_equal 'foo', post.title
end

test 'fallbacks with empty translations' do
I18n.fallbacks.map :'de-DE' => [ :'en-US' ]
post = Post.create :title => 'foo'

I18n.locale = :'de-DE'
assert_equal 'foo', post.title

post.update_attribute :title, ''
assert_equal '', post.title
end
end
# TODO should validate_presence_of take fallbacks into account? maybe we need
# an extra validation call, or more options for validate_presence_of.
Expand Down

0 comments on commit 10e71a2

Please sign in to comment.