Support creates follow (Merge pull request #3895)

* Supporting a proposal will create a follow relationship
* Only followers receive notifications
This commit is contained in:
Andy Sims
2020-04-06 23:26:47 +10:00
committed by GitHub
parent 14106ce800
commit 74fbde09f1
17 changed files with 44 additions and 48 deletions

View File

@@ -14,7 +14,7 @@ describe "Proposal Notifications" do
click_link "Message to users"
end
click_link "Send message to proposal supporters"
click_link "Send message to proposal followers"
fill_in "proposal_notification_title", with: "Thank you for supporting my proposal"
fill_in "proposal_notification_body", with: "Please share it with "\
@@ -29,7 +29,7 @@ describe "Proposal Notifications" do
scenario "Send a notification (Active voter)" do
proposal = create(:proposal)
create(:user, :level_two, votables: [proposal])
create(:user, :level_two, votables: [proposal], followables: [proposal])
create_proposal_notification(proposal)
expect(Notification.count).to eq(1)
@@ -93,21 +93,6 @@ describe "Proposal Notifications" do
expect(page).to have_content "We are almost there please share with your peoples!"
end
scenario "Message about receivers (Voters)" do
author = create(:user)
proposal = create(:proposal, author: author)
7.times { create(:vote, votable: proposal, vote_flag: true) }
login_as(author)
visit new_proposal_notification_path(proposal_id: proposal.id)
expect(page).to have_content "This message will be sent to 7 people and it will "\
"be visible in the proposal's page"
expect(page).to have_link("the proposal's page", href: proposal_path(proposal,
anchor: "comments"))
end
scenario "Message about receivers (Followers)" do
author = create(:user)
proposal = create(:proposal, author: author)
@@ -133,7 +118,7 @@ describe "Proposal Notifications" do
login_as(author)
visit new_proposal_notification_path(proposal_id: proposal.id)
expect(page).to have_content "This message will be sent to 14 people and it will "\
expect(page).to have_content "This message will be sent to 7 people and it will "\
"be visible in the proposal's page"
expect(page).to have_link("the proposal's page", href: proposal_path(proposal,
anchor: "comments"))
@@ -172,7 +157,7 @@ describe "Proposal Notifications" do
click_link "Message to users"
end
expect(page).to have_link "Send message to proposal supporters"
expect(page).to have_link "Send message to proposal followers"
end
scenario "Accessing form directly" do
@@ -189,13 +174,13 @@ describe "Proposal Notifications" do
end
context "In-app notifications from the proposal's author" do
scenario "Voters should receive a notification", :js do
scenario "Voters who are followed should receive a notification", :js do
author = create(:user)
proposal = create(:proposal, author: author)
user1 = create(:user, votables: [proposal])
user2 = create(:user, votables: [proposal])
user3 = create(:user)
user1 = create(:user, votables: [proposal], followables: [proposal])
user2 = create(:user, votables: [proposal], followables: [proposal])
user3 = create(:user, votables: [proposal])
login_as(author)
visit root_path
@@ -297,7 +282,7 @@ describe "Proposal Notifications" do
scenario "Proposal hidden", :js do
author = create(:user)
user = create(:user)
proposal = create(:proposal, author: author, voters: [user])
proposal = create(:proposal, author: author, voters: [user], followers: [user])
login_as(author)
visit root_path