Add Milestone tag select filter on executions public page
This commit is contained in:
@@ -12,15 +12,15 @@ module Budgets
|
|||||||
|
|
||||||
private
|
private
|
||||||
def investments_by_heading
|
def investments_by_heading
|
||||||
|
base = @budget.investments.winners
|
||||||
|
base = base.joins(milestones: :translations).includes(:milestones)
|
||||||
|
base = base.tagged_with(params[:milestone_tag]) if params[:milestone_tag].present?
|
||||||
|
|
||||||
if params[:status].present?
|
if params[:status].present?
|
||||||
@budget.investments.winners
|
base = base.with_milestone_status_id(params[:status])
|
||||||
.with_milestone_status_id(params[:status])
|
base.uniq.group_by(&:heading)
|
||||||
.uniq
|
|
||||||
.group_by(&:heading)
|
|
||||||
else
|
else
|
||||||
@budget.investments.winners
|
base.distinct.group_by(&:heading)
|
||||||
.joins(milestones: :translations)
|
|
||||||
.distinct.group_by(&:heading)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,12 @@ module BudgetExecutionsHelper
|
|||||||
@budget.investments.winners.with_milestone_status_id(status).count
|
@budget.investments.winners.with_milestone_status_id(status).count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def options_for_milestone_tags
|
||||||
|
@budget.milestone_tags.map do |tag|
|
||||||
|
["#{tag} (#{@budget.investments.winners.tagged_with(tag).count})", tag]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def first_milestone_with_image(investment)
|
def first_milestone_with_image(investment)
|
||||||
investment.milestones.order_by_publication_date
|
investment.milestones.order_by_publication_date
|
||||||
.select{ |milestone| milestone.image.present? }.last
|
.select{ |milestone| milestone.image.present? }.last
|
||||||
|
|||||||
@@ -195,6 +195,10 @@ class Budget < ApplicationRecord
|
|||||||
investments.winners.any?
|
investments.winners.any?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def milestone_tags
|
||||||
|
investments.winners.map(&:milestone_tag_list).flatten.uniq.sort
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def sanitize_descriptions
|
def sanitize_descriptions
|
||||||
|
|||||||
@@ -106,10 +106,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="small-12 column">
|
<div class="small-12 column">
|
||||||
<%= f.label :milestone_tag_list, t("admin.budget_investments.edit.milestone_tags") %>
|
|
||||||
<%= f.text_field :milestone_tag_list,
|
<%= f.text_field :milestone_tag_list,
|
||||||
value: @investment.milestone_tag_list.sort.join(", "),
|
value: @investment.milestone_tag_list.sort.join(", "),
|
||||||
label: false %>
|
label: t("admin.budget_investments.edit.milestone_tags") %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,9 @@
|
|||||||
|
|
||||||
<% if milestoneable.milestone_tag_list.any? %>
|
<% if milestoneable.milestone_tag_list.any? %>
|
||||||
<div>
|
<div>
|
||||||
<b><%= t("admin.milestones.index.milestone_tags") %>:</b> <%= milestoneable.milestone_tag_list.sort.join(", ") %>
|
<strong>
|
||||||
|
<%= t("admin.milestones.index.milestone_tags") %>:
|
||||||
|
</strong> <%= milestoneable.milestone_tag_list.sort.join(", ") %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|||||||
@@ -44,13 +44,24 @@
|
|||||||
<div class="small-12 medium-9 large-10 column">
|
<div class="small-12 medium-9 large-10 column">
|
||||||
<%= form_tag(budget_executions_path(@budget), method: :get) do %>
|
<%= form_tag(budget_executions_path(@budget), method: :get) do %>
|
||||||
<div class="small-12 medium-3 column">
|
<div class="small-12 medium-3 column">
|
||||||
<%= label_tag :status, t("budgets.executions.filters.label") %>
|
<%= label_tag :milestone_tag, t("budgets.executions.filters.milestone_tag.label") %>
|
||||||
|
<%= select_tag :milestone_tag,
|
||||||
|
options_for_select(
|
||||||
|
options_for_milestone_tags,
|
||||||
|
params[:milestone_tag]
|
||||||
|
),
|
||||||
|
class: "js-submit-on-change",
|
||||||
|
prompt: t("budgets.executions.filters.milestone_tag.all",
|
||||||
|
count: @budget.investments.winners.with_milestones.count) %>
|
||||||
|
</div>
|
||||||
|
<div class="small-12 medium-3 column">
|
||||||
|
<%= label_tag :status, t("budgets.executions.filters.status.label") %>
|
||||||
<%= select_tag :status,
|
<%= select_tag :status,
|
||||||
options_from_collection_for_select(@statuses,
|
options_from_collection_for_select(@statuses,
|
||||||
:id, lambda { |s| "#{s.name} (#{filters_select_counts(s.id)})" },
|
:id, lambda { |s| "#{s.name} (#{filters_select_counts(s.id)})" },
|
||||||
params[:status]),
|
params[:status]),
|
||||||
class: "js-submit-on-change",
|
class: "js-submit-on-change",
|
||||||
prompt: t("budgets.executions.filters.all",
|
prompt: t("budgets.executions.filters.status.all",
|
||||||
count: @budget.investments.winners.with_milestones.count) %>
|
count: @budget.investments.winners.with_milestones.count) %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -168,8 +168,9 @@ ar:
|
|||||||
heading_selection_title: "جسب المنطقة"
|
heading_selection_title: "جسب المنطقة"
|
||||||
no_winner_investments: "لا يوجد استثمارات فائزة"
|
no_winner_investments: "لا يوجد استثمارات فائزة"
|
||||||
filters:
|
filters:
|
||||||
label: "حالة المشروع الحالية"
|
status:
|
||||||
all: "الكل (%{count})"
|
label: "حالة المشروع الحالية"
|
||||||
|
all: "الكل (%{count})"
|
||||||
phases:
|
phases:
|
||||||
errors:
|
errors:
|
||||||
dates_range_invalid: "تاريخ البدأ لا يمكن ان يكون مساو او يتجاوز تاريخ الانتهاء"
|
dates_range_invalid: "تاريخ البدأ لا يمكن ان يكون مساو او يتجاوز تاريخ الانتهاء"
|
||||||
|
|||||||
@@ -182,8 +182,9 @@ de:
|
|||||||
heading_selection_title: "Nach Bezirk"
|
heading_selection_title: "Nach Bezirk"
|
||||||
no_winner_investments: "Keine erfolgreichen Ausgabenvorschläge in diesem Status"
|
no_winner_investments: "Keine erfolgreichen Ausgabenvorschläge in diesem Status"
|
||||||
filters:
|
filters:
|
||||||
label: "Aktueller Stand des Projekts"
|
status:
|
||||||
all: "Alle (%{count})"
|
label: "Aktueller Stand des Projekts"
|
||||||
|
all: "Alle (%{count})"
|
||||||
phases:
|
phases:
|
||||||
errors:
|
errors:
|
||||||
dates_range_invalid: "Das Anfangsdatum kann nicht gleich oder später als das Enddatum sein"
|
dates_range_invalid: "Das Anfangsdatum kann nicht gleich oder später als das Enddatum sein"
|
||||||
|
|||||||
@@ -298,6 +298,7 @@ en:
|
|||||||
documents: "Documents"
|
documents: "Documents"
|
||||||
milestone: Milestone
|
milestone: Milestone
|
||||||
new_milestone: Create new milestone
|
new_milestone: Create new milestone
|
||||||
|
milestone_tags: Milestone Tags
|
||||||
form:
|
form:
|
||||||
admin_statuses: Manage statuses
|
admin_statuses: Manage statuses
|
||||||
no_statuses_defined: There are no defined statuses yet
|
no_statuses_defined: There are no defined statuses yet
|
||||||
|
|||||||
@@ -184,8 +184,12 @@ en:
|
|||||||
heading_selection_title: "By district"
|
heading_selection_title: "By district"
|
||||||
no_winner_investments: "No winner investments in this state"
|
no_winner_investments: "No winner investments in this state"
|
||||||
filters:
|
filters:
|
||||||
label: "Project's current state"
|
status:
|
||||||
all: "All (%{count})"
|
label: "Project's current state"
|
||||||
|
all: "All (%{count})"
|
||||||
|
milestone_tag:
|
||||||
|
label: "Milestone tag"
|
||||||
|
all: "All (%{count})"
|
||||||
phases:
|
phases:
|
||||||
errors:
|
errors:
|
||||||
dates_range_invalid: "Start date can't be equal or later than End date"
|
dates_range_invalid: "Start date can't be equal or later than End date"
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ en:
|
|||||||
index:
|
index:
|
||||||
no_milestones: Don't have defined milestones
|
no_milestones: Don't have defined milestones
|
||||||
progress: Progress
|
progress: Progress
|
||||||
milestone_tags: Milestone Tags
|
|
||||||
show:
|
show:
|
||||||
publication_date: "Published %{publication_date}"
|
publication_date: "Published %{publication_date}"
|
||||||
status_changed: Status changed to
|
status_changed: Status changed to
|
||||||
|
|||||||
@@ -298,6 +298,7 @@ es:
|
|||||||
documents: "Documentos"
|
documents: "Documentos"
|
||||||
milestone: Seguimiento
|
milestone: Seguimiento
|
||||||
new_milestone: Crear nuevo hito
|
new_milestone: Crear nuevo hito
|
||||||
|
milestone_tags: Etiquetas de Seguimiento
|
||||||
form:
|
form:
|
||||||
admin_statuses: Gestionar estados
|
admin_statuses: Gestionar estados
|
||||||
no_statuses_defined: No hay estados definidos
|
no_statuses_defined: No hay estados definidos
|
||||||
|
|||||||
@@ -184,8 +184,12 @@ es:
|
|||||||
heading_selection_title: "Ámbito de actuación"
|
heading_selection_title: "Ámbito de actuación"
|
||||||
no_winner_investments: "No hay proyectos de gasto ganadores en este estado"
|
no_winner_investments: "No hay proyectos de gasto ganadores en este estado"
|
||||||
filters:
|
filters:
|
||||||
label: "Estado actual del proyecto"
|
status:
|
||||||
all: "Todos (%{count})"
|
label: "Estado actual del proyecto"
|
||||||
|
all: "Todos (%{count})"
|
||||||
|
milestone_tag:
|
||||||
|
label: "Etiquetas de Seguimiento"
|
||||||
|
all: "Todos (%{count})"
|
||||||
phases:
|
phases:
|
||||||
errors:
|
errors:
|
||||||
dates_range_invalid: "La fecha de comienzo no puede ser igual o superior a la de finalización"
|
dates_range_invalid: "La fecha de comienzo no puede ser igual o superior a la de finalización"
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ es:
|
|||||||
index:
|
index:
|
||||||
no_milestones: No hay hitos definidos
|
no_milestones: No hay hitos definidos
|
||||||
progress: Progreso
|
progress: Progreso
|
||||||
milestone_tags: Etiquetas de Seguimiento
|
|
||||||
show:
|
show:
|
||||||
publication_date: "Publicado el %{publication_date}"
|
publication_date: "Publicado el %{publication_date}"
|
||||||
status_changed: El proyecto ha cambiado al estado
|
status_changed: El proyecto ha cambiado al estado
|
||||||
|
|||||||
@@ -50,4 +50,5 @@ fi:
|
|||||||
link: "Tavoitteet"
|
link: "Tavoitteet"
|
||||||
page_title: "%{budget} - Tavoitteet"
|
page_title: "%{budget} - Tavoitteet"
|
||||||
filters:
|
filters:
|
||||||
all: "Kaikki (%{count})"
|
status:
|
||||||
|
all: "Kaikki (%{count})"
|
||||||
|
|||||||
@@ -182,8 +182,9 @@ gl:
|
|||||||
heading_selection_title: "Por ámbito de actuación"
|
heading_selection_title: "Por ámbito de actuación"
|
||||||
no_winner_investments: "Non hai investimentos gañadores neste estado"
|
no_winner_investments: "Non hai investimentos gañadores neste estado"
|
||||||
filters:
|
filters:
|
||||||
label: "Estado actual do proxecto"
|
status:
|
||||||
all: "Todo (%{count})"
|
label: "Estado actual do proxecto"
|
||||||
|
all: "Todo (%{count})"
|
||||||
phases:
|
phases:
|
||||||
errors:
|
errors:
|
||||||
dates_range_invalid: "A data de comezo non pode ser igual ou superior á de remate"
|
dates_range_invalid: "A data de comezo non pode ser igual ou superior á de remate"
|
||||||
|
|||||||
@@ -176,7 +176,8 @@ it:
|
|||||||
link: "Traguardi"
|
link: "Traguardi"
|
||||||
heading_selection_title: "Per circoscrizione"
|
heading_selection_title: "Per circoscrizione"
|
||||||
filters:
|
filters:
|
||||||
all: "Tutto (%{count})"
|
status:
|
||||||
|
all: "Tutto (%{count})"
|
||||||
phases:
|
phases:
|
||||||
errors:
|
errors:
|
||||||
dates_range_invalid: "La Data di inizio non può essere uguale o successiva alla Data finale"
|
dates_range_invalid: "La Data di inizio non può essere uguale o successiva alla Data finale"
|
||||||
|
|||||||
@@ -184,8 +184,9 @@ nl:
|
|||||||
heading_selection_title: "Per wijk"
|
heading_selection_title: "Per wijk"
|
||||||
no_winner_investments: "Geen geaccepteerde investeringen in deze status"
|
no_winner_investments: "Geen geaccepteerde investeringen in deze status"
|
||||||
filters:
|
filters:
|
||||||
label: "Status van het project"
|
status:
|
||||||
all: "Alle (%{count})"
|
label: "Status van het project"
|
||||||
|
all: "Alle (%{count})"
|
||||||
phases:
|
phases:
|
||||||
errors:
|
errors:
|
||||||
dates_range_invalid: "De begindatum dient kleiner te zijn dan de einddatum"
|
dates_range_invalid: "De begindatum dient kleiner te zijn dan de einddatum"
|
||||||
|
|||||||
@@ -181,8 +181,9 @@ so:
|
|||||||
heading_selection_title: "Degmo ahaan"
|
heading_selection_title: "Degmo ahaan"
|
||||||
no_winner_investments: "Mana jiraan maalgalin ku guuleysta gobolkan"
|
no_winner_investments: "Mana jiraan maalgalin ku guuleysta gobolkan"
|
||||||
filters:
|
filters:
|
||||||
label: "Mashruca hada gobolka kasocda"
|
status:
|
||||||
all: "Dhaman%{count}"
|
label: "Mashruca hada gobolka kasocda"
|
||||||
|
all: "Dhaman%{count}"
|
||||||
phases:
|
phases:
|
||||||
errors:
|
errors:
|
||||||
dates_range_invalid: "Taariikhda bilowga ma noqon karto mid siman ama ka dambeysa taariikhda dhammaadka"
|
dates_range_invalid: "Taariikhda bilowga ma noqon karto mid siman ama ka dambeysa taariikhda dhammaadka"
|
||||||
|
|||||||
@@ -181,8 +181,9 @@ sq:
|
|||||||
heading_selection_title: "Nga rrethi"
|
heading_selection_title: "Nga rrethi"
|
||||||
no_winner_investments: "Asnjë investim fitues në këtë gjendje"
|
no_winner_investments: "Asnjë investim fitues në këtë gjendje"
|
||||||
filters:
|
filters:
|
||||||
label: "Gjendja aktuale e projektit"
|
status:
|
||||||
all: "Të gjitha (%{count})"
|
label: "Gjendja aktuale e projektit"
|
||||||
|
all: "Të gjitha (%{count})"
|
||||||
phases:
|
phases:
|
||||||
errors:
|
errors:
|
||||||
dates_range_invalid: "Data e fillimit nuk mund të jetë e barabartë ose më vonë se data e përfundimit"
|
dates_range_invalid: "Data e fillimit nuk mund të jetë e barabartë ose më vonë se data e përfundimit"
|
||||||
|
|||||||
@@ -182,8 +182,9 @@ val:
|
|||||||
heading_selection_title: "Àmbit d'actuació"
|
heading_selection_title: "Àmbit d'actuació"
|
||||||
no_winner_investments: "No hi ha propostes en aquest estat"
|
no_winner_investments: "No hi ha propostes en aquest estat"
|
||||||
filters:
|
filters:
|
||||||
label: "Estat actual del projecte"
|
status:
|
||||||
all: "Tots (%{count})"
|
label: "Estat actual del projecte"
|
||||||
|
all: "Tots (%{count})"
|
||||||
phases:
|
phases:
|
||||||
errors:
|
errors:
|
||||||
dates_range_invalid: "La data d'inici no ha de ser igual o posterior a la data de fi"
|
dates_range_invalid: "La data d'inici no ha de ser igual o posterior a la data de fi"
|
||||||
|
|||||||
@@ -176,8 +176,9 @@ zh-CN:
|
|||||||
heading_selection_title: "按区域"
|
heading_selection_title: "按区域"
|
||||||
no_winner_investments: "这个州里没有胜出的投资"
|
no_winner_investments: "这个州里没有胜出的投资"
|
||||||
filters:
|
filters:
|
||||||
label: "项目的当前状态"
|
status:
|
||||||
all: "所有(%{count})"
|
label: "项目的当前状态"
|
||||||
|
all: "所有(%{count})"
|
||||||
phases:
|
phases:
|
||||||
errors:
|
errors:
|
||||||
dates_range_invalid: "开始日期不能等于或晚于结束日期"
|
dates_range_invalid: "开始日期不能等于或晚于结束日期"
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ FactoryBot.define do
|
|||||||
|
|
||||||
trait :published do
|
trait :published do
|
||||||
published_at { Time.current }
|
published_at { Time.current }
|
||||||
|
end
|
||||||
|
|
||||||
trait :with_milestone_tags do
|
trait :with_milestone_tags do
|
||||||
after(:create) { |proposal| proposal.milestone_tags << create(:tag, :milestone) }
|
after(:create) { |proposal| proposal.milestone_tags << create(:tag, :milestone) }
|
||||||
|
|||||||
@@ -1335,6 +1335,7 @@ describe "Admin budget investments" do
|
|||||||
budget_investment = create(:budget_investment)
|
budget_investment = create(:budget_investment)
|
||||||
|
|
||||||
visit admin_budget_budget_investment_path(budget_investment.budget, budget_investment)
|
visit admin_budget_budget_investment_path(budget_investment.budget, budget_investment)
|
||||||
|
|
||||||
expect(page).not_to have_content("Milestone Tags:")
|
expect(page).not_to have_content("Milestone Tags:")
|
||||||
|
|
||||||
click_link "Edit classification"
|
click_link "Edit classification"
|
||||||
|
|||||||
@@ -235,6 +235,52 @@ describe "Executions" do
|
|||||||
select "Bidding (0)", from: "status"
|
select "Bidding (0)", from: "status"
|
||||||
expect(page).not_to have_content(investment1.title)
|
expect(page).not_to have_content(investment1.title)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario "by milestone tag, only display tags for winner investments", :js do
|
||||||
|
create(:milestone, milestoneable: investment1, status: status1)
|
||||||
|
create(:milestone, milestoneable: investment2, status: status2)
|
||||||
|
create(:milestone, milestoneable: investment3, status: status2)
|
||||||
|
investment1.milestone_tag_list.add("tag1", "tag2")
|
||||||
|
investment1.save
|
||||||
|
investment2.milestone_tag_list.add("tag2")
|
||||||
|
investment2.save
|
||||||
|
investment3.milestone_tag_list.add("tag2")
|
||||||
|
investment3.save
|
||||||
|
|
||||||
|
visit budget_path(budget)
|
||||||
|
|
||||||
|
click_link "See results"
|
||||||
|
click_link "Milestones"
|
||||||
|
|
||||||
|
expect(page).to have_content(investment1.title)
|
||||||
|
expect(page).to have_content(investment2.title)
|
||||||
|
|
||||||
|
select "tag2 (2)", from: "milestone_tag"
|
||||||
|
|
||||||
|
expect(page).to have_content(investment1.title)
|
||||||
|
expect(page).to have_content(investment2.title)
|
||||||
|
|
||||||
|
select "Studying the project (1)", from: "status"
|
||||||
|
|
||||||
|
expect(page).to have_content(investment1.title)
|
||||||
|
expect(page).not_to have_content(investment2.title)
|
||||||
|
|
||||||
|
select "Bidding (1)", from: "status"
|
||||||
|
|
||||||
|
expect(page).not_to have_content(investment1.title)
|
||||||
|
expect(page).to have_content(investment2.title)
|
||||||
|
|
||||||
|
select "tag1 (1)", from: "milestone_tag"
|
||||||
|
|
||||||
|
expect(page).not_to have_content(investment1.title)
|
||||||
|
expect(page).not_to have_content(investment2.title)
|
||||||
|
|
||||||
|
select "All (2)", from: "milestone_tag"
|
||||||
|
|
||||||
|
expect(page).not_to have_content(investment1.title)
|
||||||
|
expect(page).to have_content(investment2.title)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "Heading Order" do
|
context "Heading Order" do
|
||||||
|
|||||||
@@ -1274,17 +1274,22 @@ describe Budget::Investment do
|
|||||||
describe "milestone_tags" do
|
describe "milestone_tags" do
|
||||||
context "without milestone_tags" do
|
context "without milestone_tags" do
|
||||||
let(:investment) {create(:budget_investment)}
|
let(:investment) {create(:budget_investment)}
|
||||||
|
|
||||||
it "do not have milestone_tags" do
|
it "do not have milestone_tags" do
|
||||||
expect(investment.milestone_tag_list).to eq([])
|
expect(investment.milestone_tag_list).to eq([])
|
||||||
expect(investment.milestone_tags).to eq([])
|
expect(investment.milestone_tags).to eq([])
|
||||||
end
|
end
|
||||||
|
|
||||||
it "add a new milestone_tag" do
|
it "add a new milestone_tag" do
|
||||||
investment.milestone_tag_list = "tag1,tag2"
|
investment.milestone_tag_list = "tag1,tag2"
|
||||||
|
|
||||||
expect(investment.milestone_tag_list).to eq(["tag1", "tag2"])
|
expect(investment.milestone_tag_list).to eq(["tag1", "tag2"])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with milestone_tags" do
|
context "with milestone_tags" do
|
||||||
let(:investment) {create(:budget_investment, :with_milestone_tags)}
|
let(:investment) {create(:budget_investment, :with_milestone_tags)}
|
||||||
|
|
||||||
it "has milestone_tags" do
|
it "has milestone_tags" do
|
||||||
expect(investment.milestone_tag_list.count).to eq(1)
|
expect(investment.milestone_tag_list.count).to eq(1)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -306,4 +306,46 @@ describe Budget do
|
|||||||
expect(budget.formatted_amount(1000.00)).to eq ("€1,000")
|
expect(budget.formatted_amount(1000.00)).to eq ("€1,000")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#milestone_tags" do
|
||||||
|
let(:investment1) { build(:budget_investment, :winner) }
|
||||||
|
let(:investment2) { build(:budget_investment, :winner) }
|
||||||
|
let(:investment3) { build(:budget_investment) }
|
||||||
|
|
||||||
|
it "returns an empty array if not investments milestone_tags" do
|
||||||
|
budget.investments << investment1
|
||||||
|
|
||||||
|
expect(budget.milestone_tags).to eq([])
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns array of investments milestone_tags" do
|
||||||
|
investment1.milestone_tag_list = "tag1"
|
||||||
|
investment1.save
|
||||||
|
budget.investments << investment1
|
||||||
|
|
||||||
|
expect(budget.milestone_tags).to eq(["tag1"])
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns uniq list of investments milestone_tags" do
|
||||||
|
investment1.milestone_tag_list = "tag1"
|
||||||
|
investment1.save
|
||||||
|
investment2.milestone_tag_list = "tag1"
|
||||||
|
investment2.save
|
||||||
|
budget.investments << investment1
|
||||||
|
budget.investments << investment2
|
||||||
|
|
||||||
|
expect(budget.milestone_tags).to eq(["tag1"])
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns tags only for winner investments" do
|
||||||
|
investment1.milestone_tag_list = "tag1"
|
||||||
|
investment1.save
|
||||||
|
investment3.milestone_tag_list = "tag2"
|
||||||
|
investment3.save
|
||||||
|
budget.investments << investment1
|
||||||
|
budget.investments << investment3
|
||||||
|
|
||||||
|
expect(budget.milestone_tags).to eq(["tag1"])
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -197,21 +197,28 @@ describe Legislation::Process do
|
|||||||
describe "milestone_tags" do
|
describe "milestone_tags" do
|
||||||
context "without milestone_tags" do
|
context "without milestone_tags" do
|
||||||
let(:process) {create(:legislation_process)}
|
let(:process) {create(:legislation_process)}
|
||||||
|
|
||||||
it "do not have milestone_tags" do
|
it "do not have milestone_tags" do
|
||||||
expect(process.milestone_tag_list).to eq([])
|
expect(process.milestone_tag_list).to eq([])
|
||||||
expect(process.milestone_tags).to eq([])
|
expect(process.milestone_tags).to eq([])
|
||||||
end
|
end
|
||||||
|
|
||||||
it "add a new milestone_tag" do
|
it "add a new milestone_tag" do
|
||||||
process.milestone_tag_list = "tag1,tag2"
|
process.milestone_tag_list = "tag1,tag2"
|
||||||
|
|
||||||
expect(process.milestone_tag_list).to eq(["tag1", "tag2"])
|
expect(process.milestone_tag_list).to eq(["tag1", "tag2"])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with milestone_tags" do
|
context "with milestone_tags" do
|
||||||
|
|
||||||
let(:process) {create(:legislation_process, :with_milestone_tags)}
|
let(:process) {create(:legislation_process, :with_milestone_tags)}
|
||||||
|
|
||||||
it "has milestone_tags" do
|
it "has milestone_tags" do
|
||||||
expect(process.milestone_tag_list.count).to eq(1)
|
expect(process.milestone_tag_list.count).to eq(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user