Skip to content

Commit

Permalink
Call deliver_now! on mail when using assert_emails
Browse files Browse the repository at this point in the history
These tests were previously passing by accident, because we were never
actually attempting to deliver the mail.
  • Loading branch information
floehopper committed Jan 10, 2024
1 parent e0e0919 commit 31fb59a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions test/mailers/album_mailer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ class AlbumMailerTest < ActionMailer::TestCase

test '#published does not send email if album has no associated user' do
@album.artist.update!(user: nil)
AlbumMailer.with(album: @album).published
AlbumMailer.with(album: @album).published.deliver_now!
assert_emails 0
end

test '#published does not send email if associated user has sending suppressed' do
user = create(:user, sending_suppressed_at: Time.current)
user.artists << @album.artist
AlbumMailer.with(album: @album).published
AlbumMailer.with(album: @album).published.deliver_now!
assert_emails 0
end
end
2 changes: 1 addition & 1 deletion test/mailers/interests_mailer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class InterestsMailerTest < ActionMailer::TestCase

test 'do not send interest confirmation email if sending is suppressed' do
interest = create(:interest, sending_suppressed_at: Time.current)
InterestsMailer.confirm(interest)
InterestsMailer.confirm(interest).deliver_now!
assert_emails 0
end
end
4 changes: 2 additions & 2 deletions test/mailers/purchase_mailer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class PurchaseMailerTest < ActionMailer::TestCase

test 'do not send purchase completed email if sending is suppressed' do
purchase = create(:purchase, customer_email: '[email protected]', sending_suppressed_at: Time.current)
PurchaseMailer.with(purchase:).completed.deliver_now
PurchaseMailer.with(purchase:).completed.deliver_now!
assert_emails 0
end

Expand All @@ -39,7 +39,7 @@ class PurchaseMailerTest < ActionMailer::TestCase
album = build(:album, artist:)
purchase = build(:purchase, album:, price: 7.00)

PurchaseMailer.with(purchase:).notify_artist
PurchaseMailer.with(purchase:).notify_artist.deliver_now!
assert_emails 0
end

Expand Down
4 changes: 2 additions & 2 deletions test/mailers/user_mailer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class UserMailerTest < ActionMailer::TestCase

test 'does not send password reset if user has sending suppressed' do
@user.update!(sending_suppressed_at: Time.current)
UserMailer.with(user: @user).password_reset
UserMailer.with(user: @user).password_reset.deliver_now!
assert_emails 0
end

Expand All @@ -27,7 +27,7 @@ class UserMailerTest < ActionMailer::TestCase

test 'does not send email verification if user has sending suppressed' do
@user.update!(sending_suppressed_at: Time.current)
UserMailer.with(user: @user).email_verification
UserMailer.with(user: @user).email_verification.deliver_now!
assert_emails 0
end
end

0 comments on commit 31fb59a

Please sign in to comment.