Test for sending notifications for new questions

This commit is contained in:
Karina Kwiatek 2022-12-23 13:03:28 +00:00
parent 8c2bfcb452
commit 44112c5449
1 changed files with 33 additions and 3 deletions

View File

@ -63,5 +63,35 @@ describe QuestionWorker do
.to(4) .to(4)
) )
end end
context "receiver has push notifications enabled" do
let(:receiver) { FactoryBot.create(:user) }
before do
Rpush::Webpush::App.create(
name: "webpush",
certificate: { public_key: "AAAA", private_key: "AAAA", subject: "" }.to_json,
connections: 1,
)
WebPushSubscription.create!(
user: receiver,
subscription: {
endpoint: "This will not be used",
keys: {},
},
)
receiver.follow(user)
end
it "sends notifications" do
expect { subject }
.to(
change { Rpush::Webpush::Notification.count }
.from(0)
.to(1)
)
end
end
end end
end end