Maintenance: Add test for Translation.sync with all active locales.
This commit is contained in:
parent
58f3cd6737
commit
f111d0cce3
2 changed files with 19 additions and 5 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue