Use buttons to send notifications and newsletters
As mentioned in commits5311daadfandbb958daf0, using links combined with JavaScript to generate POST requests to the server has a few issues.
This commit is contained in:
@@ -64,12 +64,17 @@
|
||||
|
||||
<% if @admin_notification.draft? && @admin_notification.valid_segment_recipient? %>
|
||||
<div class="small-12 medium-6 large-3 column end">
|
||||
<%= link_to t("admin.admin_notifications.show.send"),
|
||||
deliver_admin_admin_notification_path(@admin_notification),
|
||||
"data-alert": t("admin.admin_notifications.show.send_alert",
|
||||
n: @admin_notification.list_of_recipients_count),
|
||||
method: :post,
|
||||
id: "js-send-admin_notification-alert",
|
||||
class: "button success expanded" %>
|
||||
<%= render Admin::ActionComponent.new(
|
||||
:deliver,
|
||||
@admin_notification,
|
||||
text: t("admin.admin_notifications.show.send"),
|
||||
method: :post,
|
||||
"data-alert": t(
|
||||
"admin.admin_notifications.show.send_alert",
|
||||
n: @admin_notification.list_of_recipients_count
|
||||
),
|
||||
id: "js-send-admin_notification-alert",
|
||||
class: "button success expanded",
|
||||
) %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@@ -56,10 +56,13 @@
|
||||
</div>
|
||||
|
||||
<% if @newsletter.draft? && @newsletter.valid_segment_recipient? %>
|
||||
<%= link_to t("admin.newsletters.show.send"),
|
||||
deliver_admin_newsletter_path(@newsletter),
|
||||
"data-alert": t("admin.newsletters.show.send_alert", n: recipients_count),
|
||||
method: :post,
|
||||
id: "js-send-newsletter-alert",
|
||||
class: "button success" %>
|
||||
<%= render Admin::ActionComponent.new(
|
||||
:deliver,
|
||||
@newsletter,
|
||||
text: t("admin.newsletters.show.send"),
|
||||
method: :post,
|
||||
"data-alert": t("admin.newsletters.show.send_alert", n: recipients_count),
|
||||
id: "js-send-newsletter-alert",
|
||||
class: "button success"
|
||||
) %>
|
||||
<% end %>
|
||||
|
||||
@@ -190,7 +190,7 @@ describe "Admin Notifications", :admin do
|
||||
|
||||
visit admin_admin_notification_path(notification)
|
||||
|
||||
accept_confirm { click_link "Send notification" }
|
||||
accept_confirm { click_button "Send notification" }
|
||||
|
||||
expect(page).to have_content "Notification sent successfully"
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ describe "Admin newsletter emails", :admin do
|
||||
newsletter = create(:newsletter)
|
||||
visit admin_newsletter_path(newsletter)
|
||||
|
||||
accept_confirm { click_link "Send" }
|
||||
accept_confirm { click_button "Send" }
|
||||
|
||||
expect(page).to have_content "Newsletter sent successfully"
|
||||
end
|
||||
@@ -153,7 +153,7 @@ describe "Admin newsletter emails", :admin do
|
||||
newsletter = create(:newsletter, segment_recipient: "administrators")
|
||||
visit admin_newsletter_path(newsletter)
|
||||
|
||||
accept_confirm { click_link "Send" }
|
||||
accept_confirm { click_button "Send" }
|
||||
|
||||
expect(page).to have_content "Newsletter sent successfully"
|
||||
|
||||
|
||||
@@ -482,7 +482,7 @@ describe "Emails" do
|
||||
|
||||
expect(page).to have_content "Newsletter created successfully"
|
||||
|
||||
accept_confirm { click_link "Send" }
|
||||
accept_confirm { click_button "Send" }
|
||||
|
||||
expect(page).to have_content "Newsletter sent successfully"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user