Skip to content

Commit

Permalink
Add fallback configuration now required
Browse files Browse the repository at this point in the history
  • Loading branch information
j15e committed May 28, 2021
1 parent 40d0c90 commit 136dc32
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test/translates_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def test_retrieves_in_current_locale
def test_retrieves_in_current_locale_with_fallbacks
I18n::Backend::Simple.include(I18n::Backend::Fallbacks)
I18n.default_locale = :"en-US"
I18n.fallbacks = [I18n.default_locale]

p = Post.new(:title_translations => {"en" => "English Title"})
I18n.with_locale(:fr) do
Expand Down Expand Up @@ -53,6 +54,7 @@ def test_retrieves_in_specified_locale
def test_retrieves_in_specified_locale_with_fallbacks
I18n::Backend::Simple.include(I18n::Backend::Fallbacks)
I18n.default_locale = :"en-US"
I18n.fallbacks = [I18n.default_locale]

p = Post.new(:title_translations => { "en" => "English Title" })
I18n.with_locale(:fr) do
Expand All @@ -63,6 +65,7 @@ def test_retrieves_in_specified_locale_with_fallbacks
def test_fallback_from_empty_string
I18n::Backend::Simple.include(I18n::Backend::Fallbacks)
I18n.default_locale = :"en-US"
I18n.fallbacks = [I18n.default_locale]

p = Post.new(:title_translations => { "en" => "English Title", "fr" => "" })
I18n.with_locale(:fr) do
Expand All @@ -73,17 +76,19 @@ def test_fallback_from_empty_string
def test_retrieves_in_specified_locale_with_fallback_disabled
I18n::Backend::Simple.include(I18n::Backend::Fallbacks)
I18n.default_locale = :"en-US"
I18n.fallbacks = [I18n.default_locale]

p = Post.new(:title_translations => { "en" => "English Title" })
p.disable_fallback
I18n.with_locale(:fr) do
assert_equal(nil, p.title_fr)
assert_nil(p.title_fr)
end
end

def test_retrieves_in_specified_locale_with_fallback_disabled_using_a_block
I18n::Backend::Simple.include(I18n::Backend::Fallbacks)
I18n.default_locale = :"en-US"
I18n.fallbacks = [I18n.default_locale]

p = Post.new(:title_translations => { "en" => "English Title" })
p.enable_fallback
Expand All @@ -95,6 +100,7 @@ def test_retrieves_in_specified_locale_with_fallback_disabled_using_a_block
def test_retrieves_in_specified_locale_with_fallback_reenabled
I18n::Backend::Simple.include(I18n::Backend::Fallbacks)
I18n.default_locale = :"en-US"
I18n.fallbacks = [I18n.default_locale]

p = Post.new(:title_translations => { "en" => "English Title" })
p.disable_fallback
Expand All @@ -107,6 +113,7 @@ def test_retrieves_in_specified_locale_with_fallback_reenabled
def test_retrieves_in_specified_locale_with_fallback_reenabled_using_a_block
I18n::Backend::Simple.include(I18n::Backend::Fallbacks)
I18n.default_locale = :"en-US"
I18n.fallbacks = [I18n.default_locale]

p = Post.new(:title_translations => { "en" => "English Title" })
p.disable_fallback
Expand Down

0 comments on commit 136dc32

Please sign in to comment.