Add administrators UserSegment
We need a user segment to have only administrators as recipients of both newsletters and notifications
This commit is contained in:
@@ -518,6 +518,7 @@ en:
|
||||
title: 'Moderators: User search'
|
||||
segment_recipient:
|
||||
all_users: All users
|
||||
administrators: Administrators
|
||||
proposal_authors: Proposal authors
|
||||
investment_authors: Investment authors in the current budget
|
||||
feasible_and_undecided_investment_authors: Authors of feasible or undecided investments in the current budget
|
||||
|
||||
@@ -517,6 +517,7 @@ es:
|
||||
title: 'Moderadores: Búsqueda de usuarios'
|
||||
segment_recipient:
|
||||
all_users: Todos los usuarios
|
||||
administrators: Administradores
|
||||
proposal_authors: Usuarios autores de propuestas
|
||||
investment_authors: Usuarios autores de proyectos de gasto en los actuales presupuestos
|
||||
feasible_and_undecided_investment_authors: Usuarios autores de proyectos de gasto viables o sin decidir en los actuales presupuestos
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
class UserSegments
|
||||
SEGMENTS = %w(all_users
|
||||
administrators
|
||||
proposal_authors
|
||||
investment_authors
|
||||
feasible_and_undecided_investment_authors
|
||||
@@ -10,6 +11,10 @@ class UserSegments
|
||||
User.active
|
||||
end
|
||||
|
||||
def self.administrators
|
||||
all_users.administrators
|
||||
end
|
||||
|
||||
def self.proposal_authors
|
||||
author_ids(Proposal.not_archived.not_retired.pluck(:author_id).uniq)
|
||||
end
|
||||
|
||||
@@ -15,6 +15,18 @@ describe UserSegments do
|
||||
end
|
||||
end
|
||||
|
||||
describe "#administrators" do
|
||||
it "returns all active administrators users" do
|
||||
active_user = create(:user)
|
||||
active_admin = create(:administrator).user
|
||||
erased_user = create(:user, erased_at: Time.current)
|
||||
|
||||
expect(described_class.administrators).to include active_admin
|
||||
expect(described_class.administrators).not_to include active_user
|
||||
expect(described_class.administrators).not_to include erased_user
|
||||
end
|
||||
end
|
||||
|
||||
describe "#proposal_authors" do
|
||||
it "returns users that have created a proposal" do
|
||||
proposal = create(:proposal, author: user1)
|
||||
|
||||
Reference in New Issue
Block a user