destroy notifications when marked as read

This commit is contained in:
rgarcia
2016-01-07 12:02:01 +01:00
parent b5e9113718
commit e2f419e625
12 changed files with 120 additions and 84 deletions

View File

@@ -2,7 +2,7 @@ require 'rails_helper'
describe NotificationsHelper do
describe "#notification_text_for" do
describe "#notification_action" do
let(:debate) { create :debate }
let(:debate_comment) { create :comment, commentable: debate }
let(:comment_reply) { create :comment, commentable: debate, parent: debate_comment }
@@ -10,14 +10,14 @@ describe NotificationsHelper do
context "when action was comment on a debate" do
it "returns correct text when someone comments on your debate" do
notification = create :notification, notifiable: debate_comment
expect(notification_text_for(notification)).to eq "commented on your debate"
expect(notification_action(notification)).to eq "commented_on_your_debate"
end
end
context "when action was comment on a debate" do
it "returns correct text when someone replies to your comment" do
notification = create :notification, notifiable: comment_reply
expect(notification_text_for(notification)).to eq "replied to your comment on"
expect(notification_action(notification)).to eq "replied_to_your_comment"
end
end
end
@@ -25,20 +25,13 @@ describe NotificationsHelper do
describe "#notifications_class_for" do
let(:user) { create :user }
context "when user doesn't have any notification" do
context "when user doesn't have notifications" do
it "returns class 'without_notifications'" do
expect(notifications_class_for(user)).to eq "without_notifications"
end
end
context "when user doesn't have unread notifications" do
it "returns class 'without_notifications'" do
notification = create :notification, user: user, read: true
expect(notifications_class_for(user)).to eq "without_notifications"
end
end
context "when user has unread notifications" do
context "when user has notifications" do
it "returns class 'with_notifications'" do
notification = create :notification, user: user
expect(notifications_class_for(user)).to eq "with_notifications"