accept_notification_request_service_spec.rb 917 B

1234567891011121314151617181920
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe AcceptNotificationRequestService do
  4. subject { described_class.new }
  5. let(:notification_request) { Fabricate(:notification_request) }
  6. describe '#call' do
  7. it 'destroys the notification request, creates a permission, increases the jobs count and queues a worker' do
  8. expect { subject.call(notification_request) }
  9. .to change { NotificationRequest.exists?(notification_request.id) }.to(false)
  10. .and change { NotificationPermission.exists?(account_id: notification_request.account_id, from_account_id: notification_request.from_account_id) }.to(true)
  11. .and change { redis.get("notification_unfilter_jobs:#{notification_request.account_id}").to_i }.by(1)
  12. expect(UnfilterNotificationsWorker).to have_enqueued_sidekiq_job(notification_request.account_id, notification_request.from_account_id)
  13. end
  14. end
  15. end