0
0
Fork 0

Add notifications for statuses deleted by moderators (#17204)

This commit is contained in:
Eugen Rochko 2022-01-17 09:41:33 +01:00 committed by GitHub
parent d5c9feb7b7
commit 14f436c457
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
59 changed files with 1220 additions and 598 deletions

View file

@ -1,52 +0,0 @@
require 'rails_helper'
describe Form::StatusBatch do
let(:form) { Form::StatusBatch.new(action: action, status_ids: status_ids) }
let(:status) { Fabricate(:status) }
describe 'with nsfw action' do
let(:status_ids) { [status.id, nonsensitive_status.id, sensitive_status.id] }
let(:nonsensitive_status) { Fabricate(:status, sensitive: false) }
let(:sensitive_status) { Fabricate(:status, sensitive: true) }
let!(:shown_media_attachment) { Fabricate(:media_attachment, status: nonsensitive_status) }
let!(:hidden_media_attachment) { Fabricate(:media_attachment, status: sensitive_status) }
context 'nsfw_on' do
let(:action) { 'nsfw_on' }
it { expect(form.save).to be true }
it { expect { form.save }.to change { nonsensitive_status.reload.sensitive }.from(false).to(true) }
it { expect { form.save }.not_to change { sensitive_status.reload.sensitive } }
it { expect { form.save }.not_to change { status.reload.sensitive } }
end
context 'nsfw_off' do
let(:action) { 'nsfw_off' }
it { expect(form.save).to be true }
it { expect { form.save }.to change { sensitive_status.reload.sensitive }.from(true).to(false) }
it { expect { form.save }.not_to change { nonsensitive_status.reload.sensitive } }
it { expect { form.save }.not_to change { status.reload.sensitive } }
end
end
describe 'with delete action' do
let(:status_ids) { [status.id] }
let(:action) { 'delete' }
let!(:another_status) { Fabricate(:status) }
before do
allow(RemovalWorker).to receive(:perform_async)
end
it 'call RemovalWorker' do
form.save
expect(RemovalWorker).to have_received(:perform_async).with(status.id, immediate: true)
end
it 'do not call RemovalWorker' do
form.save
expect(RemovalWorker).not_to have_received(:perform_async).with(another_status.id, immediate: true)
end
end
end

View file

@ -54,7 +54,7 @@ describe Report do
end
describe 'resolve!' do
subject(:report) { Fabricate(:report, action_taken: false, action_taken_by_account_id: nil) }
subject(:report) { Fabricate(:report, action_taken_at: nil, action_taken_by_account_id: nil) }
let(:acting_account) { Fabricate(:account) }
@ -63,12 +63,13 @@ describe Report do
end
it 'records action taken' do
expect(report).to have_attributes(action_taken: true, action_taken_by_account_id: acting_account.id)
expect(report.action_taken?).to be true
expect(report.action_taken_by_account_id).to eq acting_account.id
end
end
describe 'unresolve!' do
subject(:report) { Fabricate(:report, action_taken: true, action_taken_by_account_id: acting_account.id) }
subject(:report) { Fabricate(:report, action_taken_at: Time.now.utc, action_taken_by_account_id: acting_account.id) }
let(:acting_account) { Fabricate(:account) }
@ -77,23 +78,24 @@ describe Report do
end
it 'unresolves' do
expect(report).to have_attributes(action_taken: false, action_taken_by_account_id: nil)
expect(report.action_taken?).to be false
expect(report.action_taken_by_account_id).to be_nil
end
end
describe 'unresolved?' do
subject { report.unresolved? }
let(:report) { Fabricate(:report, action_taken: action_taken) }
let(:report) { Fabricate(:report, action_taken_at: action_taken) }
context 'if action is taken' do
let(:action_taken) { true }
let(:action_taken) { Time.now.utc }
it { is_expected.to be false }
end
context 'if action not is taken' do
let(:action_taken) { false }
let(:action_taken) { nil }
it { is_expected.to be true }
end