diff --git a/spec/integration/active_record_compatibility_spec.rb b/spec/integration/active_record_compatibility_spec.rb index 4152882f9..b0249086b 100644 --- a/spec/integration/active_record_compatibility_spec.rb +++ b/spec/integration/active_record_compatibility_spec.rb @@ -77,11 +77,6 @@ describe "fallbacks" do let!(:post) { FallbackPost.create(title: "foo title") } - it "falls through to default locale with no options" do - Mobility.locale = :ja - expect(post.title).to eq("foo title") - end - it "does not fall through to default locale when fallback: false option passed in" do Mobility.locale = :ja expect(post.title(fallback: false)).to eq(nil) diff --git a/spec/mobility/plugins/fallbacks_spec.rb b/spec/mobility/plugins/fallbacks_spec.rb index 0ad665aca..3fb474bf7 100644 --- a/spec/mobility/plugins/fallbacks_spec.rb +++ b/spec/mobility/plugins/fallbacks_spec.rb @@ -73,10 +73,19 @@ def read(locale, **options) context "fallbacks is true" do let(:fallbacks) { true } + # @note I18n changed its behavior in 1.1 (see: https://github.com/svenfuchs/i18n/pull/415) + # To correctly test all versions, we actually generate fallbacks and + # determine what the value should be, then check that it matches the + # actual fallback value. + # TODO: Simplify this when support for I18n < 1.1 is dropped. it "uses default fallbacks" do original_default_locale = I18n.default_locale I18n.default_locale = :ja - expect(subject.read(:"en-US")).to eq("フー") + fallbacks = Mobility::Fallbacks.build({}) + locales = fallbacks[:"en-US"] + # in I18n 1.1 value is nil here + value = locales.map { |locale| subject.read(locale, locale: true) }.compact.first + expect(subject.read(:"en-US")).to eq(value) I18n.default_locale = original_default_locale end end