From 3a5c68857e107cc38a940f89b8cdb1ea7a8f6454 Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Fri, 26 Apr 2019 14:02:17 +0100 Subject: [PATCH] make users explicitly define localized setting values so it's clear which locale is mocked --- spec/support/shared/with_settings.rb | 6 ++++++ spec_legacy/functional/user_mailer_spec.rb | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/spec/support/shared/with_settings.rb b/spec/support/shared/with_settings.rb index 1cb11a0efa..311e578dc8 100644 --- a/spec/support/shared/with_settings.rb +++ b/spec/support/shared/with_settings.rb @@ -53,6 +53,12 @@ RSpec.configure do |config| raise "#{k} is not a valid setting" unless Setting.respond_to?(name) + expect(name).not_to start_with("localized_"), ->() do + base = name[10..-1] + + "Don't use `#{name}` in `with_settings`. Do this: `with_settings: { #{base}: { \"en\" => \"#{v}\" } }`" + end + allow(Setting).to receive(:[]).with(name).and_return v allow(Setting).to receive(:[]).with(name.to_sym).and_return v end diff --git a/spec_legacy/functional/user_mailer_spec.rb b/spec_legacy/functional/user_mailer_spec.rb index 24586e4220..cd25c1c625 100644 --- a/spec_legacy/functional/user_mailer_spec.rb +++ b/spec_legacy/functional/user_mailer_spec.rb @@ -396,7 +396,9 @@ describe UserMailer, type: :mailer do context 'layout', with_settings: { available_languages: [:en, :de], - localized_emails_header: 'deutscher header' + emails_header: { + "de" => 'deutscher header' + } } do it 'should include the emails_header depeding on the locale' do user = FactoryBot.create(:user, language: :de)