diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index 3ec222886..0d75e554f 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -521,8 +521,8 @@ en: 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 - selected_investment_authors: Authors of investments selected for the final vote in the current budget + feasible_and_undecided_investment_authors: "Authors of some investment in the current budget that does not comply with: [valuation finished unfesasible]" + selected_investment_authors: Authors of selected investments in the current budget winner_investment_authors: Authors of winner investments in the current budget invalid_recipients_segment: "Recipients user segment is invalid" newsletters: diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index a70b4fb7a..683d18894 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -519,10 +519,10 @@ es: all_users: Todos los usuarios administrators: Administradores proposal_authors: Usuarios autores de propuestas - investment_authors: Autores de proyectos de gasto en los actuales presupuestos - feasible_and_undecided_investment_authors: Autores de proyectos de gasto viables o sin decidir en los actuales presupuestos - selected_investment_authors: Autores de proyectos de gasto seleccionados para la votación final en los actuales presupuestos - winner_investment_authors: Autores de proyectos de gasto ganadoras en los actuales presupuestos + investment_authors: Usuarios autores de proyectos de gasto en los actuales presupuestos + feasible_and_undecided_investment_authors: "Usuarios autores de algún proyecto de gasto en los actuales presupuestos que no cumpla: [evaluación finalizada inviable]" + selected_investment_authors: Usuarios autores de proyectos de gasto seleccionadas en los actuales presupuestos + winner_investment_authors: Usuarios autores de proyectos de gasto ganadoras en los actuales presupuestos invalid_recipients_segment: "El segmento de destinatarios es inválido" newsletters: create_success: Newsletter creada correctamente diff --git a/lib/user_segments.rb b/lib/user_segments.rb index e922c2321..1505e08e7 100644 --- a/lib/user_segments.rb +++ b/lib/user_segments.rb @@ -24,8 +24,9 @@ class UserSegments end def self.feasible_and_undecided_investment_authors - feasibility = %w(feasible undecided) - author_ids(current_budget_investments.where(feasibility: feasibility).pluck(:author_id).uniq) + unfeasible_and_finished_condition = "feasibility = 'unfeasible' and valuation_finished = true" + investments = current_budget_investments.where.not(unfeasible_and_finished_condition) + author_ids(investments.pluck(:author_id).uniq) end def self.selected_investment_authors diff --git a/spec/lib/user_segments_spec.rb b/spec/lib/user_segments_spec.rb index 33c310203..5d0c33e19 100644 --- a/spec/lib/user_segments_spec.rb +++ b/spec/lib/user_segments_spec.rb @@ -70,18 +70,32 @@ describe UserSegments do describe "#feasible_and_undecided_investment_authors" do it "returns authors of a feasible or an undecided budget investment" do - feasible_investment = create(:budget_investment, :feasible, author: user1) - undecided_investment = create(:budget_investment, :undecided, author: user2) - unfeasible_investment = create(:budget_investment, :unfeasible, author: user3) + user4 = create(:user) + user5 = create(:user) + user6 = create(:user) + + feasible_investment_finished = create(:budget_investment, :feasible, :finished, author: user1) + undecided_investment_finished = create(:budget_investment, :undecided, :finished, author: user2) + feasible_investment_unfinished = create(:budget_investment, :feasible, author: user3) + undecided_investment_unfinished = create(:budget_investment, :undecided, author: user4) + unfeasible_investment_unfinished = create(:budget_investment, :unfeasible, author: user5) + unfeasible_investment_finished = create(:budget_investment, :unfeasible, :finished, author: user6) + budget = create(:budget) - feasible_investment.update(budget: budget) - undecided_investment.update(budget: budget) - unfeasible_investment.update(budget: budget) + feasible_investment_finished.update(budget: budget) + undecided_investment_finished.update(budget: budget) + feasible_investment_unfinished.update(budget: budget) + undecided_investment_unfinished.update(budget: budget) + unfeasible_investment_unfinished.update(budget: budget) + unfeasible_investment_finished.update(budget: budget) investment_authors = described_class.feasible_and_undecided_investment_authors expect(investment_authors).to include user1 expect(investment_authors).to include user2 - expect(investment_authors).not_to include user3 + expect(investment_authors).to include user3 + expect(investment_authors).to include user4 + expect(investment_authors).to include user5 + expect(investment_authors).not_to include user6 end it "does not return duplicated users" do