docbrown/spec/workers/notifications/welcome_notification_worker_spec.rb
Vaidehi Joshi a3d12e03a3
Add set_up_profile notification, check for active broadcasts (#7054) [deploy]
* Replace current onboarding notification with set_up_profile welcome notification

Also ensure that only "active" set_up_profile welcome notification is sent, and that "inactive" ones are ignored.

* Notify only if broadcast active, log error if broadcast not found

* Reports to Honeybadger if an active broadcast cannot be found

* Reorganize order of generator specs

* Ensure welcome_broadcast can be written to in spec

* Remove redundant spec
2020-04-02 15:56:29 -07:00

39 lines
1.1 KiB
Ruby

require "rails_helper"
RSpec.describe Notifications::WelcomeNotificationWorker, type: :worker do
describe "#perform" do
let(:broadcast) { create(:set_up_profile_broadcast) }
let(:inactive_broadcast) { create(:set_up_profile_broadcast, active: false) }
let(:user) { create(:user) }
let(:service) { Notifications::WelcomeNotification::Send }
let(:worker) { subject }
before do
allow(service).to receive(:call)
end
context "with an active broadcast" do
it "calls a service" do
worker.perform(user.id, broadcast.id)
expect(service).to have_received(:call).with(user.id, broadcast).once
end
end
context "with an inactive broadcast" do
it "does not call a service" do
worker.perform(user.id, inactive_broadcast.id)
expect(service).not_to have_received(:call)
end
end
context "when there is a non-existent broadcast" do
before do
broadcast.destroy
end
it "does nothing" do
worker.perform(user.id, broadcast.id)
expect(service).not_to have_received(:call)
end
end
end
end