adds notifications for proposals

This commit is contained in:
rgarcia
2016-06-07 22:03:14 +02:00
parent ea90869114
commit a0ddde16e9
8 changed files with 95 additions and 4 deletions

View File

@@ -149,6 +149,64 @@ feature "Notifications" do
expect(page).to have_css ".notification", count: 0
end
context "Proposal notification" do
scenario "Voters should receive a notification", :js do
author = create(:user)
user1 = create(:user)
user2 = create(:user)
user3 = create(:user)
proposal = create(:proposal, author: author)
create(:vote, voter: user1, votable: proposal, vote_flag: true)
create(:vote, voter: user2, votable: proposal, vote_flag: true)
login_as(author)
visit root_path
visit new_proposal_notification_path(proposal_id: proposal.id)
fill_in 'proposal_notification_title', with: "Thank you for supporting my proposal"
fill_in 'proposal_notification_body', with: "Please share it with others so we can make it happen!"
click_button "Send message"
expect(page).to have_content "Your message has been sent correctly."
logout
login_as user1
visit root_path
find(".icon-notification").click
expect(page).to have_css ".notification", count: 1
expect(page).to have_content "There is one new notification on #{proposal.title}"
expect(page).to have_xpath "//a[@href='#{notification_path(Notification.last)}']"
logout
login_as user2
visit root_path
find(".icon-notification").click
expect(page).to have_css ".notification", count: 1
expect(page).to have_content "There is one new notification on #{proposal.title}"
expect(page).to have_xpath "//a[@href='#{notification_path(Notification.first)}']"
logout
login_as user3
visit root_path
find(".icon-no-notification").click
expect(page).to have_css ".notification", count: 0
end
pending "group notifications for the same proposal"
end
context "mark as read" do
scenario "mark a single notification as read" do