Permalink
Browse files

Adds fallback tests for empty and nil translations

  • Loading branch information...
1 parent 31ad7ef commit c83bfdcf3d39a536519cb7f2cdec0c88184f698c Jeroen Jacobs committed May 18, 2011
Showing with 22 additions and 0 deletions.
  1. +22 −0 test/globalize3/fallbacks_test.rb
@@ -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.

0 comments on commit c83bfdc

Please sign in to comment.