mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 10:06:45 +08:00
FIX: prevent re-flagging when we have reviewed flags before (#10010)
FIX: prevent re-flagging when we have reviewed flags before Fixes an edge case where a review can be reflagged when: User flags as inappropriate. Moderator rejects the flag. Another user re-flags the post as spam. Before, anyone was able to re-flag as inappropriate despite it being flagged previously. With this, users are unable to re-flag for the same reason regardless of reviewable status.
This commit is contained in:
@ -151,6 +151,26 @@ describe PostActionCreator do
|
||||
expect(result.success?).to eq(false)
|
||||
end
|
||||
|
||||
it "succeeds with other flag action types" do
|
||||
freeze_time 10.seconds.from_now
|
||||
spam_result = PostActionCreator.create(user, post, :spam)
|
||||
|
||||
expect(reviewable.reload.pending?).to eq(true)
|
||||
end
|
||||
|
||||
it "fails when other flag action types are open" do
|
||||
freeze_time 10.seconds.from_now
|
||||
spam_result = PostActionCreator.create(user, post, :spam)
|
||||
|
||||
inappropriate_result = PostActionCreator.create(Fabricate(:user), post, :inappropriate)
|
||||
|
||||
reviewable.reload
|
||||
|
||||
expect(inappropriate_result.success?).to eq(false)
|
||||
expect(reviewable.pending?).to eq(true)
|
||||
expect(reviewable.reviewable_scores.select(&:pending?).count).to eq(1)
|
||||
end
|
||||
|
||||
it "succesfully flags the post if it was reviewed more than 24 hours ago" do
|
||||
reviewable.update!(updated_at: 25.hours.ago)
|
||||
post.last_version_at = 30.hours.ago
|
||||
|
Reference in New Issue
Block a user