From 1c76493fa177c19b9b6fa52774d9b3d1512a26d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Fri, 5 Apr 2019 14:15:38 +0200 Subject: [PATCH] Prevent flaky specs because of globalize fallbacks initialization When any helper, lib, mailer, model or view spec is executed after a feature, controller or request spec Globalize.fallbacks returns nil and this can cause some flaky specs. With this patch we are ensuring to initialize Globalize fallbacks between specs. Controller, feature and request specs do not need this patch because of application_controller is currently initializing Globalize.fallback on each request. --- spec/spec_helper.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 513718dd3..a1c4b58a8 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -45,6 +45,9 @@ RSpec.configure do |config| DatabaseCleaner.strategy = :transaction I18n.locale = :en Globalize.locale = I18n.locale + unless %i[controller feature request].include? example.metadata[:type] + Globalize.set_fallbacks_to_all_available_locales + end load Rails.root.join("db", "seeds.rb").to_s Setting["feature.user.skip_verification"] = nil end