Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adds fallback tests for empty and nil translations

  • Loading branch information...
commit c83bfdcf3d39a536519cb7f2cdec0c88184f698c 1 parent 31ad7ef
Jeroen Jacobs authored
Showing with 22 additions and 0 deletions.
  1. +22 −0 test/globalize3/fallbacks_test.rb
View
22 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.
Please sign in to comment.
Something went wrong with that request. Please try again.