Skip to content

Commit

Permalink
Load defaults for the latest Rails minor version in the dummy app
Browse files Browse the repository at this point in the history
Before this change, the dummy app used in the test suite was not loading
any new default that Rails has added since 5.0.

However, we still use old defaults for three settings that make our test
suite fail. Each one of them will be worked out in individual commits.

See https://api.rubyonrails.org/classes/Rails/Application/Configuration.html#method-i-load_defaults
  • Loading branch information
waiting-for-dev committed Apr 22, 2021
1 parent d4174a8 commit f746923
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/lib/spree/testing_support/dummy_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ def self.setup(gem_root:, lib_name:, auto_migrate: true)
end

class Application < ::Rails::Application
config.load_defaults("#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}")
# TODO: Remove the three following settings once the codebase has been adapted
# to load_defaults
config.active_record.has_many_inversing = nil
config.active_storage.track_variants = nil
config.active_record.belongs_to_required_by_default = false
config.eager_load = false
config.cache_classes = true
config.cache_store = :memory_store
Expand Down
12 changes: 12 additions & 0 deletions core/spec/lib/spree/core/testing_support/dummy_app_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe DummyApp do
it 'loads default from the Rails version in use' do
expect(
DummyApp::Application.config.loaded_config_version
).to eq("#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}")
end
end

0 comments on commit f746923

Please sign in to comment.