Skip to content

Commit

Permalink
Merge pull request #6981 from fjordllc/bug/fix-admin-notification-ign…
Browse files Browse the repository at this point in the history
…oring-settings

メール通知設定がOFFになっている場合は、相談部屋からのメール通知が飛ばないように修正
  • Loading branch information
komagata authored Oct 23, 2023
2 parents 1028453 + 76ffe0f commit 50514e2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/mailers/activity_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def came_comment(args = {})
@message ||= args[:message]
@receiver ||= args[:receiver]

return unless @receiver.mail_notification?

@user = @receiver
link = "/#{@comment.commentable_type.downcase.pluralize}/#{@comment.commentable.id}"
@link_url = notification_redirector_url(
Expand Down
15 changes: 15 additions & 0 deletions test/mailers/activity_mailer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1099,4 +1099,19 @@ class ActivityMailerTest < ActionMailer::TestCase
assert_equal '[FBC] 相談部屋でkomagataさんからコメントがありました。', email.subject
assert_match(/コメント/, email.body.to_s)
end

test 'came_comment for admin with mail_notification off' do
admin = users(:komagata)
admin.update(mail_notification: false)

comment = comments(:commentOfTalk)

ActivityMailer.came_comment(
comment: comment,
message: "相談部屋で#{comment.sender.login_name}さんからコメントがありました。",
receiver: comment.receiver
).deliver_now

assert ActionMailer::Base.deliveries.empty?
end
end

0 comments on commit 50514e2

Please sign in to comment.