I'm trying to test a Rails plugin to make sure that the correct action is performed with or without fallbacks turned on. Inside my Dummy application's configuration, I have:
module Dummy
class Application < Rails::Application
config.i18n.fallbacks = true
end
end
How can I flip this back to false for a specific test? So far I have tried:
Dummy::Application.config.i18n.fallbacks = false
Dummy::Application.configure do |app|
app.config.i18n.fallbacks = false
end
Rails.application.config.i18n.fallbacks = false
All to no avail.
This is an interesting question, actually once the app got initialized in the beginning, you couldn't change i18n configuration because it already got memoized with these codes:
And
I18n.fallbackswas set with this lineWhen you specify the
callbacksas true,I18n.fallbackshas a value ofAnd
I18n.fallbacksis used in this way:As long as
I18n.respond_to? :fallbacks, the app will always have fallbacks feature turned on.The method is defined here in I18n:
To turn off the fallbacks feature, the only way is to make
I18n.respond_to? :fallbacksreturnfalse.Here you go: