2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2020-01-27 09:28:17 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe Locale, type: :model do
|
|
|
|
describe 'Class methods:' do
|
|
|
|
describe '.default' do
|
|
|
|
context 'with default locale' do
|
|
|
|
before { Setting.set('locale_default', 'foo') }
|
|
|
|
|
|
|
|
it 'returns the system-wide default locale' do
|
|
|
|
expect(described_class.default).to eq('foo')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'without default locale' do
|
|
|
|
before { Setting.set('locale_default', nil) }
|
|
|
|
|
|
|
|
it 'returns en-us' do
|
|
|
|
expect(described_class.default).to eq('en-us')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-11-15 15:58:19 +00:00
|
|
|
|
|
|
|
describe '.sync()' do
|
|
|
|
context 'when importing locales' do
|
|
|
|
before do
|
|
|
|
described_class.all.delete_all
|
|
|
|
described_class.sync
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'imports many locales locales' do
|
|
|
|
expect(described_class.count).to be > 40
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'imports locale data correctly' do
|
|
|
|
expect(described_class.find_by(locale: 'de-de')).to have_attributes(locale: 'de-de', alias: 'de', name: 'Deutsch', dir: 'ltr', active: true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-01-27 09:28:17 +00:00
|
|
|
end
|
|
|
|
end
|