Module: Workarea::TestCase::Locales

Extended by:
ActiveSupport::Concern
Included in:
IntegrationTest, PerformanceTest, SystemTest, Workarea::TestCase, ViewTest
Defined in:
lib/workarea/test_case.rb

Instance Method Summary collapse

Instance Method Details

#restore_localesObject



146
147
148
149
150
151
152
153
154
# File 'lib/workarea/test_case.rb', line 146

def restore_locales
  Rails.application.config.i18n.available_locales = @current_rails_available_locales
  Rails.application.config.i18n.default_locale = @current_rails_default_locale

  I18n.available_locales = @current_i18n_available_locales
  I18n.default_locale = @current_i18n_default_locale
  I18n.locale = @current_i18n_locale
  I18n.fallbacks = @current_i18n_fallbacks if I18n.respond_to?(:fallbacks=)
end

#save_localesObject



136
137
138
139
140
141
142
143
144
# File 'lib/workarea/test_case.rb', line 136

def save_locales
  @current_rails_available_locales = Rails.application.config.i18n.available_locales
  @current_rails_default_locale = Rails.application.config.i18n.default_locale

  @current_i18n_available_locales = I18n.available_locales
  @current_i18n_default_locale = I18n.default_locale
  @current_i18n_locale = I18n.default_locale
  @current_i18n_fallbacks = I18n.try(:fallbacks)
end

#set_locales(available:, default:, current: nil, fallbacks: nil) ⇒ Object



129
130
131
132
133
134
# File 'lib/workarea/test_case.rb', line 129

def set_locales(available:, default:, current: nil, fallbacks: nil)
  Rails.application.config.i18n.available_locales = I18n.available_locales = available
  Rails.application.config.i18n.default_locale = I18n.default_locale = default
  I18n.locale = current || default
  I18n.fallbacks = fallbacks if I18n.respond_to?(:fallbacks=)
end