Adds activity tab for system emails
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
class Admin::ActivityController < Admin::BaseController
|
||||
has_filters %w{all on_users on_proposals on_debates on_comments}
|
||||
has_filters %w{all on_users on_proposals on_debates on_comments on_system_emails}
|
||||
|
||||
def show
|
||||
@activity = Activity.for_render.send(@current_filter)
|
||||
|
||||
@@ -11,6 +11,7 @@ class Activity < ActiveRecord::Base
|
||||
scope :on_users, -> { where(actionable_type: 'User') }
|
||||
scope :on_comments, -> { where(actionable_type: 'Comment') }
|
||||
scope :on_budget_investments, -> { where(actionable_type: 'Budget::Investment') }
|
||||
scope :on_system_emails, -> { where(actionable_type: 'ProposalNotification') }
|
||||
scope :for_render, -> { includes(user: [:moderator, :administrator]).includes(:actionable) }
|
||||
|
||||
def self.log(user, action, actionable)
|
||||
|
||||
@@ -10,6 +10,7 @@ class ProposalNotification < ActiveRecord::Base
|
||||
validates :proposal, presence: true
|
||||
validate :minimum_interval
|
||||
|
||||
scope :with_hidden, -> { all }
|
||||
scope :public_for_api, -> { where(proposal_id: Proposal.public_for_api.pluck(:id)) }
|
||||
scope :sort_by_created_at, -> { reorder(created_at: :desc) }
|
||||
scope :sort_by_moderated, -> { reorder(moderated: :desc) }
|
||||
|
||||
@@ -67,6 +67,7 @@ en:
|
||||
on_debates: Debates
|
||||
on_proposals: Proposals
|
||||
on_users: Users
|
||||
on_system_emails: System emails
|
||||
title: Moderator activity
|
||||
type: Type
|
||||
no_activity: There are no moderators activity.
|
||||
|
||||
@@ -67,6 +67,7 @@ es:
|
||||
on_debates: Debates
|
||||
on_proposals: Propuestas
|
||||
on_users: Usuarios
|
||||
on_system_emails: Emails del sistema
|
||||
title: Actividad de los Moderadores
|
||||
type: Tipo
|
||||
no_activity: No hay actividad de moderadores.
|
||||
|
||||
@@ -331,4 +331,22 @@ feature 'Admin activity' do
|
||||
end
|
||||
end
|
||||
|
||||
context "System emails" do
|
||||
scenario "Shows moderation activity on system emails" do
|
||||
proposal = create(:proposal, title: 'Proposal A')
|
||||
proposal_notification = create(:proposal_notification, proposal: proposal,
|
||||
title: 'Proposal A Title',
|
||||
body: 'Proposal A Notification Body')
|
||||
proposal_notification.moderate_system_email(@admin.user)
|
||||
|
||||
visit admin_activity_path
|
||||
|
||||
within("#activity_#{Activity.last.id}") do
|
||||
expect(page).to have_content(proposal_notification.title)
|
||||
expect(page).to have_content("Hidden")
|
||||
expect(page).to have_content(@admin.user.username)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user