A platform for community discussion. Free, open, simple.
FEATURE: Add scrub action for rejected reviewable users (#36556)
Krzysztof Kotlarek11789c084ad5
diff --git a/app/models/reviewable_user.rb b/app/models/reviewable_user.rbindex c7b42133117..451772918ef 100644--- a/app/models/reviewable_user.rb+++ b/app/models/reviewable_user.rb@@ -12,10 +12,14 @@ class ReviewableUser < Reviewableenddef build_legacy_combined_actions(actions, guardian, args)- return if status != "pending"- build_action(actions, :approve_user, icon: "user-plus") if guardian.can_approve?(target)+ if status == "rejected" && !payload["scrubbed_by"]+ build_action(actions, :scrub, client_action: "scrub")+ end+ if status == "pending"+ build_action(actions, :approve_user, icon: "user-plus") if guardian.can_approve?(target)- delete_user_actions(actions, require_reject_reason: !is_a_suspect_user?)+ delete_user_actions(actions, require_reject_reason: !is_a_suspect_user?)+ endenddef build_actions(actions, guardian, args)diff --git a/spec/system/page_objects/pages/refreshed_review.rb b/spec/system/page_objects/pages/refreshed_review.rbindex ca9895cdacc..4e9b04efd2d 100644--- a/spec/system/page_objects/pages/refreshed_review.rb+++ b/spec/system/page_objects/pages/refreshed_review.rb@@ -72,6 +72,10 @@ module PageObjectsfind(".reviewable-action.edit").clickend+ def click_scrub_user_button+ find(".user-scrub").click+ end+def fill_post_content(content)find(".d-editor-input").fill_in(with: content)enddiff --git a/spec/system/viewing_reviewable_spec.rb b/spec/system/viewing_reviewable_spec.rbindex a18abf4fe6d..a12a7dd2072 100644--- a/spec/system/viewing_reviewable_spec.rb+++ b/spec/system/viewing_reviewable_spec.rb@@ -343,6 +343,46 @@ describe "Viewing reviewable item", type: :system doexpect(refreshed_review_page).to have_reviewable_with_approved_status(reviewable)expect(refreshed_review_page).to have_approved_item_in_timeline(reviewable)end++ it "Allow to delete and scrub user when old moderator actions are enabled" do+ SiteSetting.reviewable_old_moderator_actions = true++ reviewable = ReviewableUser.find_by_target_id(user.id)++ refreshed_review_page.visit_reviewable(reviewable)++ expect(page).to have_text(user.name)+ expect(page).to have_link(user.username, href: "/admin/users/#{user.id}/#{user.username}")++ refreshed_review_page.select_bundled_action(reviewable, "user-delete_user")+ rejection_reason_modal.fill_in_rejection_reason("Spamming the site")+ rejection_reason_modal.delete_user++ expect(refreshed_review_page).to have_reviewable_with_rejected_status(reviewable)++ expect(page).to have_text(user.name)++ refreshed_review_page.click_scrub_user_button++ scrubbing_reason = "a spammer who knows how to make GDPR requests"+ scrub_user_modal.fill_in_scrub_reason(scrubbing_reason)+ expect(scrub_user_modal.scrub_button).not_to be_disabled+ scrub_user_modal.scrub_button.click++ expect(refreshed_review_page).to have_reviewable_with_scrubbed_by(+ reviewable,+ admin.username,+ )+ expect(refreshed_review_page).to have_reviewable_with_scrubbed_reason(+ reviewable,+ scrubbing_reason,+ )+ expect(refreshed_review_page).to have_reviewable_with_scrubbed_at(+ reviewable,+ reviewable.payload["scrubbed_at"],+ )+ expect(page).not_to have_text(user.name)+ endendend