Change dismissing a notification to clear existing filtered notifications for that account (#31329)
This commit is contained in:
parent
6f285bb2a6
commit
670e4655d1
5 changed files with 61 additions and 1 deletions
24
spec/workers/filtered_notification_cleanup_worker_spec.rb
Normal file
24
spec/workers/filtered_notification_cleanup_worker_spec.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe FilteredNotificationCleanupWorker do
|
||||
describe '#perform' do
|
||||
let(:sender) { Fabricate(:account) }
|
||||
let(:recipient) { Fabricate(:account) }
|
||||
let(:bystander) { Fabricate(:account) }
|
||||
|
||||
before do
|
||||
Fabricate(:notification, account: recipient, activity: Fabricate(:favourite, account: sender), filtered: true)
|
||||
Fabricate(:notification, account: recipient, activity: Fabricate(:favourite, account: bystander), filtered: true)
|
||||
Fabricate(:notification, account: recipient, activity: Fabricate(:follow, account: sender), filtered: true)
|
||||
Fabricate(:notification, account: recipient, activity: Fabricate(:favourite, account: bystander), filtered: true)
|
||||
end
|
||||
|
||||
it 'deletes all filtered notifications to the account' do
|
||||
expect { described_class.new.perform(recipient.id, sender.id) }
|
||||
.to change { recipient.notifications.where(from_account: sender).count }.from(2).to(0)
|
||||
.and(not_change { recipient.notifications.where(from_account: bystander).count })
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue