Merge pull request #2801 from consul/proposal_authors_notifications

Prevent authors from receiving their own proposals notification emails
This commit is contained in:
Alberto
2018-07-26 14:12:14 +02:00
committed by GitHub
3 changed files with 14 additions and 3 deletions

View File

@@ -205,7 +205,7 @@ class Proposal < ActiveRecord::Base
end
def users_to_notify
(voters + followers).uniq
(voters + followers).uniq - [author]
end
def self.proposals_orders(user)

View File

@@ -35,8 +35,6 @@
<%= activity.actionable.body %>
<% when "Newsletter" %>
<strong><%= activity.actionable.subject %></strong>
<br>
<%= activity.actionable.body %>
<% when "ProposalNotification" %>
<strong><%= activity.actionable.title %></strong>
<br>

View File

@@ -895,6 +895,19 @@ describe Proposal do
expect(proposal.users_to_notify).to eq([voter_and_follower])
end
it "returns voters and followers except the proposal author" do
author = create(:user, :level_two)
proposal = create(:proposal, author: author)
voter_and_follower = create(:user, :level_two)
create(:follow, user: author, followable: proposal)
create(:follow, user: voter_and_follower, followable: proposal)
create(:vote, voter: author, votable: proposal)
create(:vote, voter: voter_and_follower, votable: proposal)
expect(proposal.users_to_notify).to eq([voter_and_follower])
end
end
describe "#recommendations" do