From 4d17b78181cbb624e8a88e5fcbfd7f6266268819 Mon Sep 17 00:00:00 2001 From: Mantas Masalskis Date: Thu, 14 May 2020 15:30:36 +0200 Subject: [PATCH] Fixes #3054 - "Get latest translations" update all but latest locales --- .../app/controllers/translation.coffee | 2 +- spec/system/system/translations_spec.rb | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 spec/system/system/translations_spec.rb diff --git a/app/assets/javascripts/app/controllers/translation.coffee b/app/assets/javascripts/app/controllers/translation.coffee index f3e6adf2f..70900c430 100644 --- a/app/assets/javascripts/app/controllers/translation.coffee +++ b/app/assets/javascripts/app/controllers/translation.coffee @@ -175,7 +175,7 @@ class Index extends App.ControllerSubContent success: => loader.update(locale.name, false) locale = locales.shift() - if _.isEmpty(locales) + if !locale hide() return @_syncChanges(locale, locales, loader, hide) diff --git a/spec/system/system/translations_spec.rb b/spec/system/system/translations_spec.rb new file mode 100644 index 000000000..5f9ac1c63 --- /dev/null +++ b/spec/system/system/translations_spec.rb @@ -0,0 +1,18 @@ +require 'rails_helper' + +RSpec.describe 'System > Translations', type: :system do + prepend_before do + Locale.where.not(locale: %w[en-us de-de]).destroy_all # remove all but 2 locales for quicker test + end + + it 'when clicking "Get latest translations" fetches all translations' do + visit 'system/translation' + + expect(Translation).to receive(:load).with('de-de').and_return(true) + expect(Translation).to receive(:load).with('en-us').and_return(true) + + click '.js-syncChanges' + + modal_ready && modal_disappear # make sure test is not terminated while modal is visible + end +end