diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-05-25 18:05:06 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-05-25 18:05:06 +0000 |
commit | b3b6c78112c97df32c406f7dd18031e540df3297 (patch) | |
tree | 4abd36a4157b40fd3a6bdab227ca00b415a2f801 /spec | |
parent | 43c3614ebfd3a224b9db5718f19aa1e1eb7e7e61 (diff) | |
parent | 5c921809cd86e1031a6a5075da142fef3bb01d6d (diff) | |
download | gitlab-ce-b3b6c78112c97df32c406f7dd18031e540df3297.tar.gz |
Merge branch '32748-emails-are-being-sent-with-the-wrong-language' into 'master'
Bugfix: Always use the default language when generating emails.
Closes #32748
See merge request !11662
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/i18n_spec.rb | 32 | ||||
-rw-r--r-- | spec/mailers/notify_spec.rb | 9 |
2 files changed, 25 insertions, 16 deletions
diff --git a/spec/lib/gitlab/i18n_spec.rb b/spec/lib/gitlab/i18n_spec.rb index 52f2614d5ca..a3dbeaa3753 100644 --- a/spec/lib/gitlab/i18n_spec.rb +++ b/spec/lib/gitlab/i18n_spec.rb @@ -1,27 +1,27 @@ require 'spec_helper' -module Gitlab - describe I18n, lib: true do - let(:user) { create(:user, preferred_language: 'es') } +describe Gitlab::I18n, lib: true do + let(:user) { create(:user, preferred_language: 'es') } - describe '.set_locale' do - it 'sets the locale based on current user preferred language' do - Gitlab::I18n.set_locale(user) + describe '.locale=' do + after { described_class.use_default_locale } - expect(FastGettext.locale).to eq('es') - expect(::I18n.locale).to eq(:es) - end + it 'sets the locale based on current user preferred language' do + described_class.locale = user.preferred_language + + expect(FastGettext.locale).to eq('es') + expect(::I18n.locale).to eq(:es) end + end - describe '.reset_locale' do - it 'resets the locale to the default language' do - Gitlab::I18n.set_locale(user) + describe '.use_default_locale' do + it 'resets the locale to the default language' do + described_class.locale = user.preferred_language - Gitlab::I18n.reset_locale + described_class.use_default_locale - expect(FastGettext.locale).to eq('en') - expect(::I18n.locale).to eq(:en) - end + expect(FastGettext.locale).to eq('en') + expect(::I18n.locale).to eq(:en) end end end diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index 1e6260270fe..ec6f6c42eac 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -128,6 +128,15 @@ describe Notify do is_expected.to have_body_text(namespace_project_issue_path(project.namespace, project, issue)) end end + + context 'with a preferred language' do + before { Gitlab::I18n.locale = :es } + after { Gitlab::I18n.use_default_locale } + + it 'always generates the email using the default language' do + is_expected.to have_body_text('foo, bar, and baz') + end + end end describe 'status changed' do |