Closed ryohakjae114 closed 19 hours ago
メールテストについて
今回は使わないかもですが、非同期でメールを送信するときに使うヘルパメソッド。
perform_enqueued_jobs
https://api.rubyonrails.org/classes/ActiveJob/TestHelper.html#method-i-perform_enqueued_jobs
このへんも参考になりそう。 Rails テスティングガイド - Railsガイド
[x] コメントされたら投稿主にメール通知が飛ぶ 12:20~
rails g UserMailer commented
[x] メーラーを編集する 5m ~ 13:50
default from: 'notifications@example.com'
def commented
@comment = params[:comment]
mail(to: @comment.post.user.email, subject: 'コメントが届きました')
end
UserMailer.with(comment: @comment).commented if @post.user.email.present?
expect(ActionMailer::Base.deliveries.count).to eq 0
expect(ActionMailer::Base.deliveries.count).to eq 1
expect(mail.to) eq 'taji@example.com'
post_url(comment.post, anchor: comment.id)
であること ~ 12:23, 13:50~14:17
[x] コメントされたら投稿主にメール通知が飛ぶ 40m
[x] メーラーを編集する 5m
[x] ユーザが自身のコメントに投稿すると、通知は送信されない 10m
[x] ユーザがメールのリンクをクリックすると、投稿のコメントに飛べるように 10m
[x] テスト作成(タスクばらしまだ)