Skip to content

Commit

Permalink
Add test for preserving count option
Browse files Browse the repository at this point in the history
  • Loading branch information
radar committed Jan 7, 2020
1 parent ffaf7f0 commit 00b6489
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test/backend/fallbacks_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Backend < I18n::Backend::Simple
def setup
super
I18n.backend = Backend.new
store_translations(:en, :foo => 'Foo in :en', :bar => 'Bar in :en', :buz => 'Buz in :en', :interpolate => 'Interpolate %{value}')
store_translations(:en, :foo => 'Foo in :en', :bar => 'Bar in :en', :buz => 'Buz in :en', :interpolate => 'Interpolate %{value}', :interpolate_count => 'Interpolate %{value} %{count}')
store_translations(:de, :bar => 'Bar in :de', :baz => 'Baz in :de')
store_translations(:'de-DE', :baz => 'Baz in :de-DE')
store_translations(:'pt-BR', :baz => 'Baz in :pt-BR')
Expand All @@ -28,6 +28,10 @@ def setup
assert_equal 'Bar in :de', I18n.t(:bar, :locale => :'de-DE')
end

test "keeps the count option when defaulting to a different key" do
assert_equal 'Interpolate 5 10', I18n.t(:non_existant, default: :interpolate_count, count: 10, value: 5)
end

test "returns the :de translation for a missing :'de-DE' when :default is a String" do
assert_equal 'Bar in :de', I18n.t(:bar, :locale => :'de-DE', :default => "Default Bar")
assert_equal "Default Bar", I18n.t(:missing_bar, :locale => :'de-DE', :default => "Default Bar")
Expand Down

0 comments on commit 00b6489

Please sign in to comment.