diff --git a/Gemfile.lock b/Gemfile.lock index 285e46804..e23c96d34 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -172,7 +172,7 @@ GEM erubi (1.10.0) eventmachine (1.2.7) execjs (2.8.1) - factory_bot (6.2.0) + factory_bot (6.2.1) activesupport (>= 5.0.0) factory_bot_rails (6.2.0) factory_bot (~> 6.2.0) @@ -508,7 +508,7 @@ GEM shoulda-matchers (5.1.0) activesupport (>= 5.2.0) simple_oauth (0.3.1) - simple_po_parser (1.1.5) + simple_po_parser (1.1.6) slack-notifier (2.4.0) slack-ruby-client (1.0.0) faraday (>= 1.0) diff --git a/spec/models/translation/translation_synchronizes_from_po_spec.rb b/spec/models/translation/translation_synchronizes_from_po_spec.rb index fbf07700f..42b2d1f2d 100644 --- a/spec/models/translation/translation_synchronizes_from_po_spec.rb +++ b/spec/models/translation/translation_synchronizes_from_po_spec.rb @@ -189,9 +189,10 @@ RSpec.describe Translation do end end - context 'when synchronizing strings for all locales' do + context 'when synchronizing strings for CI locales' do - before do + # Tests are slow, so use before :all to save time. + before :all do # rubocop:disable RSpec/BeforeAfterAll # Simulate additional entries File.write(Rails.root.join('i18n/testaddon.de-de.po'), <<~CUSTOM_PO) msgid "custom-string-translated" @@ -213,7 +214,7 @@ RSpec.describe Translation do described_class.sync end - after do + after :all do # rubocop:disable RSpec/BeforeAfterAll FileUtils.remove(Rails.root.join('i18n/testaddon.de-de.po')) end @@ -250,4 +251,17 @@ RSpec.describe Translation do end end + # Make sure that translation imports work really for all locales. + context 'when synchronizing strings for all locales' do + before do + # Only 'en-us' and 'de-de' are returned in test env - override. + allow(Locale).to receive(:to_sync).and_return(Locale.where(active: true)) + described_class.sync + end + + it 'imports without error and finds Chinese entries' do + expect(described_class.where(locale: 'zh-cn').count).to be > 500 + end + end + end