2024-03-07 23:53:37 +09: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-10 02:29:02 +09:00
|
|
|
let(:suspended_sender) { Fabricate(:account) }
|
2024-03-07 23:53:37 +09:00
|
|
|
|
|
|
|
before do
|
2024-08-07 20:12:36 +09:00
|
|
|
Fabricate.times(2, :notification, account: subject.account, activity: Fabricate(:status, account: sender), filtered: true, type: :mention)
|
2024-03-07 23:53:37 +09:00
|
|
|
Fabricate(:notification_request, account: subject.account, from_account: sender)
|
|
|
|
|
2024-10-10 02:29:02 +09: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 23:53:37 +09:00
|
|
|
end
|
|
|
|
|
2024-10-10 02:29:02 +09: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 23:53:37 +09:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|