2024-03-07 14:53:37 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe NotificationRequest do
|
|
|
|
describe '#reconsider_existence!' do
|
2024-07-12 12:09:52 +00:00
|
|
|
subject { Fabricate(:notification_request) }
|
2024-03-07 14:53:37 +00:00
|
|
|
|
|
|
|
context 'when there are remaining notifications' do
|
|
|
|
before do
|
2024-08-07 11:12:36 +00:00
|
|
|
Fabricate(:notification, account: subject.account, activity: Fabricate(:status, account: subject.from_account), filtered: true, type: :mention)
|
2024-03-07 14:53:37 +00:00
|
|
|
subject.reconsider_existence!
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'leaves request intact' do
|
|
|
|
expect(subject.destroyed?).to be false
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'updates notifications_count' do
|
|
|
|
expect(subject.notifications_count).to eq 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when there are no notifications' do
|
|
|
|
before do
|
|
|
|
subject.reconsider_existence!
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'removes the request' do
|
|
|
|
expect(subject.destroyed?).to be true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|