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

@@ -21,10 +21,10 @@ feature "Notifications" do
expect(page).to have_xpath "//a[@class='with_notifications' and @href='#{notifications_path}' and text()='Notificaciones']"
click_link "Notificaciones"
expect(page).to have_css ".notification", count: 1
expect(page).to have_content user.username
expect(page).to have_content I18n.t("comments.notifications.commented_on_your_debate")
expect(page).to_not have_content I18n.t("comments.notifications.replied_to_your_comment")
expect(page).to have_link debate.title, href: debate_path(debate)
expect(page).to have_content "commented on your debate"
expect(page).to have_xpath "//a[@href='#{notification_path(Notification.last)}']"
end
scenario "User replied to my comment", :js do
@@ -48,10 +48,10 @@ feature "Notifications" do
expect(page).to have_xpath "//a[@class='with_notifications' and @href='#{notifications_path}' and text()='Notificaciones']"
visit notifications_path
expect(page).to have_css ".notification", count: 1
expect(page).to have_content user.username
expect(page).to have_content I18n.t("comments.notifications.replied_to_your_comment")
expect(page).to_not have_content I18n.t("comments.notifications.commented_on_your_debate")
expect(page).to have_link debate.title, href: debate_path(debate)
expect(page).to have_content "replied to your comment on"
expect(page).to have_xpath "//a[@href='#{notification_path(Notification.last)}']"
end
scenario "Author commented on his own debate", :js do
@@ -66,10 +66,7 @@ feature "Notifications" do
expect(page).to have_xpath "//a[@class='without_notifications' and @href='#{notifications_path}' and text()='Notificaciones']"
click_link "Notificaciones"
expect(page).to_not have_content user.username
expect(page).to_not have_content I18n.t("comments.notifications.commented_on_your_debate")
expect(page).to_not have_content I18n.t("comments.notifications.replied_to_your_comment")
expect(page).to_not have_link debate.title, href: debate_path(debate)
expect(page).to have_css ".notification", count: 0
end
scenario "Author replied to his own comment", :js do
@@ -89,9 +86,47 @@ feature "Notifications" do
expect(page).to have_xpath "//a[@class='without_notifications' and @href='#{notifications_path}' and text()='Notificaciones']"
visit notifications_path
expect(page).to_not have_content user.username
expect(page).to_not have_content I18n.t("comments.notifications.replied_to_your_comment")
expect(page).to_not have_content I18n.t("comments.notifications.commented_on_your_debate")
expect(page).to_not have_link debate.title, href: debate_path(debate)
expect(page).to have_css ".notification", count: 0
end
context "mark as read" do
scenario "mark a single notification as read" do
user = create :user
notification = create :notification, user: user
login_as user
visit notifications_path
expect(page).to have_css ".notification", count: 1
first(".notification a").click
visit notifications_path
expect(page).to have_css ".notification", count: 0
end
scenario "mark all notifications as read" do
user = create :user
2.times { create :notification, user: user }
login_as user
visit notifications_path
expect(page).to have_css ".notification", count: 2
click_link "Mark all as read"
expect(page).to have_css ".notification", count: 0
expect(current_path).to eq(notifications_path)
end
end
scenario "no notifications" do
login_as user
visit notifications_path
expect(page).to have_content "There are no new notifications"
end
end