summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2024-05-03 14:21:48 +0200
committerClaire <claire.github-309c@sitedethib.com>2024-05-03 14:27:03 +0200
commit9d13f5c91c33b6273a03d42d49afe5b63c53d3ba (patch)
treeaded3956af9e35488266567e2e4cbc68e429422a
parent33368e3e79a6edfcaf65fd2b80b636a7c1e56e48 (diff)
Fix post deletion not being deferred when those are part of an account warningfixes/account-warning-status-delete
Fixes #30142
-rw-r--r--app/models/status.rb2
-rw-r--r--spec/models/status_spec.rb42
2 files changed, 43 insertions, 1 deletions
diff --git a/app/models/status.rb b/app/models/status.rb
index 0bb5c0ce235..ecb2c9d3776 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -266,7 +266,7 @@ class Status < ApplicationRecord
end
def reported?
- @reported ||= Report.where(target_account: account).unresolved.exists?(['? = ANY(status_ids)', id])
+ @reported ||= Report.where(target_account: account).unresolved.exists?(['? = ANY(status_ids)', id]) || AccountWarning.where(target_account: account).exists?(['? = ANY(status_ids)', id.to_s])
end
def emojis
diff --git a/spec/models/status_spec.rb b/spec/models/status_spec.rb
index 284576cedab..271cf8690ec 100644
--- a/spec/models/status_spec.rb
+++ b/spec/models/status_spec.rb
@@ -205,6 +205,48 @@ RSpec.describe Status do
end
end
+ describe '#reported?' do
+ context 'when the status is not reported' do
+ it 'returns false' do
+ expect(subject.reported?).to be false
+ end
+ end
+
+ context 'when the status is part of an open report' do
+ before do
+ Fabricate(:report, target_account: subject.account, status_ids: [subject.id])
+ end
+
+ it 'returns true' do
+ expect(subject.reported?).to be true
+ end
+ end
+
+ context 'when the status is part of a closed report with an account warning mentioning the account' do
+ before do
+ report = Fabricate(:report, target_account: subject.account, status_ids: [subject.id])
+ report.resolve!(Fabricate(:account))
+ Fabricate(:account_warning, target_account: subject.account, status_ids: [subject.id], report: report)
+ end
+
+ it 'returns true' do
+ expect(subject.reported?).to be true
+ end
+ end
+
+ context 'when the status is part of a closed report with an account warning not mentioning the account' do
+ before do
+ report = Fabricate(:report, target_account: subject.account, status_ids: [subject.id])
+ report.resolve!(Fabricate(:account))
+ Fabricate(:account_warning, target_account: subject.account, report: report)
+ end
+
+ it 'returns false' do
+ expect(subject.reported?).to be false
+ end
+ end
+ end
+
describe '.mutes_map' do
subject { described_class.mutes_map([status.conversation.id], account) }