Skip to content

Commit

Permalink
Support Solidus v3.2
Browse files Browse the repository at this point in the history
We need to unsubscribe the subscription from the new event system.
  • Loading branch information
waiting-for-dev committed May 4, 2022
1 parent 6fe5b0a commit 126f093
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
8 changes: 8 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ jobs:
executor: solidusio_extensions/mysql
steps:
- solidusio_extensions/run-tests
disable-built-in-emails:
executor: solidusio_extensions/postgres
steps:
- solidusio_extensions/run-tests
environment:
DISABLE_BUILTIN_EMAILS: 1
lint-code:
executor: solidusio_extensions/sqlite-memory
steps:
Expand All @@ -26,6 +32,7 @@ workflows:
jobs:
- run-specs-with-postgres
- run-specs-with-mysql
- disable-built-in-emails
- lint-code

"Weekly run specs against master":
Expand All @@ -39,3 +46,4 @@ workflows:
jobs:
- run-specs-with-postgres
- run-specs-with-mysql
- disable-built-in-emails
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
branch = 'waiting-for-dev/omnes' if branch == 'master'
gem 'solidus', github: 'solidusio/solidus', branch: branch

# Needed to help Bundler figure out how to resolve dependencies,
Expand Down
8 changes: 8 additions & 0 deletions lib/solidus_tracking/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,13 @@ class Engine < Rails::Engine
config.generators do |g|
g.test_framework :rspec
end

config.after_initialize do
if SolidusTracking.configuration.disable_builtin_emails && defined?(Spree::OrderMailerSubscriber)
Spree::Bus.unsubscribe(
Spree::Bus.subscription(:spree_order_mailer_send_confirmation_email)
)
end
end
end
end
6 changes: 2 additions & 4 deletions spec/models/spree/order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@
end
end

context 'when disable_builtin_emails is true' do
context 'when disable_builtin_emails is true', if: ENV['DISABLE_BUILTIN_EMAILS'] do
it 'does not send the confirmation email' do
allow(SolidusTracking.configuration).to receive(:disable_builtin_emails).and_return(true)
order = Spree::TestingSupport::OrderWalkthrough.up_to(:payment)

expect {
Expand All @@ -52,9 +51,8 @@
end
end

context 'when disable_builtin_emails is false' do
context 'when disable_builtin_emails is false', unless: ENV['DISABLE_BUILTIN_EMAILS'] do
it 'sends the confirmation email' do
allow(SolidusTracking.configuration).to receive(:disable_builtin_emails).and_return(false)
order = Spree::TestingSupport::OrderWalkthrough.up_to(:payment)

expect {
Expand Down
1 change: 1 addition & 0 deletions spec/support/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
config.before do
SolidusTracking.configure do |c|
c.test_mode = false
c.disable_builtin_emails = ENV['DISABLE_BUILTIN_EMAILS'].present?
c.variant_url_builder = proc do |variant|
"https://example.com/products/#{variant.product.slug}"
end
Expand Down

0 comments on commit 126f093

Please sign in to comment.