Skip to content

Commit

Permalink
Do not notify artist of purchase if sending is suppressed
Browse files Browse the repository at this point in the history
  • Loading branch information
floehopper committed Jan 10, 2024
1 parent 31fb59a commit e8d2b37
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/mailers/purchase_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def notify_artist
@purchase = params[:purchase]

return unless (@user = @purchase.album.artist.user)
return if @user.suppress_sending?

mail to: @user.email, subject: "You have sold a copy of #{@purchase.album.title}"
end
Expand Down
10 changes: 10 additions & 0 deletions test/mailers/purchase_mailer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,14 @@ class PurchaseMailerTest < ActionMailer::TestCase
mail = PurchaseMailer.with(purchase:).notify_artist
assert_includes mail.body.to_s, edit_payout_detail_url
end

test 'do not notify artist of purchase if sending is suppressed' do
user = build(:user, sending_suppressed_at: Time.current)
album = build(:album)
user.artists << album.artist
purchase = build(:purchase, album:, price: 7.00)

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

0 comments on commit e8d2b37

Please sign in to comment.