notification_policy_spec.rb 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe NotificationPolicy do
  4. describe '#summarize!' do
  5. subject { Fabricate(:notification_policy) }
  6. let(:sender) { Fabricate(:account) }
  7. let(:suspended_sender) { Fabricate(:account) }
  8. before do
  9. Fabricate.times(2, :notification, account: subject.account, activity: Fabricate(:status, account: sender), filtered: true, type: :mention)
  10. Fabricate(:notification_request, account: subject.account, from_account: sender)
  11. Fabricate(:notification, account: subject.account, activity: Fabricate(:status, account: suspended_sender), filtered: true, type: :mention)
  12. Fabricate(:notification_request, account: subject.account, from_account: suspended_sender)
  13. suspended_sender.suspend!
  14. subject.summarize!
  15. end
  16. it 'sets pending_requests_count and pending_notifications_count' do
  17. expect(subject).to have_attributes(
  18. pending_requests_count: 1,
  19. pending_notifications_count: 2
  20. )
  21. end
  22. end
  23. end