debian-mirror-gitlab/spec/lib/gitlab/i18n_spec.rb

32 lines
739 B
Ruby
Raw Normal View History

2019-12-26 22:10:19 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
2017-09-10 17:25:29 +05:30
describe Gitlab::I18n do
let(:user) { create(:user, preferred_language: 'es') }
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
describe '.locale=' do
after do
described_class.use_default_locale
end
it 'sets the locale based on current user preferred language' do
described_class.locale = user.preferred_language
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
expect(FastGettext.locale).to eq('es')
expect(::I18n.locale).to eq(:es)
2017-08-17 22:00:37 +05:30
end
2017-09-10 17:25:29 +05:30
end
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
describe '.use_default_locale' do
it 'resets the locale to the default language' do
described_class.locale = user.preferred_language
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
described_class.use_default_locale
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
expect(FastGettext.locale).to eq('en')
expect(::I18n.locale).to eq(:en)
2017-08-17 22:00:37 +05:30
end
end
end