locale_spec.rb 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Locale, type: :model do
  4. describe 'Class methods:' do
  5. describe '.default' do
  6. context 'with default locale' do
  7. before { Setting.set('locale_default', 'foo') }
  8. it 'returns the system-wide default locale' do
  9. expect(described_class.default).to eq('foo')
  10. end
  11. end
  12. context 'without default locale' do
  13. before { Setting.set('locale_default', nil) }
  14. it 'returns en-us' do
  15. expect(described_class.default).to eq('en-us')
  16. end
  17. end
  18. end
  19. describe '.sync()' do
  20. context 'when importing locales' do
  21. before do
  22. described_class.all.delete_all
  23. described_class.sync
  24. end
  25. it 'imports many locales locales' do
  26. expect(described_class.count).to be > 40
  27. end
  28. it 'imports locale data correctly' do
  29. expect(described_class.find_by(locale: 'de-de')).to have_attributes(locale: 'de-de', alias: 'de', name: 'Deutsch', dir: 'ltr', active: true)
  30. end
  31. end
  32. end
  33. end
  34. end