From 538958de3fb12b7256586db350822f67fff252de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 12 Mar 2025 23:57:30 +0100 Subject: [PATCH] Simplify mailer test replying to a comment Since we're using the `reply_to` method in a few tests on this file, we might as well use it here for consistency. --- spec/system/emails_spec.rb | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/spec/system/emails_spec.rb b/spec/system/emails_spec.rb index d23b08e6d..8b7b504fe 100644 --- a/spec/system/emails_spec.rb +++ b/spec/system/emails_spec.rb @@ -312,32 +312,19 @@ describe "Emails" do context "Polls" do scenario "Send email on poll comment reply" do - user1 = create(:user, email_on_comment_reply: true) - user2 = create(:user) + user = create(:user, email_on_comment_reply: true) poll = create(:poll, author: create(:user)) - comment = create(:comment, commentable: poll, author: user1) + comment = create(:comment, commentable: poll, author: user) - login_as(user2) - visit poll_path(poll) - - click_link "Reply" - - within "#js-comment-form-comment_#{comment.id}" do - fill_in "Leave your comment", with: "It will be done next week." - click_button "Publish reply" - end - - within "#comment_#{comment.id}" do - expect(page).to have_content "It will be done next week." - end + reply_to(comment) email = open_last_email expect(email).to have_subject("Someone has responded to your comment") - expect(email).to deliver_to(user1) + expect(email).to deliver_to(user) expect(email).not_to have_body_text(poll_path(poll)) expect(email).to have_body_text(comment_path(Comment.last)) expect(email).to have_body_text("To unsubscribe from these emails, visit") - expect(email).to have_body_text(edit_subscriptions_path(token: user1.subscriptions_token)) + expect(email).to have_body_text(edit_subscriptions_path(token: user.subscriptions_token)) expect(email).to have_body_text('and uncheck "Notify me by email when someone replies to my comments"') end end