Add test for marking all notifications as read

This commit is contained in:
Karina Kwiatek 2023-03-10 21:36:43 +01:00
parent 0db44949e6
commit b5a72be288
1 changed files with 21 additions and 0 deletions

View File

@ -40,4 +40,25 @@ describe NotificationsController do
end
end
end
describe "#read" do
subject { post :read, format: :turbo_stream }
let(:recipient) { FactoryBot.create(:user) }
let(:notification_count) { rand(8..20) }
context "user has some unread notifications" do
before do
notification_count.times do
FactoryBot.create(:user).follow(recipient)
end
sign_in(recipient)
end
it "marks all notifications as read" do
expect { subject }.to change { Notification.where(recipient:, new: true).count }.from(notification_count).to(0)
end
end
end
end