Remove unused task to send dashboard notifications
This task was "temporarily" removed in commit 7b6619528. Since that was
done three and a half years ago, right after the dashboard was
introduced, I think it's time to make this "temporary" measure a bit
more permanent ;).
This commit is contained in:
@@ -7,20 +7,6 @@ class Dashboard::Mailer < ApplicationMailer
|
|||||||
mail to: proposal.author.email, subject: proposal.title
|
mail to: proposal.author.email, subject: proposal.title
|
||||||
end
|
end
|
||||||
|
|
||||||
def new_actions_notification_rake_published(proposal, new_actions_ids)
|
|
||||||
@proposal = proposal
|
|
||||||
@new_actions = get_new_actions(new_actions_ids)
|
|
||||||
mail to: proposal.author.email,
|
|
||||||
subject: I18n.t("mailers.new_actions_notification_rake_published.subject")
|
|
||||||
end
|
|
||||||
|
|
||||||
def new_actions_notification_rake_created(proposal, new_actions_ids)
|
|
||||||
@proposal = proposal
|
|
||||||
@new_actions = get_new_actions(new_actions_ids)
|
|
||||||
mail to: proposal.author.email,
|
|
||||||
subject: I18n.t("mailers.new_actions_notification_rake_created.subject")
|
|
||||||
end
|
|
||||||
|
|
||||||
def new_actions_notification_on_create(proposal)
|
def new_actions_notification_on_create(proposal)
|
||||||
@proposal = proposal
|
@proposal = proposal
|
||||||
mail to: proposal.author.email,
|
mail to: proposal.author.email,
|
||||||
|
|||||||
@@ -1,73 +0,0 @@
|
|||||||
<td style="padding-bottom: 20px;padding-left: 10px;font-size: 14px;font-weight: normal;
|
|
||||||
font-family:'Open Sans',arial,sans-serif;line-height: 24px; text-align: justify;">
|
|
||||||
|
|
||||||
<p><%= t("mailers.new_actions_notification_rake_created.hi", name: @proposal.author.name) %></p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<%= t("mailers.new_actions_notification_rake_created.introduction",
|
|
||||||
created_at_day: @proposal.created_at.day,
|
|
||||||
created_at_month: @proposal.created_at.strftime("%B"),
|
|
||||||
title: @proposal.title) %>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<%= sanitize(t("mailers.new_actions_notification_rake_created.text_1",
|
|
||||||
link_to_published: link_to(proposal_dashboard_url(@proposal),
|
|
||||||
proposal_dashboard_url(@proposal)))) %>
|
|
||||||
</p>
|
|
||||||
<p><%= t("mailers.new_actions_notification_rake_created.text_2") %></p>
|
|
||||||
<br>
|
|
||||||
<p><%= t("mailers.new_actions_notification_rake_created.text_3") %></p>
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
<% first_resource = @new_actions.resources.first %>
|
|
||||||
<% if first_resource.present? %>
|
|
||||||
<strong><%= t("mailers.new_actions_notification_rake_created.new_resource") %></strong>
|
|
||||||
<ul>
|
|
||||||
<li><%= first_resource.title %></li>
|
|
||||||
</ul>
|
|
||||||
<br>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<% first_proposed_action = @new_actions.proposed_actions.first %>
|
|
||||||
<% if first_proposed_action.present? %>
|
|
||||||
<p><%= t("mailers.new_actions_notification_rake_created.text_4") %></p>
|
|
||||||
<ul>
|
|
||||||
<li><%= first_proposed_action.title %></li>
|
|
||||||
<% if first_proposed_action.description.present? %>
|
|
||||||
<p><%= wysiwyg(first_proposed_action.description) %></p>
|
|
||||||
<% end %>
|
|
||||||
</ul>
|
|
||||||
<br>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<% if @new_actions.proposed_actions.count > 1 %>
|
|
||||||
<% second_proposed_action = @new_actions.proposed_actions.second %>
|
|
||||||
<p><%= t("mailers.new_actions_notification_rake_created.text_5") %></p>
|
|
||||||
<ul>
|
|
||||||
<li><%= second_proposed_action.title %></li>
|
|
||||||
</ul>
|
|
||||||
<br>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<p><%= t("mailers.new_actions_notification_rake_created.footer_text") %></p>
|
|
||||||
|
|
||||||
<br>
|
|
||||||
<table style="width: 100%;">
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td style="padding-bottom: 12px; padding-top: 24px; text-align: center;">
|
|
||||||
<%= link_to proposal_dashboard_url(@proposal),
|
|
||||||
style: "font-family: 'Open Sans',arial,sans-serif; background: #3700fd;
|
|
||||||
border-radius: 6px; color: #fff !important; font-weight: bold;
|
|
||||||
padding: 17px 20px; text-align: center; text-decoration: none;
|
|
||||||
font-size: 20px; min-width: 200px; display: inline-block;",
|
|
||||||
target: "_blank" do %>
|
|
||||||
<%= t("mailers.new_actions_notification_rake_created.dashboard_button") %>
|
|
||||||
<% end %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
</td>
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
<td style="padding-bottom: 20px;padding-left: 10px;font-size: 14px;font-weight: normal;
|
|
||||||
font-family:'Open Sans',arial,sans-serif;line-height: 24px; text-align: justify;">
|
|
||||||
|
|
||||||
<p><%= t("mailers.new_actions_notification_rake_published.hi", name: @proposal.author.name) %></p>
|
|
||||||
<p>
|
|
||||||
<%= t("mailers.new_actions_notification_rake_published.introduction",
|
|
||||||
published_at_day: @proposal.published_at.day,
|
|
||||||
published_at_month: @proposal.published_at.strftime("%B"),
|
|
||||||
title: @proposal.title) %>
|
|
||||||
</p>
|
|
||||||
<br>
|
|
||||||
<% first_resource = @new_actions.resources.first %>
|
|
||||||
<% if first_resource.present? %>
|
|
||||||
<p><%= t("mailers.new_actions_notification_rake_published.text_1", votes_count: @proposal.cached_votes_up) %></p>
|
|
||||||
<br>
|
|
||||||
<p><%= t("mailers.new_actions_notification_rake_published.text_2") %></p>
|
|
||||||
<br>
|
|
||||||
<p><%= t("mailers.new_actions_notification_rake_published.new_resource") %></p>
|
|
||||||
<ul>
|
|
||||||
<li><%= first_resource.title %></li>
|
|
||||||
</ul>
|
|
||||||
<br>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<% limit_to_archive_proposal = @proposal.created_at.to_date +
|
|
||||||
Setting["months_to_archive_proposals"].to_i.months %>
|
|
||||||
<p>
|
|
||||||
<%= t("mailers.new_actions_notification_rake_published.text_3",
|
|
||||||
days_count: (limit_to_archive_proposal - Date.current).to_i,
|
|
||||||
max_votes_count: Setting["votes_for_proposal_success"]) %>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<% first_proposed_action = @new_actions.proposed_actions.first %>
|
|
||||||
<% if first_proposed_action.present? %>
|
|
||||||
<p><%= t("mailers.new_actions_notification_rake_published.text_4") %></p>
|
|
||||||
<ul>
|
|
||||||
<li><%= first_proposed_action.title %></li>
|
|
||||||
<% if first_proposed_action.description.present? %>
|
|
||||||
<p><%= wysiwyg(first_proposed_action.description) %></p>
|
|
||||||
<% end %>
|
|
||||||
</ul>
|
|
||||||
<br>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<% if @new_actions.proposed_actions.count > 1 %>
|
|
||||||
<% second_proposed_action = @new_actions.proposed_actions.second %>
|
|
||||||
<p><%= t("mailers.new_actions_notification_rake_published.text_5") %></p>
|
|
||||||
<ul>
|
|
||||||
<li><%= second_proposed_action.title %></li>
|
|
||||||
</ul>
|
|
||||||
<br>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<p><%= t("mailers.new_actions_notification_rake_published.footer_text") %></p>
|
|
||||||
|
|
||||||
<br>
|
|
||||||
<table style="width: 100%;">
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td style="padding-bottom: 12px; padding-top: 24px; text-align: center;">
|
|
||||||
<%= link_to proposal_dashboard_url(@proposal),
|
|
||||||
style: "font-family: 'Open Sans',arial,sans-serif; background: #3700fd;
|
|
||||||
border-radius: 6px; color: #fff !important; font-weight: bold;
|
|
||||||
padding: 17px 20px; text-align: center; text-decoration: none;
|
|
||||||
font-size: 20px; min-width: 200px; display: inline-block;",
|
|
||||||
target: "_blank" do %>
|
|
||||||
<%= t("mailers.new_actions_notification_rake_published.dashboard_button") %>
|
|
||||||
<% end %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
</td>
|
|
||||||
@@ -96,30 +96,6 @@ en:
|
|||||||
subject: "Machine Learning - Content has been generated successfully"
|
subject: "Machine Learning - Content has been generated successfully"
|
||||||
text: "Content has been generated successfully."
|
text: "Content has been generated successfully."
|
||||||
title: "Machine Learning script"
|
title: "Machine Learning script"
|
||||||
new_actions_notification_rake_created:
|
|
||||||
subject: "More news about your citizen proposal"
|
|
||||||
hi: "Hello %{name},"
|
|
||||||
new_resource: "NEW UNLOCKED RESOURCE"
|
|
||||||
introduction: "As you know, on the %{created_at_day} day of the %{created_at_month} you created the proposal in draft mode %{title}."
|
|
||||||
text_1: "Whenever you want you can publish on this link: %{link_to_published}. If you're still not sure..."
|
|
||||||
text_2: "Seize this moment! Learn, add other people with the same interests and prepare the diffusion that you will need when you publish your proposal definitively."
|
|
||||||
text_3: "And to accompany you in this challenge, here are the news..."
|
|
||||||
text_4: "Take a look at this NEW recommended ACTION:"
|
|
||||||
text_5: "The next action we recommend is:"
|
|
||||||
footer_text: "As always, enter the Proposals Panel and we will tell you in detail how to use these resources and how to get the most out of it."
|
|
||||||
dashboard_button: "Go ahead, discover them!"
|
|
||||||
new_actions_notification_rake_published:
|
|
||||||
subject: "More news about your citizen proposal"
|
|
||||||
hi: "Hello %{name},"
|
|
||||||
new_resource: "NEW UNLOCKED RESOURCE"
|
|
||||||
introduction: "As you know, on the %{published_at_day} day of the %{published_at_month} you published the proposal %{title}."
|
|
||||||
text_1: "Well, you've got %{votes_count} support so far Congratulations!"
|
|
||||||
text_2: "And so, you have a new resource available to help you keep moving forward."
|
|
||||||
text_3: "You are missing %{days_count} days before your proposal gets the %{max_votes_count} supports and goes to referendum. Cheer up and keep spreading. Are you short of ideas?"
|
|
||||||
text_4: "NEW RECOMMENDED DIFFUSION ACTION"
|
|
||||||
text_5: "There's more yet, see the following action:"
|
|
||||||
footer_text: "As always, enter the Proposals Panel and we will tell you in detail how to use these resources and how to get the most out of it."
|
|
||||||
dashboard_button: "Go ahead, discover them!"
|
|
||||||
new_actions_notification_on_create:
|
new_actions_notification_on_create:
|
||||||
subject: "Your draft citizen proposal is created"
|
subject: "Your draft citizen proposal is created"
|
||||||
hi: "Hi %{name}!"
|
hi: "Hi %{name}!"
|
||||||
|
|||||||
@@ -96,30 +96,6 @@ es:
|
|||||||
subject: "Machine learning - Contenido generado correctamente"
|
subject: "Machine learning - Contenido generado correctamente"
|
||||||
text: "El contenido ha sido generado correctamente."
|
text: "El contenido ha sido generado correctamente."
|
||||||
title: "Script Machine Learning"
|
title: "Script Machine Learning"
|
||||||
new_actions_notification_rake_created:
|
|
||||||
subject: "Más novedades de tu propuesta ciudadana"
|
|
||||||
hi: "Hola %{name},"
|
|
||||||
new_resource: "NUEVO RECURSO DESBLOQUEADO"
|
|
||||||
introduction: "Como sabes, el día %{created_at_day} del %{created_at_month} creaste la propuesta en modo borrador %{title}."
|
|
||||||
text_1: "Cuando quieras puedes publicar en este enlace: %{link_to_published}. Si aún no lo tienes claro…"
|
|
||||||
text_2: "¡aprovecha este momento! Aprende, suma a otras personas con los mismos intereses y prepara la difusión que necesitarás al publicar tu propuesta definitivamente."
|
|
||||||
text_3: "Y para acompañarte en este reto, aquí van las novedades..."
|
|
||||||
text_4: "Échale un vistazo a esta NUEVA ACCIÓN recomendada:"
|
|
||||||
text_5: "La siguiente acción que te recomendamos es:"
|
|
||||||
footer_text: "Como siempre, entra en el Panel de propuestas y te contamos detalladamente cómo utilizar estos recursos y cómo sacarle el máximo partido."
|
|
||||||
dashboard_button: "Adelante, ¡descúbrelos!"
|
|
||||||
new_actions_notification_rake_published:
|
|
||||||
subject: "Más novedades de tu propuesta ciudadana"
|
|
||||||
hi: "Hola %{name},"
|
|
||||||
new_resource: "NUEVO RECURSO DESBLOQUEADO"
|
|
||||||
introduction: "Como sabes, el día %{published_at_day} del %{published_at_month} publicaste la propuesta %{title}."
|
|
||||||
text_1: "Pues bien, has conseguido %{votes_count} apoyos hasta este momento ¡Felicidades!"
|
|
||||||
text_2: "Y por eso, tienes disponible un nuevo recurso para ayudarte a seguir avanzando."
|
|
||||||
text_3: "Te faltan %{days_count} días para que tu propuesta consiga los %{max_votes_count} apoyos y que vaya a referéndum. Ánimo y sigue difundiendo. ¿Te faltan ideas?"
|
|
||||||
text_4: "NUEVA ACCIÓN DE DIFUSIÓN RECOMENDADA"
|
|
||||||
text_5: "Aún hay más, consulta la siguiente acción:"
|
|
||||||
footer_text: "Como siempre, entra en el Panel de propuestas y te contamos detalladamente cómo utilizar estos recursos y cómo sacarle el máximo partido."
|
|
||||||
dashboard_button: "Adelante, ¡descúbrelos!"
|
|
||||||
new_actions_notification_on_create:
|
new_actions_notification_on_create:
|
||||||
subject: "Tu borrador de propuesta ciudadana está creado"
|
subject: "Tu borrador de propuesta ciudadana está creado"
|
||||||
hi: "Hola %{name}!"
|
hi: "Hola %{name}!"
|
||||||
|
|||||||
@@ -31,11 +31,6 @@ every 2.hours do
|
|||||||
rake "-s stats:generate"
|
rake "-s stats:generate"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Temporally not send dashboard's notifications
|
|
||||||
# every 1.day, at: "7:00 am" do
|
|
||||||
# rake "dashboards:send_notifications"
|
|
||||||
# end
|
|
||||||
|
|
||||||
every 1.day, at: "1:00 am", roles: [:cron] do
|
every 1.day, at: "1:00 am", roles: [:cron] do
|
||||||
rake "files:remove_old_cached_attachments"
|
rake "files:remove_old_cached_attachments"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
namespace :dashboards do
|
|
||||||
desc "Send to user notifications from new actions availability on dashboard"
|
|
||||||
task send_notifications: :environment do
|
|
||||||
Proposal.not_archived.each do |proposal|
|
|
||||||
new_actions_ids = Dashboard::Action.detect_new_actions_since(Date.yesterday, proposal)
|
|
||||||
|
|
||||||
if new_actions_ids.present?
|
|
||||||
if proposal.published?
|
|
||||||
Dashboard::Mailer.delay.new_actions_notification_rake_published(proposal,
|
|
||||||
new_actions_ids)
|
|
||||||
else
|
|
||||||
Dashboard::Mailer.delay.new_actions_notification_rake_created(proposal,
|
|
||||||
new_actions_ids)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
require "rails_helper"
|
|
||||||
require "rake"
|
|
||||||
|
|
||||||
describe "Dashboards Rake" do
|
|
||||||
describe "#send_notifications" do
|
|
||||||
before do
|
|
||||||
Rake.application.rake_require "tasks/dashboards"
|
|
||||||
Rake::Task.define_task(:environment)
|
|
||||||
Setting["feature.dashboard.notification_emails"] = true
|
|
||||||
ActionMailer::Base.deliveries.clear
|
|
||||||
end
|
|
||||||
|
|
||||||
let :run_rake_task do
|
|
||||||
Rake::Task["dashboards:send_notifications"].reenable
|
|
||||||
Rake.application.invoke_task "dashboards:send_notifications"
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "Not send notifications to proposal author" do
|
|
||||||
let!(:action) { create(:dashboard_action, :proposed_action, :active, day_offset: 1) }
|
|
||||||
let!(:resource) { create(:dashboard_action, :resource, :active, day_offset: 1) }
|
|
||||||
|
|
||||||
it "when there are not news actions actived for published proposals" do
|
|
||||||
create(:proposal)
|
|
||||||
action.update!(published_proposal: true)
|
|
||||||
resource.update!(published_proposal: true)
|
|
||||||
|
|
||||||
expect { run_rake_task }.to change { ActionMailer::Base.deliveries.count }.by(0)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "when there are not news actions actived for draft proposals" do
|
|
||||||
create(:proposal, :draft)
|
|
||||||
action.update!(published_proposal: false)
|
|
||||||
resource.update!(published_proposal: false)
|
|
||||||
|
|
||||||
expect { run_rake_task }.to change { ActionMailer::Base.deliveries.count }.by(0)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "when there are news actions actived for archived proposals" do
|
|
||||||
create(:proposal, :archived)
|
|
||||||
action.update!(day_offset: 0, published_proposal: true)
|
|
||||||
resource.update!(day_offset: 0, published_proposal: true)
|
|
||||||
|
|
||||||
expect { run_rake_task }.to change { ActionMailer::Base.deliveries.count }.by(0)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "Send notifications to proposal author" do
|
|
||||||
let!(:action) { create(:dashboard_action, :proposed_action, :active, day_offset: 0) }
|
|
||||||
let!(:resource) { create(:dashboard_action, :resource, :active, day_offset: 0) }
|
|
||||||
|
|
||||||
before do
|
|
||||||
Setting["mailer_from_name"] = "CONSUL"
|
|
||||||
Setting["mailer_from_address"] = "noreply@consul.dev"
|
|
||||||
end
|
|
||||||
|
|
||||||
it " when there are news actions actived for published proposals" do
|
|
||||||
proposal = create(:proposal)
|
|
||||||
action.update!(published_proposal: true)
|
|
||||||
resource.update!(published_proposal: true)
|
|
||||||
|
|
||||||
run_rake_task
|
|
||||||
email = open_last_email
|
|
||||||
|
|
||||||
expect(email).to deliver_from("CONSUL <noreply@consul.dev>")
|
|
||||||
expect(email).to deliver_to(proposal.author)
|
|
||||||
expect(email).to have_subject("More news about your citizen proposal")
|
|
||||||
end
|
|
||||||
|
|
||||||
it "when there are news actions actived for draft proposals" do
|
|
||||||
proposal = create(:proposal, :draft)
|
|
||||||
action.update!(published_proposal: false)
|
|
||||||
resource.update!(published_proposal: false)
|
|
||||||
|
|
||||||
run_rake_task
|
|
||||||
email = open_last_email
|
|
||||||
|
|
||||||
expect(email).to deliver_from("CONSUL <noreply@consul.dev>")
|
|
||||||
expect(email).to deliver_to(proposal.author)
|
|
||||||
expect(email).to have_subject("More news about your citizen proposal")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -44,111 +44,6 @@ describe Dashboard::Mailer do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#new_actions_notification rake task" do
|
|
||||||
before do
|
|
||||||
Rake.application.rake_require "tasks/dashboards"
|
|
||||||
Rake::Task.define_task(:environment)
|
|
||||||
ActionMailer::Base.deliveries.clear
|
|
||||||
end
|
|
||||||
|
|
||||||
let :run_rake_task do
|
|
||||||
Rake::Task["dashboards:send_notifications"].reenable
|
|
||||||
Rake.application.invoke_task "dashboards:send_notifications"
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "#new_actions_notification_rake_created" do
|
|
||||||
let!(:proposal) { create(:proposal, :draft) }
|
|
||||||
|
|
||||||
it "Disables notification email delivery using setting" do
|
|
||||||
Setting["feature.dashboard.notification_emails"] = nil
|
|
||||||
|
|
||||||
action.update!(published_proposal: false)
|
|
||||||
resource.update!(published_proposal: false)
|
|
||||||
run_rake_task
|
|
||||||
|
|
||||||
expect(ActionMailer::Base.deliveries.count).to eq(0)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "sends emails when detect new actions for draft proposal" do
|
|
||||||
action.update!(published_proposal: false)
|
|
||||||
resource.update!(published_proposal: false)
|
|
||||||
run_rake_task
|
|
||||||
|
|
||||||
email = open_last_email
|
|
||||||
|
|
||||||
expect(email).to deliver_from("CONSUL <noreply@consul.dev>")
|
|
||||||
expect(email).to deliver_to(proposal.author)
|
|
||||||
expect(email).to have_subject("More news about your citizen proposal")
|
|
||||||
expect(email).to have_body_text("Hello #{proposal.author.name},")
|
|
||||||
expect(email).to have_body_text("As you know, on the #{proposal.created_at.day} day of "\
|
|
||||||
"the #{proposal.created_at.strftime("%B")} you created "\
|
|
||||||
"the proposal in draft mode #{proposal.title}.")
|
|
||||||
expect(email).to have_body_text("Whenever you want you can publish on this link:")
|
|
||||||
expect(email).to have_body_text("Seize this moment! Learn, add other people with the same "\
|
|
||||||
"interests and prepare the diffusion that you will need "\
|
|
||||||
"when you publish your proposal definitively.")
|
|
||||||
expect(email).to have_body_text("And to accompany you in this challenge, "\
|
|
||||||
"here are the news...")
|
|
||||||
expect(email).to have_body_text("NEW UNLOCKED RESOURCE")
|
|
||||||
expect(email).to have_body_text(resource.title)
|
|
||||||
expect(email).to have_body_text("Take a look at this NEW recommended ACTION:")
|
|
||||||
expect(email).to have_body_text(action.title)
|
|
||||||
expect(email).to have_body_text(action.description)
|
|
||||||
expect(email).to have_body_text("As always, enter the Proposals Panel and we will tell "\
|
|
||||||
"you in detail how to use these resources and how to get "\
|
|
||||||
"the most out of it.")
|
|
||||||
expect(email).to have_body_text("Go ahead, discover them!")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "#new_actions_notification_rake_published" do
|
|
||||||
let!(:proposal) { create(:proposal) }
|
|
||||||
|
|
||||||
it "Disables notification email delivery using setting" do
|
|
||||||
Setting["feature.dashboard.notification_emails"] = nil
|
|
||||||
ActionMailer::Base.deliveries.clear
|
|
||||||
|
|
||||||
run_rake_task
|
|
||||||
|
|
||||||
expect(ActionMailer::Base.deliveries.count).to eq(0)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "sends emails when detect new actions for proposal" do
|
|
||||||
run_rake_task
|
|
||||||
|
|
||||||
email = open_last_email
|
|
||||||
|
|
||||||
expect(email).to deliver_from("CONSUL <noreply@consul.dev>")
|
|
||||||
expect(email).to deliver_to(proposal.author)
|
|
||||||
expect(email).to have_subject("More news about your citizen proposal")
|
|
||||||
expect(email).to have_body_text("Hello #{proposal.author.name},")
|
|
||||||
expect(email).to have_body_text("As you know, on the #{proposal.published_at.day} day of "\
|
|
||||||
"the #{proposal.published_at.strftime("%B")} you "\
|
|
||||||
"published the proposal #{proposal.title}.")
|
|
||||||
expect(email).to have_body_text("And so, you have a new resource available to help "\
|
|
||||||
"you keep moving forward.")
|
|
||||||
expect(email).to have_body_text("NEW UNLOCKED RESOURCE")
|
|
||||||
expect(email).to have_body_text(resource.title)
|
|
||||||
|
|
||||||
months_to_archive_proposals = Setting["months_to_archive_proposals"].to_i.months
|
|
||||||
limit_to_archive_proposal = proposal.created_at.to_date + months_to_archive_proposals
|
|
||||||
days_count = (limit_to_archive_proposal - Date.current).to_i
|
|
||||||
|
|
||||||
expect(email).to have_body_text("You are missing #{days_count} days before your proposal "\
|
|
||||||
"gets the #{Setting["votes_for_proposal_success"]} "\
|
|
||||||
"supports and goes to referendum. Cheer up and keep "\
|
|
||||||
"spreading. Are you short of ideas?")
|
|
||||||
expect(email).to have_body_text("NEW RECOMMENDED DIFFUSION ACTION")
|
|
||||||
expect(email).to have_body_text(action.title)
|
|
||||||
expect(email).to have_body_text(action.description)
|
|
||||||
expect(email).to have_body_text("As always, enter the Proposals Panel and we will tell "\
|
|
||||||
"you in detail how to use these resources and how to get "\
|
|
||||||
"the most out of it.")
|
|
||||||
expect(email).to have_body_text("Go ahead, discover them!")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "#new_actions_notification_on_create" do
|
describe "#new_actions_notification_on_create" do
|
||||||
before do
|
before do
|
||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
|
|||||||
@@ -4,20 +4,6 @@ class DashboardMailerPreview < ActionMailer::Preview
|
|||||||
Dashboard::Mailer.forward(proposal)
|
Dashboard::Mailer.forward(proposal)
|
||||||
end
|
end
|
||||||
|
|
||||||
# http://localhost:3000/rails/mailers/dashboard_mailer/new_actions_notification_rake_published
|
|
||||||
def new_actions_notification_rake_published
|
|
||||||
proposal = Proposal.find_by(published: true)
|
|
||||||
new_actions_ids = Dashboard::Action.limit(1).id
|
|
||||||
Dashboard::Mailer.new_actions_notification(proposal, [new_actions_ids])
|
|
||||||
end
|
|
||||||
|
|
||||||
# http://localhost:3000/rails/mailers/dashboard_mailer/new_actions_notification_rake_created
|
|
||||||
def new_actions_notification_rake_created
|
|
||||||
proposal = Proposal.find_by(published: false)
|
|
||||||
new_actions_ids = Dashboard::Action.limit(1).id
|
|
||||||
Dashboard::Mailer.new_actions_notification(proposal, [new_actions_ids])
|
|
||||||
end
|
|
||||||
|
|
||||||
# http://localhost:3000/rails/mailers/dashboard_mailer/new_actions_notification_on_create
|
# http://localhost:3000/rails/mailers/dashboard_mailer/new_actions_notification_on_create
|
||||||
def new_actions_notification_on_create
|
def new_actions_notification_on_create
|
||||||
proposal = Proposal.first
|
proposal = Proposal.first
|
||||||
|
|||||||
Reference in New Issue
Block a user