mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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:
@@ -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
|
||||
|
||||
|
||||
@@ -266,7 +266,7 @@ RSpec.describe Reviewable, type: :model do
|
||||
end
|
||||
|
||||
it "triggers a notification on update" do
|
||||
reviewable = PostActionCreator.spam(moderator, post).reviewable
|
||||
reviewable = PostActionCreator.create(moderator, post, :inappropriate).reviewable
|
||||
reviewable.perform(moderator, :disagree)
|
||||
|
||||
expect { PostActionCreator.spam(Fabricate(:user), post) }
|
||||
|
||||
Reference in New Issue
Block a user