Revamp notification policy options (#31343)

This commit is contained in:
Claire 2024-08-09 15:30:55 +02:00 committed by GitHub
parent e29c401f77
commit cbdd8edf68
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 442 additions and 109 deletions

View file

@ -196,20 +196,58 @@ RSpec.describe NotifyService do
end
end
describe NotifyService::DismissCondition do
describe NotifyService::DropCondition do
subject { described_class.new(notification) }
let(:activity) { Fabricate(:mention, status: Fabricate(:status)) }
let(:notification) { Fabricate(:notification, type: :mention, activity: activity, from_account: activity.status.account, account: activity.account) }
describe '#dismiss?' do
context 'when sender is silenced' do
describe '#drop' do
context 'when sender is silenced and recipient has a default policy' do
before do
notification.from_account.silence!
end
it 'returns false' do
expect(subject.dismiss?).to be false
expect(subject.drop?).to be false
end
end
context 'when sender is silenced and recipient has a policy to ignore silenced accounts' do
before do
notification.from_account.silence!
notification.account.create_notification_policy!(for_limited_accounts: :drop)
end
it 'returns true' do
expect(subject.drop?).to be true
end
end
context 'when sender is new and recipient has a default policy' do
it 'returns false' do
expect(subject.drop?).to be false
end
end
context 'when sender is new and recipient has a policy to ignore silenced accounts' do
before do
notification.account.create_notification_policy!(for_new_accounts: :drop)
end
it 'returns true' do
expect(subject.drop?).to be true
end
end
context 'when sender is new and followed and recipient has a policy to ignore silenced accounts' do
before do
notification.account.create_notification_policy!(for_new_accounts: :drop)
notification.account.follow!(notification.from_account)
end
it 'returns false' do
expect(subject.drop?).to be false
end
end
@ -219,7 +257,7 @@ RSpec.describe NotifyService do
end
it 'returns true' do
expect(subject.dismiss?).to be true
expect(subject.drop?).to be true
end
end
end
@ -250,6 +288,16 @@ RSpec.describe NotifyService do
expect(subject.filter?).to be false
end
end
context 'when recipient is allowing limited accounts' do
before do
notification.account.create_notification_policy!(for_limited_accounts: :accept)
end
it 'returns false' do
expect(subject.filter?).to be false
end
end
end
context 'when recipient is filtering not-followed senders' do