Skip to content

AO3-7275 Unreviewed comments marked as spam are still visible to creators#5577

Open
archie-2006 wants to merge 1 commit intootwcode:masterfrom
archie-2006:spam-visiblity
Open

AO3-7275 Unreviewed comments marked as spam are still visible to creators#5577
archie-2006 wants to merge 1 commit intootwcode:masterfrom
archie-2006:spam-visiblity

Conversation

@archie-2006
Copy link

Updated comment to include not_spam scope
filter unreviewed comments in commentscontroller using not_spam update specs to verify spam comments are excluded from viewing

Pull Request Checklist

Issue

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

Purpose

Unreviewed comments marked as spam remained visible to creators in the unreviewed comments.

  • added a not_spam scope to filter out spam-flagged comments.

  • applied the not_spam scope to the index action for unreviewed comments.

  • while creators have their view filtered, admins retain full visibility of all unreviewed comments for moderation.

  • modified comment_spec.rb to verify the exclusion of spam from these filtered collections.

References

  • fixes the issue where unreviewed spam comments behaved differently than reviewed spam comments for creators.

  • updates the unreviewed comments counter consistently

Credit

Archie Singh (she/her/hers)

Updated comment to include not_spam scope
filter unreviewed comments in commentscontroller using not_spam
update specs to verify spam comments are excluded from viewing
@Bilka2
Copy link
Contributor

Bilka2 commented Feb 8, 2026

Hi, Archie Singh!

Thank you so much for this pull request, someone will be along to review it soon.

I've also updated the Jira issue status to In Review so no one will mistakenly create a duplicate pull request. If you'd like the ability to comment on, assign, and transition issues in the future, you're welcome to create a Jira account! It makes things a bit easier for us on the organizational side if the Full Name on your Jira account either closely matches the name you'd like us to credit in the release notes or includes it in parentheses, e.g. "Nickname (CREDIT NAME)."

Once you've done that (or if you've already done it -- Jira has been unreliable about showing us new accounts in the admin panel lately), you can either reply here or send an email to otw-coders@transformativeworks.org with your account name and email address and we'll set up the permissions for you.

Thanks again for contributing! If you have any questions, you can contact us at the same email address listed above.

@Bilka2 Bilka2 changed the title AO3-7275: Unreviewed comments marked as spam are still visible to creators AO3-7275 Unreviewed comments marked as spam are still visible to creators Feb 8, 2026
Copy link
Contributor

@Bilka2 Bilka2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for getting started on this! Please also adjust app/views/works/_work_header_navigation.html.erb to display the correct comment count for users

scope :top_level, -> { where.not(commentable_type: "Comment") }
scope :include_pseud, -> { includes(:pseud) }
scope :not_deleted, -> { where(is_deleted: false) }
scope :not_spam, -> { where(spam: false) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This scope should read the approved column instead (and then it has to be true), per AO3-5997 we are not yet reading from the spam column

end
end

describe ".not_spam" do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this scope is rather simple, we don't really need a unit test for it. Instead, it would be good to have an integration test (so a cucumber test) for the comments showing up/not showing up for admins/users


it "excludes comments marked as spam" do
spam_comment = create(:comment, spam: true)
expect(Comment.not_spam).not_to include(spam_comment)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but if you were wondering why this fails: the spam status is set on creation of the comment (to the default false), so the spam: true that is specified above is getting overridden.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants