1
0

notification_request_spec.rb 884 B

12345678910111213141516171819202122232425262728293031323334
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe NotificationRequest do
  4. describe '#reconsider_existence!' do
  5. subject { Fabricate(:notification_request) }
  6. context 'when there are remaining notifications' do
  7. before do
  8. Fabricate(:notification, account: subject.account, activity: Fabricate(:status, account: subject.from_account), filtered: true, type: :mention)
  9. subject.reconsider_existence!
  10. end
  11. it 'leaves request intact' do
  12. expect(subject.destroyed?).to be false
  13. end
  14. it 'updates notifications_count' do
  15. expect(subject.notifications_count).to eq 1
  16. end
  17. end
  18. context 'when there are no notifications' do
  19. before do
  20. subject.reconsider_existence!
  21. end
  22. it 'removes the request' do
  23. expect(subject.destroyed?).to be true
  24. end
  25. end
  26. end
  27. end