DEV: Add specs for handling InvalidPluralizationData exception

DEV: Add specs for handling InvalidPluralizationData exception

follow-up to 6d44be51

diff --git a/spec/components/discourse_i18n_spec.rb b/spec/components/discourse_i18n_spec.rb
index 19118ea..0215dc3 100644
--- a/spec/components/discourse_i18n_spec.rb
+++ b/spec/components/discourse_i18n_spec.rb
@@ -94,4 +94,23 @@ describe I18n::Backend::DiscourseI18n do
       expect(backend.exists?(:ru, :bogus)).to eq(false)
     end
   end
+
+  describe '#pluralize' do
+    it 'uses fallback locales when a pluralization key is missing' do
+      SiteSetting.default_locale = 'ru'
+
+      backend.store_translations(:ru, items: { one: '%{count} Russian item', other: '%{count} Russian items' })
+
+      expect(backend.translate(:ru, :items, count: 1)).to eq('1 Russian item')
+      expect(backend.translate(:ru, :items, count: 2)).to eq('2 items')
+      expect(backend.translate(:ru, :items, count: 5)).to eq('5 Russian items')
+
+      backend.store_translations(:ru, items: { one: '%{count} Russian item', few: '%{count} Russian items are a few', other: '%{count} Russian items' })
+      expect(backend.translate(:ru, :items, count: 2)).to eq('2 Russian items are a few')
+
+      backend.store_translations(:en, airplanes: { one: '%{count} airplane' })
+      expect(backend.translate(:ru, :airplanes, count: 1)).to eq('1 airplane')
+      expect { backend.translate(:ru, :airplanes, count: 2) }.to raise_error(I18n::InvalidPluralizationData)
+    end
+  end
 end

GitHub sha: 13e54bca

1 Like