Adds button to send pending proposal notifications
This commit is contained in:
@@ -31,7 +31,7 @@ class Admin::SystemEmailsController < Admin::BaseController
|
||||
end
|
||||
|
||||
def send_pending
|
||||
Notification.send_pending
|
||||
Notification.delay.send_pending
|
||||
|
||||
flash[:notice] = t("admin.system_emails.preview_pending.send_pending_notification")
|
||||
redirect_to admin_system_emails_path
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<tr>
|
||||
<th><%= t("admin.shared.title") %></th>
|
||||
<th><%= t("admin.shared.description") %></th>
|
||||
<th class="small-5 text-right"><%= t("admin.shared.actions") %></th>
|
||||
<th class="small-7 text-right"><%= t("admin.shared.actions") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -27,6 +27,10 @@
|
||||
admin_system_email_preview_pending_path(system_email_title),
|
||||
class: "button" %>
|
||||
<% end %>
|
||||
<%= link_to t("admin.system_emails.preview_pending.send_pending"),
|
||||
admin_system_email_send_pending_path(system_email_title),
|
||||
class: "button",
|
||||
method: :put %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
@@ -655,6 +655,9 @@ en:
|
||||
action: Preview Pending
|
||||
preview_of: Preview of %{name}
|
||||
pending_to_be_sent: This is the content pending to be sent
|
||||
moderate_pending: Moderate notification send
|
||||
send_pending: Send pending
|
||||
send_pending_notification: Pending notifications sent succesfully
|
||||
proposal_notification_digest:
|
||||
title: Proposal Notification Digest
|
||||
description: Gathers all proposal notifications for an user in a single message, to avoid too much emails.
|
||||
|
||||
@@ -656,6 +656,9 @@ es:
|
||||
action: Previsualizar Pendientes
|
||||
preview_of: Vista previa de %{name}
|
||||
pending_to_be_sent: Este es todo el contenido pendiente de enviar
|
||||
moderate_pending: Moderar envío de notificación
|
||||
send_pending : Enviar pendientes
|
||||
send_pending_notification: Notificaciones pendientes enviadas correctamente
|
||||
proposal_notification_digest:
|
||||
title: Resumen de Notificationes de Propuestas
|
||||
description: Reune todas las notificaciones de propuestas en un único mensaje, para evitar demasiados emails.
|
||||
|
||||
@@ -168,6 +168,8 @@ namespace :admin do
|
||||
resources :system_emails, only: [:index] do
|
||||
get :view
|
||||
get :preview_pending
|
||||
put :moderate_pending
|
||||
put :send_pending
|
||||
end
|
||||
|
||||
resources :emails_download, only: :index do
|
||||
|
||||
@@ -65,6 +65,49 @@ feature "System Emails" do
|
||||
expect(page).to have_link('Proposal B Title', href: proposal_url(proposal_b,
|
||||
anchor: 'tab-notifications'))
|
||||
end
|
||||
|
||||
scenario "#moderate_pending" do
|
||||
proposal1 = create(:proposal, title: 'Proposal A')
|
||||
proposal2 = create(:proposal, title: 'Proposal B')
|
||||
proposal_notification1 = create(:proposal_notification, proposal: proposal1,
|
||||
title: 'Proposal A Title',
|
||||
body: 'Proposal A Notification Body')
|
||||
proposal_notification2 = create(:proposal_notification, proposal: proposal2)
|
||||
create(:notification, notifiable: proposal_notification1, emailed_at: nil)
|
||||
create(:notification, notifiable: proposal_notification2, emailed_at: nil)
|
||||
|
||||
visit admin_system_email_preview_pending_path('proposal_notification_digest')
|
||||
|
||||
within("#proposal_notification_#{proposal_notification1.id}") do
|
||||
click_on "Moderate notification send"
|
||||
end
|
||||
|
||||
visit admin_system_email_preview_pending_path('proposal_notification_digest')
|
||||
|
||||
expect(Notification.count).to equal(1)
|
||||
expect(Activity.last.actionable_type).to eq('ProposalNotification')
|
||||
expect(page).not_to have_content("Proposal A Title")
|
||||
end
|
||||
|
||||
scenario "#send_pending" do
|
||||
proposal = create(:proposal)
|
||||
proposal_notification = create(:proposal_notification, proposal: proposal,
|
||||
title: 'Proposal A Title',
|
||||
body: 'Proposal A Notification Body')
|
||||
voter = create(:user, :level_two)
|
||||
create(:notification, notifiable: proposal_notification, user: voter, emailed_at: nil)
|
||||
create(:follow, user: voter, followable: proposal)
|
||||
|
||||
visit admin_system_emails_path
|
||||
|
||||
click_on "Send pending"
|
||||
|
||||
email = open_last_email
|
||||
expect(email).to deliver_to(voter)
|
||||
expect(email).to have_body_text(proposal_notification.body)
|
||||
|
||||
expect(page).to have_content("Pending notifications sent succesfully")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user