Skip to content

Commit

Permalink
Replace mailer with notify: RenewalPendingPaymentEmailService
Browse files Browse the repository at this point in the history
  • Loading branch information
tobyprivett committed May 5, 2021
1 parent 18897c6 commit f641c93
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 339 deletions.
28 changes: 0 additions & 28 deletions app/mailers/waste_carriers_engine/renewal_mailer.rb

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ def send_renewal_pending_checks_email
end

def send_renewal_received_pending_payment_email
RenewalMailer.send_renewal_received_email(self).deliver_now
WasteCarriersEngine::Notify::RenewalPendingPaymentEmailService.run(registration: self)
rescue StandardError => e
Airbrake.notify(e, registration_no: reg_identifier) if defined?(Airbrake)
end
Expand Down

This file was deleted.

83 changes: 0 additions & 83 deletions config/locales/mailers/renewal_mailer.en.yml

This file was deleted.

82 changes: 0 additions & 82 deletions spec/mailers/waste_carriers_engine/renewal_mailer_spec.rb

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ module WasteCarriersEngine
include_examples "has next transition", next_state: "renewal_received_pending_payment_form"

it "sends a confirmation email after the 'next' event" do
expect { subject.next! }.to change { ActionMailer::Base.deliveries.count }.by(1)
expect(Notify::RenewalPendingPaymentEmailService)
.to receive(:run)
.with(registration: subject)
.once

subject.next!
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ module WasteCarriersEngine
include_examples "has next transition", next_state: "renewal_complete_form"

it "does not send a confirmation email after the 'next' event" do
expect { subject.next! }.to_not change { ActionMailer::Base.deliveries.count }
# An older incarnation of this spec checked that ActionMailer
# did not send *any* emails.
# Here we check to see if the notification service has been invoked,
# which should tell us if *any* emails have been sent.
expect(Notifications::Client).not_to receive(:new)

subject.next!
end
end

Expand Down

0 comments on commit f641c93

Please sign in to comment.