Skip to content

Commit

Permalink
Automatically add legacy promotion factories
Browse files Browse the repository at this point in the history
This should help everyones test suite's to stay green.
  • Loading branch information
mamhoff committed Jun 19, 2024
1 parent 4a87281 commit 800900b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 8 additions & 0 deletions legacy_promotions/lib/solidus_legacy_promotions/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions legacy_promotions/spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 800900b

Please sign in to comment.