diff --git a/app/helpers/comments_helper.rb b/app/helpers/comments_helper.rb index 377e50c6e3d..9a4266dc4b6 100644 --- a/app/helpers/comments_helper.rb +++ b/app/helpers/comments_helper.rb @@ -302,7 +302,7 @@ def cancel_delete_comment_link(comment) # return html link to mark/unmark comment as spam def tag_comment_as_spam_link(comment) if comment.approved - link_to(ts("Spam"), reject_comment_path(comment), method: :put, confirm: "Are you sure you want to mark this as spam?" ) + link_to(ts("Spam"), reject_comment_path(comment), method: :put, data: { confirm: "Are you sure you want to mark this as spam?" }) else link_to(ts("Not Spam"), approve_comment_path(comment), method: :put) end diff --git a/features/comments_and_kudos/spam_comments.feature b/features/comments_and_kudos/spam_comments.feature index 7a959d3b12a..ef87225955a 100644 --- a/features/comments_and_kudos/spam_comments.feature +++ b/features/comments_and_kudos/spam_comments.feature @@ -46,3 +46,31 @@ Feature: Marking comments as spam When I follow "Default Admin Post" Then I should see "Comments (1)" + + Scenario: Author can mark comments as spam + Given I am logged in as "author" + And I post the work "Popular Fic" + And I log out + When I view the work "Popular Fic" with comments + And I post a spam comment + And I post a guest comment + And I am logged in as "author" + And I view the work "Popular Fic" with comments + Then I should see "Comments (2)" + And I should see "Buy my product" + When I mark the comment as spam + Then I should see "Comments (1)" + And I should not see "Buy my product" + + @javascript + Scenario: If Javascript is enabled, there's a confirmation popup before marking a comment as spam + Given the work "Popular Fic" by "author" + And a guest comment on the work "Popular Fic" + And a guest comment on the work "Popular Fic" + When I am logged in as "author" + And I view the work "Popular Fic" with comments + Then I should see "Comments (2)" + When I mark the comment as spam + And I confirm I want to mark the comment as spam + And I view the work "Popular Fic" with comments + Then I should see "Comments (1)" diff --git a/features/step_definitions/comment_steps.rb b/features/step_definitions/comment_steps.rb index c434b7ea7c3..9167278d888 100644 --- a/features/step_definitions/comment_steps.rb +++ b/features/step_definitions/comment_steps.rb @@ -302,3 +302,11 @@ click_link("Yes, delete!") # TODO: Fix along with comment deletion. end end + +When "I mark the comment as spam" do + click_link("Spam") +end + +When "I confirm I want to mark the comment as spam" do + expect(page.accept_alert).to eq("Are you sure you want to mark this as spam?") if @javascript +end