diff --git a/legacy_promotions/lib/solidus_legacy_promotions/engine.rb b/legacy_promotions/lib/solidus_legacy_promotions/engine.rb index 0be296e75f..d8adcc5e11 100644 --- a/legacy_promotions/lib/solidus_legacy_promotions/engine.rb +++ b/legacy_promotions/lib/solidus_legacy_promotions/engine.rb @@ -73,6 +73,14 @@ class Engine < ::Rails::Engine app.config.assets.precompile << "solidus_legacy_promotions/manifest.js" end + initializer "solidus_legacy_promotions.add_factories_to_core" do + if Rails.env.test? + require 'spree/testing_support/factory_bot' + require 'solidus_legacy_promotions/testing_support/factory_bot' + Spree::TestingSupport::FactoryBot.definition_file_paths.concat(SolidusLegacyPromotions::TestingSupport::FactoryBot.definition_file_paths) + end + end + initializer "solidus_legacy_promotions", after: "spree.load_config_initializers" do Spree::Config.order_contents_class = "Spree::OrderContents" Spree::Config.promotions = SolidusLegacyPromotions::Configuration.new diff --git a/legacy_promotions/spec/rails_helper.rb b/legacy_promotions/spec/rails_helper.rb index 1ea6aeef0f..b2149922fc 100644 --- a/legacy_promotions/spec/rails_helper.rb +++ b/legacy_promotions/spec/rails_helper.rb @@ -52,8 +52,7 @@ ActiveJob::Base.queue_adapter = :test -Spree::TestingSupport::FactoryBot.add_definitions! -SolidusLegacyPromotions::TestingSupport::FactoryBot.add_paths_and_load! +Spree::TestingSupport::FactoryBot.add_paths_and_load! Capybara.register_driver :selenium_chrome_headless do |app| browser_options = ::Selenium::WebDriver::Chrome::Options.new