diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 496778e5f..9212eb4fa 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -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 diff --git a/app/controllers/proposal_notifications_controller.rb b/app/controllers/proposal_notifications_controller.rb index 1fcd9322a..fc9cdf3d8 100644 --- a/app/controllers/proposal_notifications_controller.rb +++ b/app/controllers/proposal_notifications_controller.rb @@ -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 diff --git a/app/mailers/mailer.rb b/app/mailers/mailer.rb index 6916253f2..5f7dc5391 100644 --- a/app/mailers/mailer.rb +++ b/app/mailers/mailer.rb @@ -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 diff --git a/app/views/account/show.html.erb b/app/views/account/show.html.erb index 3d93bc705..98987626d 100644 --- a/app/views/account/show.html.erb +++ b/app/views/account/show.html.erb @@ -69,15 +69,6 @@ <% end %> -
- <%= 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 %> - - <%= t("account.show.email_on_proposal_notification_label") %> - - <% end %> -
-
<%= f.label :email_digest do %> <%= f.check_box :email_digest, title: t('account.show.email_digest_label'), label: false %> diff --git a/app/views/mailer/proposal_notification.html.erb b/app/views/mailer/proposal_notification.html.erb deleted file mode 100644 index 04ca39d86..000000000 --- a/app/views/mailer/proposal_notification.html.erb +++ /dev/null @@ -1,29 +0,0 @@ - -

- <%= @notification.proposal.title %> -

- -

- <%= @notification.body %> -

- - - - - - - - - -
- <%= 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 %> - - <%= 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 %> -
- diff --git a/config/locales/en.yml b/config/locales/en.yml index de1f1a485..e78f9c4d0 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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 diff --git a/config/locales/es.yml b/config/locales/es.yml index c5fa39c91..592bc9213 100755 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -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 diff --git a/config/locales/mailers.en.yml b/config/locales/mailers.en.yml index ec6e7f45c..7270f81ae 100755 --- a/config/locales/mailers.en.yml +++ b/config/locales/mailers.en.yml @@ -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 participatory budgets of the city of Madrid. We regret to inform you that your proposal '%{title}' 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 diff --git a/config/locales/mailers.es.yml b/config/locales/mailers.es.yml index 4defbd1ed..288fa189e 100644 --- a/config/locales/mailers.es.yml +++ b/config/locales/mailers.es.yml @@ -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 Presupuestos Participativos de la ciudad de Madrid. Lamentamos informarte de que tu propuesta '%{title}' 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 diff --git a/spec/features/account_spec.rb b/spec/features/account_spec.rb index b41d676d4..0d5da38b2 100644 --- a/spec/features/account_spec.rb +++ b/spec/features/account_spec.rb @@ -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' diff --git a/spec/features/emails_spec.rb b/spec/features/emails_spec.rb index 237444f85..3ea8f16b9 100644 --- a/spec/features/emails_spec.rb +++ b/spec/features/emails_spec.rb @@ -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 diff --git a/spec/features/proposal_notifications_spec.rb b/spec/features/proposal_notifications_spec.rb index 7785a1236..be8b146fd 100644 --- a/spec/features/proposal_notifications_spec.rb +++ b/spec/features/proposal_notifications_spec.rb @@ -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 diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 698c4884c..143053c77 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -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)