Skip to content

Commit

Permalink
AO3-6561 Repair confirm dialog on comment "Spam" button (#4578)
Browse files Browse the repository at this point in the history
* Repair confirm dialog on "Spam" button

https://otwarchive.atlassian.net/browse/AO3-6561

* Add test that isn't testing anything

* Hound

* Hound (bis)

* Actually test popup

* Hound

* Hound (always two or more)

* Update features/comments_and_kudos/spam_comments.feature

Co-authored-by: sarken <[email protected]>

* Update features/comments_and_kudos/spam_comments.feature

Co-authored-by: sarken <[email protected]>

* Update features/step_definitions/comment_steps.rb

Co-authored-by: sarken <[email protected]>

* Explicit popup confirm in test

Otherwise
What is being tested is indeed quite mysterious

---------

Co-authored-by: sarken <[email protected]>
  • Loading branch information
ceithir and sarken authored Aug 13, 2023
1 parent 6504b0b commit c472b7a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/helpers/comments_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions features/comments_and_kudos/spam_comments.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
8 changes: 8 additions & 0 deletions features/step_definitions/comment_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c472b7a

Please sign in to comment.