2024-03-07 14:53:37 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe NotificationPolicy do
|
|
|
|
describe '#summarize!' do
|
|
|
|
subject { Fabricate(:notification_policy) }
|
|
|
|
|
|
|
|
let(:sender) { Fabricate(:account) }
|
2024-10-09 17:29:02 +00:00
|
|
|
let(:suspended_sender) { Fabricate(:account) }
|
2024-03-07 14:53:37 +00:00
|
|
|
|
|
|
|
before do
|
2024-08-07 11:12:36 +00:00
|
|
|
Fabricate.times(2, :notification, account: subject.account, activity: Fabricate(:status, account: sender), filtered: true, type: :mention)
|
2024-03-07 14:53:37 +00:00
|
|
|
Fabricate(:notification_request, account: subject.account, from_account: sender)
|
|
|
|
|
2024-10-09 17:29:02 +00:00
|
|
|
Fabricate(:notification, account: subject.account, activity: Fabricate(:status, account: suspended_sender), filtered: true, type: :mention)
|
|
|
|
Fabricate(:notification_request, account: subject.account, from_account: suspended_sender)
|
|
|
|
|
|
|
|
suspended_sender.suspend!
|
|
|
|
|
|
|
|
subject.summarize!
|
2024-03-07 14:53:37 +00:00
|
|
|
end
|
|
|
|
|
2024-10-09 17:29:02 +00:00
|
|
|
it 'sets pending_requests_count and pending_notifications_count' do
|
|
|
|
expect(subject).to have_attributes(
|
|
|
|
pending_requests_count: 1,
|
|
|
|
pending_notifications_count: 2
|
|
|
|
)
|
2024-03-07 14:53:37 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|