Adds activity tab for system emails

This commit is contained in:
María Checa
2018-05-15 13:19:47 +02:00
committed by decabeza
parent f1e7b634ba
commit 9d580e15f5
6 changed files with 23 additions and 1 deletions

View File

@@ -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)

View File

@@ -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)

View File

@@ -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) }

View File

@@ -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.

View File

@@ -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.

View File

@@ -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