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 c860e8d commit a78e28d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 10 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,16 @@ 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
rescue LoadError
# FactoryBot is not available, we don't need factories
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 a78e28d

Please sign in to comment.