@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")
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