removes sending individual proposal notifications via email

This commit is contained in:
rgarcia
2016-06-15 10:43:02 +02:00
parent ce6072d17b
commit 28d12fe55b
13 changed files with 1 additions and 168 deletions

View File

@@ -25,7 +25,7 @@ class AccountController < ApplicationController
if @account.organization?
params.require(:account).permit(:phone_number, :email_on_comment, :email_on_comment_reply, :newsletter, organization_attributes: [:name, :responsible_name])
else
params.require(:account).permit(:username, :public_activity, :email_on_comment, :email_on_comment_reply, :email_on_proposal_notification, :email_on_direct_message, :email_digest, :newsletter)
params.require(:account).permit(:username, :public_activity, :email_on_comment, :email_on_comment_reply, :email_on_direct_message, :email_digest, :newsletter)
end
end

View File

@@ -13,9 +13,6 @@ class ProposalNotificationsController < ApplicationController
if @notification.save
@proposal.voters.each do |voter|
Notification.add(voter.id, @notification)
if voter.email_on_proposal_notification?
Mailer.proposal_notification(@notification, voter).deliver_later
end
end
redirect_to @notification, notice: I18n.t("flash.actions.create.proposal_notification")
else

View File

@@ -42,14 +42,6 @@ class Mailer < ApplicationMailer
end
end
def proposal_notification(notification, voter)
@notification = notification
with_user(voter) do
mail(to: voter.email, subject: @notification.title + ": " + @notification.proposal.title)
end
end
def direct_message_for_receiver(direct_message)
@direct_message = direct_message
@receiver = @direct_message.receiver

View File

@@ -69,15 +69,6 @@
<% end %>
</div>
<div>
<%= f.label :email_on_proposal_notification do %>
<%= f.check_box :email_on_proposal_notification, title: t('account.show.email_on_proposal_notification_label'), label: false %>
<span class="checkbox">
<%= t("account.show.email_on_proposal_notification_label") %>
</span>
<% end %>
</div>
<div>
<%= f.label :email_digest do %>
<%= f.check_box :email_digest, title: t('account.show.email_digest_label'), label: false %>

View File

@@ -1,29 +0,0 @@
<td style="padding-bottom: 20px; padding-left: 10px;">
<h1 style="font-family: 'Open Sans','Helvetica Neue',arial,sans-serif;">
<%= @notification.proposal.title %>
</h1>
<p style="font-family: 'Open Sans','Helvetica Neue',arial,sans-serif;font-size: 14px;font-weight: normal;line-height: 24px;">
<%= @notification.body %>
</p>
<table style="width: 100%; border-top: 1px solid #DEE0E3; margin-top: 36px;">
<tbody>
<tr>
<td style="padding-bottom: 12px; padding-top: 24px; text-align: right; padding-right: 12px; width: 50%;">
<%= link_to "#comments", style: "font-family: 'Open Sans','Helvetica Neue',arial,sans-serif; background: #f7f5f2; border-radius: 6px; color: #3d3d66!important; font-weight: bold; margin: 0px; padding: 10px 15px; text-align: center; text-decoration: none; min-width: 160px; display: inline-block;" do %>
<%= image_tag('icon_mailer_share.png', style: "border: 0; display: inline-block; width: 100%; max-width: 16px", alt: "") %>
<%= t('mailers.proposal_notification.share') %>
<% end %>
</td>
<td style="padding-bottom: 12px; padding-top: 24px; text-align: left; padding-left: 12px; width: 50%;">
<%= link_to "#social-share", style: "font-family: 'Open Sans','Helvetica Neue',arial,sans-serif; background: #f7f5f2; border-radius: 6px; color: #3d3d66!important; font-weight: bold; margin: 0px; padding: 10px 15px; text-align: center; text-decoration: none; min-width: 160px; display: inline-block;" do %>
<%= image_tag('icon_mailer_comment.png', style: "border: 0; display: inline-block; width: 100%; max-width: 16px; vertical-align: middle;", alt: "") %>
<%= t('mailers.proposal_notification.comment') %>
<% end %>
</td>
</tr>
</tbody>
</table>
</td>

View File

@@ -15,7 +15,6 @@ en:
public_activity_label: Keep my list of activities public
save_changes_submit: Save changes
subscription_to_website_newsletter_label: Receive by email website relevant information
email_on_proposal_notification_label: Receive by email notifications about proposals
email_on_direct_message_label: Receive emails about direct messages
email_digest_label: Receive a summary of proposal notifications
title: My account

View File

@@ -15,7 +15,6 @@ es:
public_activity_label: Mostrar públicamente mi lista de actividades
save_changes_submit: Guardar cambios
subscription_to_website_newsletter_label: Recibir emails con información interesante sobre la web
email_on_proposal_notification_label: Recibir emails con notificaciones sobre propuestas
email_on_direct_message_label: Recibir emails con mensajes directos
email_digest_label: Recibir resumen de notificaciones sobre propuestas
title: Mi cuenta

