mirror of
https://github.com/lunaisnotaboy/mastodon.git
synced 2024-08-18 14:05:26 +00:00
* Record account suspend/silence time and keep track of domain blocks * Also unblock users who were suspended/silenced before dates were recorded * Add tests * Keep track of suspending date for users suspended through the CLI * Show accurate number of accounts that would be affected by unsuspending an instance * Change migration to set silenced_at and suspended_at * Revert "Also unblock users who were suspended/silenced before dates were recorded" This reverts commit a015c65d2d1e28c7b7cfab8b3f8cd5fb48b8b71c. * Switch from using suspended and silenced to suspended_at and silenced_at * Add post-deployment migration script to remove `suspended` and `silenced` columns * Use Account#silence! and Account#suspend! instead of updating the underlying property * Add silenced_at and suspended_at migration to post-migration * Change account fabricator to translate suspended and silenced attributes * Minor fixes * Make unblocking domains always retroactive
84 lines
2.1 KiB
Ruby
84 lines
2.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
describe StatusFilter do
|
|
describe '#filtered?' do
|
|
let(:status) { Fabricate(:status) }
|
|
|
|
context 'without an account' do
|
|
subject { described_class.new(status, nil) }
|
|
|
|
context 'when there are no connections' do
|
|
it { is_expected.not_to be_filtered }
|
|
end
|
|
|
|
context 'when status account is silenced' do
|
|
before do
|
|
status.account.silence!
|
|
end
|
|
|
|
it { is_expected.to be_filtered }
|
|
end
|
|
|
|
context 'when status policy does not allow show' do
|
|
before do
|
|
expect_any_instance_of(StatusPolicy).to receive(:show?).and_return(false)
|
|
end
|
|
|
|
it { is_expected.to be_filtered }
|
|
end
|
|
end
|
|
|
|
context 'with real account' do
|
|
let(:account) { Fabricate(:account) }
|
|
subject { described_class.new(status, account) }
|
|
|
|
context 'when there are no connections' do
|
|
it { is_expected.not_to be_filtered }
|
|
end
|
|
|
|
context 'when status account is blocked' do
|
|
before do
|
|
Fabricate(:block, account: account, target_account: status.account)
|
|
end
|
|
|
|
it { is_expected.to be_filtered }
|
|
end
|
|
|
|
context 'when status account domain is blocked' do
|
|
before do
|
|
status.account.update(domain: 'example.com')
|
|
Fabricate(:account_domain_block, account: account, domain: status.account_domain)
|
|
end
|
|
|
|
it { is_expected.to be_filtered }
|
|
end
|
|
|
|
context 'when status account is muted' do
|
|
before do
|
|
Fabricate(:mute, account: account, target_account: status.account)
|
|
end
|
|
|
|
it { is_expected.to be_filtered }
|
|
end
|
|
|
|
context 'when status account is silenced' do
|
|
before do
|
|
status.account.silence!
|
|
end
|
|
|
|
it { is_expected.to be_filtered }
|
|
end
|
|
|
|
context 'when status policy does not allow show' do
|
|
before do
|
|
expect_any_instance_of(StatusPolicy).to receive(:show?).and_return(false)
|
|
end
|
|
|
|
it { is_expected.to be_filtered }
|
|
end
|
|
end
|
|
end
|
|
end
|