mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 15:28:37 +08:00
DEV: Add "delete user" options to illegal flag review (#29956)
We already add the "delete user" and "delete and block user" options to the drop-down for potential spam, but we should do this for potentially illegal posts as well. This is entirely based on the implementation for the potential spam one, including caching the status on the reviewable record. Also note that just as for potential spam, the user must be "deletable" for the option to appear. I also took the liberty to move the options in the drop-down to what I think is a more intuitive place. (Between delete post and suspend/silence user.)
This commit is contained in:
@ -16,6 +16,13 @@ RSpec.describe ReviewableFlaggedPost, type: :model do
|
||||
expect(reviewable.reload.potential_spam?).to eq(true)
|
||||
end
|
||||
|
||||
it "sets `potentially_illegal` when an illegal flag is added" do
|
||||
reviewable = PostActionCreator.off_topic(user, post).reviewable
|
||||
expect(reviewable.potentially_illegal?).to eq(false)
|
||||
PostActionCreator.illegal(Fabricate(:user, refresh_auto_groups: true), post)
|
||||
expect(reviewable.reload.potentially_illegal?).to eq(true)
|
||||
end
|
||||
|
||||
describe "actions" do
|
||||
let!(:result) { PostActionCreator.spam(user, post) }
|
||||
let(:reviewable) { result.reviewable }
|
||||
@ -95,7 +102,26 @@ RSpec.describe ReviewableFlaggedPost, type: :model do
|
||||
end
|
||||
|
||||
context "when flagged as potential_spam" do
|
||||
before { reviewable.update!(potential_spam: true) }
|
||||
before { reviewable.update!(potential_spam: true, potentially_illegal: false) }
|
||||
|
||||
it "excludes delete action if the reviewer cannot delete the user" do
|
||||
post.user.user_stat.update!(
|
||||
first_post_created_at: 1.year.ago,
|
||||
post_count: User::MAX_STAFF_DELETE_POST_COUNT + 1,
|
||||
)
|
||||
|
||||
expect(reviewable.actions_for(guardian).has?(:delete_user)).to be false
|
||||
expect(reviewable.actions_for(guardian).has?(:delete_user_block)).to be false
|
||||
end
|
||||
|
||||
it "includes delete actions if the reviewer can delete the user" do
|
||||
expect(reviewable.actions_for(guardian).has?(:delete_user)).to be true
|
||||
expect(reviewable.actions_for(guardian).has?(:delete_user_block)).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context "when flagged as illegal" do
|
||||
before { reviewable.update(potential_spam: false, potentially_illegal: true) }
|
||||
|
||||
it "excludes delete action if the reviewer cannot delete the user" do
|
||||
post.user.user_stat.update!(
|
||||
|
Reference in New Issue
Block a user