FEATURE: Users cannot reflag recently handled items using the same reason unless the post was edited, or it was reviewed more than 24 hours ago. (#8969)

This commit is contained in:
Roman Rizzi
2020-02-14 13:43:48 -03:00
committed by GitHub
parent ea0f20e331
commit fadb2b7157
4 changed files with 55 additions and 2 deletions

View File

@ -115,6 +115,38 @@ describe PostActionCreator do
expect(score.reviewed_by).to be_blank
expect(score.reviewed_at).to be_blank
end
describe "When the post was already reviewed by staff" do
fab!(:admin) { Fabricate(:admin) }
before { reviewable.perform(admin, :ignore) }
it "fails because the post was recently reviewed" do
result = PostActionCreator.create(user, post, :inappropriate)
expect(result.success?).to eq(false)
end
it "succesfully flags the post if it was edited after being reviewed" do
reviewable.update!(updated_at: 25.hours.ago)
post.last_version_at = 30.hours.ago
result = PostActionCreator.create(user, post, :inappropriate)
expect(result.success?).to eq(true)
expect(result.reviewable).to be_present
end
it 'succesfully flags the post if it was reviewed more than 24 hours ago' do
reviewable.update!(updated_at: 10.minutes.ago)
post.last_version_at = 1.minute.ago
result = PostActionCreator.create(user, post, :inappropriate)
expect(result.success?).to eq(true)
expect(result.reviewable).to be_present
end
end
end
end