闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
865 B

  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe 'Localization' do
  4. after(:all) do
  5. I18n.locale = I18n.default_locale
  6. end
  7. it 'uses a specific region when provided' do
  8. headers = { 'Accept-Language' => 'zh-HK' }
  9. get "/about", headers: headers
  10. expect(response.body).to include(
  11. I18n.t('about.about_mastodon', locale: 'zh-HK')
  12. )
  13. end
  14. it 'falls back to a locale when region missing' do
  15. headers = { 'Accept-Language' => 'es-FAKE' }
  16. get "/about", headers: headers
  17. expect(response.body).to include(
  18. I18n.t('about.about_mastodon', locale: 'es')
  19. )
  20. end
  21. it 'falls back to english when locale is missing' do
  22. headers = { 'Accept-Language' => '12-FAKE' }
  23. get "/about", headers: headers
  24. expect(response.body).to include(
  25. I18n.t('about.about_mastodon', locale: 'en')
  26. )
  27. end
  28. end