marcar notificaciones como leidas despues de ser vistas

This commit is contained in:
Julian Herrero
2015-10-06 20:48:46 +02:00
committed by rgarcia
parent d9ba3edc2a
commit 9a5f525dc9
4 changed files with 25 additions and 5 deletions

View File

@@ -4,13 +4,18 @@ describe NotificationsController do
describe "#index" do
let(:user) { create :user }
let(:notification) { create :notification, user: user }
it "assigns @notifications" do
it "mark all notifications as read" do
notifications = [create(:notification, user: user), create(:notification, user: user)]
Notification.all.each do |notification|
expect(notification.read).to be false
end
sign_in user
get :index, debate: { title: 'A sample debate', description: 'this is a sample debate', terms_of_service: 1 }
expect(assigns(:notifications)).to eq user.notifications.unread.recent.for_render
get :index
Notification.all.each do |notification|
expect(notification.read).to be true
end
end
end
end