From: Tom Hughes Date: Sun, 16 Feb 2025 13:34:12 +0000 (+0000) Subject: Make reports trigger a spam check on the reported user X-Git-Tag: live~174^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/b68aa8f3ddeb4e644915b4970d46a6cb169733db?hp=-c Make reports trigger a spam check on the reported user --- b68aa8f3ddeb4e644915b4970d46a6cb169733db diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 5c70d9704..e2ec400a5 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -29,6 +29,8 @@ class ReportsController < ApplicationController @report.issue.reopen unless @report.issue.open? @report.issue.save! + @report.issue.reported_user&.spam_check + redirect_to helpers.reportable_url(@report.issue.reportable), :notice => t(".successful_report") else flash.now[:notice] = t(".provide_details") diff --git a/test/controllers/reports_controller_test.rb b/test/controllers/reports_controller_test.rb index 25b80e8f4..a7f65de62 100644 --- a/test/controllers/reports_controller_test.rb +++ b/test/controllers/reports_controller_test.rb @@ -111,4 +111,42 @@ class ReportsControllerTest < ActionDispatch::IntegrationTest assert_equal 2, issue.reports.count end + + def test_spam_reports_can_suspend + target_user = create(:user) + + session_for(create(:user)) + + post reports_path(:report => { + :details => "Spammer", + :category => "spam", + :issue => { :reportable_id => target_user.id, :reportable_type => "User" } + }) + assert_equal "active", target_user.reload.status + + session_for(create(:user)) + + post reports_path(:report => { + :details => "Spammer", + :category => "spam", + :issue => { :reportable_id => target_user.id, :reportable_type => "User" } + }) + assert_equal "active", target_user.reload.status + + post reports_path(:report => { + :details => "Spammer", + :category => "spam", + :issue => { :reportable_id => target_user.id, :reportable_type => "User" } + }) + assert_equal "active", target_user.reload.status + + session_for(create(:user)) + + post reports_path(:report => { + :details => "Spammer", + :category => "spam", + :issue => { :reportable_id => target_user.id, :reportable_type => "User" } + }) + assert_equal "suspended", target_user.reload.status + end end