View File

@@ -30,9 +30,6 @@ en:
sorry: "Sorry for the inconvenience and we again thank you for your invaluable participation."
subject: "Your investment project '%{code}' has been marked as unfeasible"
unfeasible_html: "From the Madrid City Council we want to thank you for your participation in the <strong>participatory budgets of the city of Madrid</strong>. We regret to inform you that your proposal <strong>'%{title}'</strong> will be excluded from this participatory process for the following reason:"
proposal_notification:
share: Share
comment: Comment proposal
proposal_notification_digest:
title: You received the following notifications
share: Share

View File

@@ -30,9 +30,6 @@ es:
sorry: "Sentimos las molestias ocasionadas y volvemos a darte las gracias por tu inestimable participación."
subject: "Tu propuesta de inversión '%{code}' ha sido marcada como inviable"
unfeasible_html: "Desde el Ayuntamiento de Madrid queremos agradecer tu participación en los <strong>Presupuestos Participativos de la ciudad de Madrid</strong>. Lamentamos informarte de que tu propuesta <strong>'%{title}'</strong> quedará excluida de este proceso participativo por el siguiente motivo:"
proposal_notification:
share: Compartir
comment: Comentar propuesta
proposal_notification_digest:
title: Has recibido las siguientes notificaciones
share: Compartir

View File

@@ -35,7 +35,6 @@ feature 'Account' do
fill_in 'account_username', with: 'Larry Bird'
check 'account_email_on_comment'
check 'account_email_on_comment_reply'
uncheck 'account_email_on_proposal_notification'
uncheck 'account_email_digest'
uncheck 'account_email_on_direct_message'
click_button 'Save changes'

View File

@@ -183,62 +183,6 @@ feature 'Emails' do
end
context "Proposal notifications" do
scenario "Proposal notification" do
author = create(:user)
noelia = create(:user)
vega = create(:user)
cristina = create(:user)
proposal = create(:proposal, author: author)
create(:vote, voter: noelia, votable: proposal, vote_flag: true)
create(:vote, voter: vega, votable: proposal, vote_flag: true)
reset_mailer
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."
expect(unread_emails_for(noelia.email).size).to eql parse_email_count(1)
expect(unread_emails_for(vega.email).size).to eql parse_email_count(1)
expect(unread_emails_for(cristina.email).size).to eql parse_email_count(0)
expect(unread_emails_for(author.email).size).to eql parse_email_count(0)
email = open_last_email
expect(email).to have_subject("Thank you for supporting my proposal: #{proposal.title}")
expect(email).to have_body_text("Please share it with others so we can make it happen!")
expect(email).to have_body_text(proposal.title)
end
scenario "Do not send email about proposal notifications unless set in preferences", :js do
author = create(:user)
voter = create(:user, email_on_proposal_notification: false)
proposal = create(:proposal, author: author)
create(:vote, voter: voter, votable: proposal, vote_flag: true)
login_as(author)
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 { open_last_email }.to raise_error "No email has been sent!"
end
end
context "Proposal notification digest" do
scenario "notifications for proposals that I have supported" do

View File

@@ -51,53 +51,6 @@ feature 'Proposal Notifications' do
expect(page).to have_link("the proposal's page", href: proposal_path(proposal))
end
context "Receivers" do
scenario "Only send a digest to users that have the option set in their profile" do
user1 = create(:user, email_digest: true)
user2 = create(:user, email_digest: true)
user3 = create(:user, email_digest: false)
proposal = create(:proposal)
[user1, user2, user3].each do |user|
create(:vote, votable: proposal, voter: user)
end
create_proposal_notification(proposal)
reset_mailer
email_digest = EmailDigest.new
email_digest.create
expect(unread_emails_for(user1.email).size).to eql parse_email_count(1)
expect(unread_emails_for(user2.email).size).to eql parse_email_count(1)
expect(unread_emails_for(user3.email).size).to eql parse_email_count(0)
end
scenario "Only send a digest to users that have voted for a proposal" do
user1 = create(:user, email_digest: true)
user2 = create(:user, email_digest: true)
user3 = create(:user, email_digest: true)
proposal = create(:proposal)
[user1, user2].each do |user|
create(:vote, votable: proposal, voter: user)
end
create_proposal_notification(proposal)
reset_mailer
email_digest = EmailDigest.new
email_digest.create
expect(unread_emails_for(user1.email).size).to eql parse_email_count(1)
expect(unread_emails_for(user2.email).size).to eql parse_email_count(1)
expect(unread_emails_for(user3.email).size).to eql parse_email_count(0)
end
end
context "Permissions" do
scenario "Link to send the message" do

View File

@@ -84,12 +84,6 @@ describe User do
end
end
describe 'email_on_proposal_notification' do
it 'should be true by default' do
expect(subject.email_on_proposal_notification).to eq(true)
end
end
describe 'email_digest' do
it 'should be true by default' do
expect(subject.email_digest).to eq(true)