Skip to content

Commit

Permalink
Fix bug in Order#deliver_order_confirmation_email
Browse files Browse the repository at this point in the history
When this method was re-introduced in solidusio#3485 with the
purpose of adding a deprecation warning, the reintroduced method had a
bug where `order` was being called on the order (instead of self).

Co-authored-by: Adam Mueller <adam@super.gd>
  • Loading branch information
MadelineCollier and adammathys committed Jul 26, 2022
1 parent a255498 commit 55105f8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/app/models/spree/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,8 @@ def deliver_order_confirmation_email
"Spree::MailerSubscriber#order_finalized.",
caller(1)

Spree::Config.order_mailer_class.confirm_email(order).deliver_later
order.update_column(:confirmation_delivered, true)
Spree::Config.order_mailer_class.confirm_email(self).deliver_later
update_column(:confirmation_delivered, true)
end

# Helper methods for checkout steps
Expand Down
13 changes: 13 additions & 0 deletions core/spec/models/spree/order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@
end
end

describe '#deliver_order_confirmation_mailer' do
it 'sends an email' do
expect(Spree::Config.order_mailer_class).to receive(:confirm_email).and_call_original
order.deliver_order_confirmation_email
end

it 'marks the order as confirmation_delivered' do
expect do
order.deliver_order_confirmation_email
end.to change(order, :confirmation_delivered).to true
end
end

context '#store' do
it { is_expected.to respond_to(:store) }

Expand Down

0 comments on commit 55105f8

Please sign in to comment.