diff --git a/app/controllers/admin/budget_investments_controller.rb b/app/controllers/admin/budget_investments_controller.rb index b47fd4e49..743faa166 100644 --- a/app/controllers/admin/budget_investments_controller.rb +++ b/app/controllers/admin/budget_investments_controller.rb @@ -3,7 +3,7 @@ class Admin::BudgetInvestmentsController < Admin::BaseController feature_flag :budgets has_filters(%w{valuation_open without_admin managed valuating valuation_finished - valuation_finished_feasible selected all}, + valuation_finished_feasible selected winners all}, only: [:index, :toggle_selection]) before_action :load_budget diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index 01ab15de3..b3b51996c 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -49,6 +49,7 @@ class Budget scope :undecided, -> { where(feasibility: "undecided") } scope :with_supports, -> { where('cached_votes_up > 0') } scope :selected, -> { feasible.where(selected: true) } + scope :winners, -> { selected.where(winner: true) } scope :unselected, -> { not_unfeasible.where(selected: false) } scope :last_week, -> { where("created_at >= ?", 7.days.ago)} diff --git a/app/views/admin/budget_investments/_investments.html.erb b/app/views/admin/budget_investments/_investments.html.erb index 475b582f5..0c56e579c 100644 --- a/app/views/admin/budget_investments/_investments.html.erb +++ b/app/views/admin/budget_investments/_investments.html.erb @@ -12,6 +12,7 @@ <%= t("admin.budget_investments.index.table_feasibility") %> <%= t("admin.budget_investments.index.table_valuation_finished") %> <%= t("admin.budget_investments.index.table_selection") %> + <%= t("admin.budget_investments.index.table_winner") %> @@ -74,6 +75,9 @@ <% end %> <% end %> + + <%= investment.winner? ? t('shared.yes'): t('shared.no') %> + <% end %> diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index 1ba256dfe..bbd8dd1bd 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -135,6 +135,7 @@ en: table_feasibility: "Feasibility" table_valuation_finished: "Val. Fin." table_selection: "Selection" + table_winner: "Winner" show: assigned_admin: Assigned administrator assigned_valuators: Assigned valuators diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index 1cd133da4..a3c6a99b9 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -135,6 +135,7 @@ es: table_feasibility: "Viabilidad" table_valuation_finished: "Ev. Fin." table_selection: "Selección" + table_winner: "Ganadora" show: assigned_admin: Administrador asignado assigned_valuators: Evaluadores asignados diff --git a/config/locales/admin.fr.yml b/config/locales/admin.fr.yml index 72e56ef31..8100a95a6 100644 --- a/config/locales/admin.fr.yml +++ b/config/locales/admin.fr.yml @@ -135,6 +135,7 @@ fr: table_feasibility: "Faisabilité" table_valuation_finished: "Ev. Ter." table_selection: "Sélection" + table_winner: "Winner" show: assigned_admin: Administrateur assigné assigned_valuators: Évaluateur assigné diff --git a/config/locales/admin.nl.yml b/config/locales/admin.nl.yml index 567733232..40b21ed32 100755 --- a/config/locales/admin.nl.yml +++ b/config/locales/admin.nl.yml @@ -135,6 +135,7 @@ nl: table_feasibility: "Feasibility" table_valuation_finished: "Val. Fin." table_selection: "Selection" + table_winner: "Winner" show: assigned_admin: Assigned administrator assigned_valuators: Assigned valuators diff --git a/spec/factories.rb b/spec/factories.rb index 6d9cb8ddd..42c8dbfc5 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -291,6 +291,12 @@ FactoryGirl.define do selected true feasibility "feasible" valuation_finished true + + end + + trait :winner do + selected + winner true end trait :unselected do diff --git a/spec/features/admin/budget_investments_spec.rb b/spec/features/admin/budget_investments_spec.rb index 199db0d38..52c008c18 100644 --- a/spec/features/admin/budget_investments_spec.rb +++ b/spec/features/admin/budget_investments_spec.rb @@ -463,6 +463,7 @@ feature 'Admin budget investments' do let!(:feasible_bi) { create(:budget_investment, :feasible, budget: @budget, title: "Feasible project") } let!(:feasible_vf_bi) { create(:budget_investment, :feasible, :finished, budget: @budget, title: "Feasible, VF project") } let!(:selected_bi) { create(:budget_investment, :selected, budget: @budget, title: "Selected project") } + let!(:winner_bi) { create(:budget_investment, :winner, budget: @budget, title: "Winner project") } scenario "Filtering by valuation and selection" do visit admin_budget_budget_investments_path(@budget) @@ -472,18 +473,28 @@ feature 'Admin budget investments' do expect(page).to_not have_content(feasible_bi.title) expect(page).to have_content(feasible_vf_bi.title) expect(page).to have_content(selected_bi.title) + expect(page).to have_content(winner_bi.title) within('#filter-subnav') { click_link 'Val. fin. Feasible' } expect(page).to_not have_content(unfeasible_bi.title) expect(page).to_not have_content(feasible_bi.title) expect(page).to have_content(feasible_vf_bi.title) expect(page).to have_content(selected_bi.title) + expect(page).to have_content(winner_bi.title) within('#filter-subnav') { click_link 'Selected' } expect(page).to_not have_content(unfeasible_bi.title) expect(page).to_not have_content(feasible_bi.title) expect(page).to_not have_content(feasible_vf_bi.title) expect(page).to have_content(selected_bi.title) + expect(page).to have_content(winner_bi.title) + + within('#filter-subnav') { click_link 'Winners' } + expect(page).to_not have_content(unfeasible_bi.title) + expect(page).to_not have_content(feasible_bi.title) + expect(page).to_not have_content(feasible_vf_bi.title) + expect(page).to_not have_content(selected_bi.title) + expect(page).to have_content(winner_bi.title) end scenario "Showing the selection buttons", :js do @@ -532,14 +543,14 @@ feature 'Admin budget investments' do visit admin_budget_budget_investments_path(@budget) within('#filter-subnav') { click_link 'Selected' } - expect(page).to have_content('There is 1 investment') + expect(page).to have_content('There are 2 investments') within("#budget_investment_#{selected_bi.id}") do click_link('Selected') end expect(page).to_not have_content(selected_bi.title) - expect(page).to have_content('investments cannot be found') + expect(page).to have_content('There is 1 investment') within('#filter-subnav') { click_link 'All' }