Adds moderate actions to proposal system notifications
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
class Admin::SystemEmailsController < Admin::BaseController
|
||||
|
||||
before_action :load_system_email, only: [:view, :preview_pending]
|
||||
before_action :load_system_email, only: [:view, :preview_pending, :moderate_pending]
|
||||
|
||||
def index
|
||||
@system_emails = {
|
||||
|
||||
@@ -55,4 +55,9 @@ class ProposalNotification < ActiveRecord::Base
|
||||
self.update(author_id: self.proposal.author_id) if self.proposal
|
||||
end
|
||||
|
||||
def moderate_system_email(moderator)
|
||||
Notification.where(notifiable_type: 'ProposalNotification', notifiable: self).destroy_all
|
||||
Activity.log(moderator, :hide, self)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<% if preview.proposal.present? %>
|
||||
<div id="<%= dom_id(preview) %>">
|
||||
<div class="callout highlight">
|
||||
<div class="row">
|
||||
<div class="row expanded">
|
||||
<div class="small-12 medium-6 column">
|
||||
<strong><%= t("admin.shared.proposal") %></strong><br>
|
||||
<%= link_to preview.proposal.title, proposal_url(preview.proposal) %>
|
||||
@@ -9,8 +10,6 @@
|
||||
<strong><%= t("admin.shared.title") %></strong><br>
|
||||
<%= link_to preview.title, proposal_url(preview.proposal, anchor: "tab-notifications") %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="small-12 medium-6 column">
|
||||
<strong><%= t("admin.shared.author") %></strong><br>
|
||||
<%= preview.proposal.author&.username || '-' %>
|
||||
@@ -25,9 +24,17 @@
|
||||
<div class="row">
|
||||
<div class="column">
|
||||
<strong><%= t("admin.shared.content") %></strong>
|
||||
<p class="help-text" id="phase-description-help-text">
|
||||
<p id="phase-description-help-text">
|
||||
<%= preview.body %>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= link_to t("admin.system_emails.preview_pending.moderate_pending"),
|
||||
admin_system_email_moderate_pending_path(system_email_id: 'proposal_notification_digest',
|
||||
id: preview.id),
|
||||
method: :put,
|
||||
class: "button hollow float-right" %>
|
||||
</div>
|
||||
<hr>
|
||||
<% end %>
|
||||
|
||||
@@ -152,5 +152,21 @@ describe ProposalNotification do
|
||||
|
||||
end
|
||||
|
||||
describe "#moderate_system_email" do
|
||||
let(:admin) { create(:administrator) }
|
||||
let(:proposal) { create(:proposal) }
|
||||
let(:proposal_notification) { build(:proposal_notification, proposal: proposal) }
|
||||
let(:notification) { create(:notification, notifiable: proposal_notification) }
|
||||
|
||||
it "removes all notifications related to the proposal notification" do
|
||||
proposal_notification.moderate_system_email(admin.user)
|
||||
expect(Notification.all.count).to be(0)
|
||||
end
|
||||
|
||||
it "records the moderation action in the Activity table" do
|
||||
proposal_notification.moderate_system_email(admin.user)
|
||||
expect(Activity.last.actionable_type).to eq('ProposalNotification')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user