adds index of investments with filters to admin
This commit is contained in:
15
app/controllers/admin/budget_investments_controller.rb
Normal file
15
app/controllers/admin/budget_investments_controller.rb
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
class Admin::BudgetInvestmentsController < Admin::BaseController
|
||||||
|
|
||||||
|
has_filters %w{valuation_open without_admin managed valuating valuation_finished all}, only: :index
|
||||||
|
|
||||||
|
def index
|
||||||
|
@budget = Budget.includes(:groups).find params[:budget_id]
|
||||||
|
@investments = @budget.investments.scoped_filter(params, @current_filter).order(cached_votes_up: :desc, created_at: :desc).page(params[:page])
|
||||||
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
@budget = Budget.includes(:groups).find params[:budget_id]
|
||||||
|
@investment = @budget.investments.find params[:id]
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
7
app/helpers/budget_groups_helper.rb
Normal file
7
app/helpers/budget_groups_helper.rb
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
module BudgetGroupsHelper
|
||||||
|
|
||||||
|
def budget_group_select_options(groups)
|
||||||
|
groups.map {|group| [group.name, group.id]}
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
76
app/views/admin/budget_investments/index.html.erb
Normal file
76
app/views/admin/budget_investments/index.html.erb
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
<h2 class="inline-block"><%= @budget.name %> - <%= t("admin.budget_investments.index.title") %></h2>
|
||||||
|
|
||||||
|
<div class="row margin">
|
||||||
|
<%= form_tag admin_budget_budget_investments_path(budget: @budget), method: :get, enforce_utf8: false do %>
|
||||||
|
<div class="small-12 medium-3 column">
|
||||||
|
<%= select_tag :administrator_id,
|
||||||
|
options_for_select(admin_select_options, params[:administrator_id]),
|
||||||
|
{ prompt: t("admin.budget_investments.index.administrator_filter_all"),
|
||||||
|
label: false,
|
||||||
|
class: "js-submit-on-change" } %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="small-12 medium-3 column">
|
||||||
|
<%= select_tag :valuator_id,
|
||||||
|
options_for_select(valuator_select_options, params[:valuator_id]),
|
||||||
|
{ prompt: t("admin.budget_investments.index.valuator_filter_all"),
|
||||||
|
label: false,
|
||||||
|
class: "js-submit-on-change" } %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="small-12 medium-3 column">
|
||||||
|
<%= select_tag :group_id,
|
||||||
|
options_for_select(budget_group_select_options(@budget.groups), params[:group_id]),
|
||||||
|
{ prompt: t("admin.budget_investments.index.group_filter_all"),
|
||||||
|
label: false,
|
||||||
|
class: "js-submit-on-change" } %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="small-12 medium-3 column">
|
||||||
|
<%= select_tag :tag_name,
|
||||||
|
options_for_select(spending_proposal_tags_select_options, params[:tag_name]),
|
||||||
|
{ prompt: t("admin.budget_investments.index.tags_filter_all"),
|
||||||
|
label: false,
|
||||||
|
class: "js-submit-on-change" } %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= render 'shared/filter_subnav', i18n_namespace: "admin.budget_investments.index" %>
|
||||||
|
|
||||||
|
<h3><%= page_entries_info @investments %></h3>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<% @investments.each do |investment| %>
|
||||||
|
<tr id="<%= dom_id(investment) %>" class="budget_investment">
|
||||||
|
<td>
|
||||||
|
<strong><%= investment.id %></strong>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= link_to investment.title, admin_budget_budget_investment_path(budget_id: @budget.id, id: investment.id), Budget::Investment.filter_params(params) %>
|
||||||
|
</td>
|
||||||
|
<td class="small">
|
||||||
|
<% if investment.administrator.present? %>
|
||||||
|
<span title="<%= t('admin.budget_investments.index.assigned_admin') %>"><%= investment.administrator.name %></span>
|
||||||
|
<% else %>
|
||||||
|
<%= t("admin.budget_investments.index.no_admin_assigned") %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<td class="small">
|
||||||
|
<% if investment.valuators.size == 0 %>
|
||||||
|
<%= t("admin.budget_investments.index.no_valuators_assigned") %>
|
||||||
|
<% else %>
|
||||||
|
<%= investment.valuators.collect(&:description_or_name).join(', ') %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<td class="small">
|
||||||
|
<%= investment.group.name %>
|
||||||
|
</td>
|
||||||
|
<td class="small">
|
||||||
|
<%= t("admin.budget_investments.index.feasibility.#{investment.feasibility}", price: investment.price) %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<%= paginate @investments %>
|
||||||
1
app/views/admin/budget_investments/show.html.erb
Normal file
1
app/views/admin/budget_investments/show.html.erb
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<%= @investment.title %>
|
||||||
@@ -13,11 +13,14 @@
|
|||||||
<% @budgets.each do |budget| %>
|
<% @budgets.each do |budget| %>
|
||||||
<tr id="<%= dom_id(budget) %>" class="budget">
|
<tr id="<%= dom_id(budget) %>" class="budget">
|
||||||
<td>
|
<td>
|
||||||
<%= link_to budget.name, admin_budget_path(budget) %>
|
<%= link_to budget.name, admin_budget_budget_investments_path(budget_id: budget.id) %>
|
||||||
</td>
|
</td>
|
||||||
<td class="small">
|
<td class="small">
|
||||||
<%= t("budget.phase.#{budget.phase}") %>
|
<%= t("budget.phase.#{budget.phase}") %>
|
||||||
</td>
|
</td>
|
||||||
|
<td class="small">
|
||||||
|
<%= link_to t("admin.budgets.index.info_link"), admin_budget_path(budget) %>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ ignore_unused:
|
|||||||
- 'admin.debates.index.filter*'
|
- 'admin.debates.index.filter*'
|
||||||
- 'admin.proposals.index.filter*'
|
- 'admin.proposals.index.filter*'
|
||||||
- 'admin.budgets.index.filter*'
|
- 'admin.budgets.index.filter*'
|
||||||
|
- 'admin.budget_investments.index.filter*'
|
||||||
- 'admin.spending_proposals.index.filter*'
|
- 'admin.spending_proposals.index.filter*'
|
||||||
- 'admin.organizations.index.filter*'
|
- 'admin.organizations.index.filter*'
|
||||||
- 'admin.users.index.filter*'
|
- 'admin.users.index.filter*'
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ es:
|
|||||||
budget:
|
budget:
|
||||||
one: "Presupuesto participativo"
|
one: "Presupuesto participativo"
|
||||||
other: "Presupuestos participativos"
|
other: "Presupuestos participativos"
|
||||||
|
budget/investment:
|
||||||
|
one: "Propuesta de inversión"
|
||||||
|
other: "Propuestas de inversión"
|
||||||
comment:
|
comment:
|
||||||
one: "Comentario"
|
one: "Comentario"
|
||||||
other: "Comentarios"
|
other: "Comentarios"
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ en:
|
|||||||
index:
|
index:
|
||||||
title: Participatory budgets
|
title: Participatory budgets
|
||||||
new_link: Create new
|
new_link: Create new
|
||||||
|
info_link: Info
|
||||||
filters:
|
filters:
|
||||||
open: Open
|
open: Open
|
||||||
finished: Finished
|
finished: Finished
|
||||||
@@ -92,6 +93,27 @@ en:
|
|||||||
table_heading: Heading
|
table_heading: Heading
|
||||||
table_amount: Amount
|
table_amount: Amount
|
||||||
table_geozone: Scope of operation
|
table_geozone: Scope of operation
|
||||||
|
budget_investments:
|
||||||
|
index:
|
||||||
|
group_filter_all: All voting groups
|
||||||
|
administrator_filter_all: All administrators
|
||||||
|
valuator_filter_all: All valuators
|
||||||
|
tags_filter_all: All tags
|
||||||
|
filters:
|
||||||
|
valuation_open: Open
|
||||||
|
without_admin: Without assigned admin
|
||||||
|
managed: Managed
|
||||||
|
valuating: Under valuation
|
||||||
|
valuation_finished: Valuation finished
|
||||||
|
all: All
|
||||||
|
title: Investment projects
|
||||||
|
assigned_admin: Assigned administrator
|
||||||
|
no_admin_assigned: No admin assigned
|
||||||
|
no_valuators_assigned: No valuators assigned
|
||||||
|
feasibility:
|
||||||
|
feasible: "Feasible (%{price})"
|
||||||
|
not_feasible: "Not feasible"
|
||||||
|
undefined: "Undefined"
|
||||||
comments:
|
comments:
|
||||||
index:
|
index:
|
||||||
filter: Filter
|
filter: Filter
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ es:
|
|||||||
index:
|
index:
|
||||||
title: Presupuestos participativos
|
title: Presupuestos participativos
|
||||||
new_link: Crear nuevo
|
new_link: Crear nuevo
|
||||||
|
info_link: Info
|
||||||
filters:
|
filters:
|
||||||
open: Abiertos
|
open: Abiertos
|
||||||
finished: Terminados
|
finished: Terminados
|
||||||
@@ -92,6 +93,27 @@ es:
|
|||||||
table_heading: Partida
|
table_heading: Partida
|
||||||
table_amount: Cantidad
|
table_amount: Cantidad
|
||||||
table_geozone: Ámbito de actuación
|
table_geozone: Ámbito de actuación
|
||||||
|
budget_investments:
|
||||||
|
index:
|
||||||
|
group_filter_all: Todos los grupos
|
||||||
|
administrator_filter_all: Todos los administradores
|
||||||
|
valuator_filter_all: Todos los evaluadores
|
||||||
|
tags_filter_all: Todas las etiquetas
|
||||||
|
filters:
|
||||||
|
valuation_open: Abiertas
|
||||||
|
without_admin: Sin administrador
|
||||||
|
managed: Gestionando
|
||||||
|
valuating: En evaluación
|
||||||
|
valuation_finished: Evaluación finalizada
|
||||||
|
all: Todas
|
||||||
|
title: Propuestas de inversión
|
||||||
|
assigned_admin: Administrador asignado
|
||||||
|
no_admin_assigned: Sin admin asignado
|
||||||
|
no_valuators_assigned: Sin evaluador
|
||||||
|
feasibility:
|
||||||
|
feasible: "Viable (%{price})"
|
||||||
|
not_feasible: "Inviable"
|
||||||
|
undefined: "Sin definir"
|
||||||
comments:
|
comments:
|
||||||
index:
|
index:
|
||||||
filter: Filtro
|
filter: Filtro
|
||||||
|
|||||||
@@ -161,6 +161,8 @@ Rails.application.routes.draw do
|
|||||||
resources :budget_headings do
|
resources :budget_headings do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
resources :budget_investments, only: [:index, :show]
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :banners, only: [:index, :new, :create, :edit, :update, :destroy] do
|
resources :banners, only: [:index, :new, :create, :edit, :update, :destroy] do
|
||||||
|
|||||||
298
spec/features/admin/budget_investments_spec.rb
Normal file
298
spec/features/admin/budget_investments_spec.rb
Normal file
@@ -0,0 +1,298 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
feature 'Admin budget investments' do
|
||||||
|
|
||||||
|
background do
|
||||||
|
admin = create(:administrator)
|
||||||
|
login_as(admin.user)
|
||||||
|
|
||||||
|
@budget = create(:budget)
|
||||||
|
end
|
||||||
|
|
||||||
|
context "Index" do
|
||||||
|
|
||||||
|
scenario 'Displaying investmentss' do
|
||||||
|
budget_investment = create(:budget_investment, budget: @budget)
|
||||||
|
visit admin_budget_budget_investments_path(budget_id: @budget.id)
|
||||||
|
expect(page).to have_content(budget_investment.title)
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'Displaying assignments info' do
|
||||||
|
budget_investment1 = create(:budget_investment, budget: @budget)
|
||||||
|
budget_investment2 = create(:budget_investment, budget: @budget)
|
||||||
|
budget_investment3 = create(:budget_investment, budget: @budget)
|
||||||
|
|
||||||
|
valuator1 = create(:valuator, user: create(:user, username: 'Olga'), description: 'Valuator Olga')
|
||||||
|
valuator2 = create(:valuator, user: create(:user, username: 'Miriam'), description: 'Valuator Miriam')
|
||||||
|
admin = create(:administrator, user: create(:user, username: 'Gema'))
|
||||||
|
|
||||||
|
budget_investment1.valuators << valuator1
|
||||||
|
budget_investment2.valuator_ids = [valuator1.id, valuator2.id]
|
||||||
|
budget_investment3.update({administrator_id: admin.id})
|
||||||
|
|
||||||
|
visit admin_budget_budget_investments_path(budget_id: @budget.id)
|
||||||
|
|
||||||
|
within("#budget_investment_#{budget_investment1.id}") do
|
||||||
|
expect(page).to have_content("No admin assigned")
|
||||||
|
expect(page).to have_content("Valuator Olga")
|
||||||
|
end
|
||||||
|
|
||||||
|
within("#budget_investment_#{budget_investment2.id}") do
|
||||||
|
expect(page).to have_content("No admin assigned")
|
||||||
|
expect(page).to have_content("Valuator Olga")
|
||||||
|
expect(page).to have_content("Valuator Miriam")
|
||||||
|
end
|
||||||
|
|
||||||
|
within("#budget_investment_#{budget_investment3.id}") do
|
||||||
|
expect(page).to have_content("Gema")
|
||||||
|
expect(page).to have_content("No valuators assigned")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "Filtering by budget group", :js do
|
||||||
|
group1 = create(:budget_group, name: "Street improvments", budget: @budget)
|
||||||
|
group2 = create(:budget_group, name: "Parks", budget: @budget)
|
||||||
|
|
||||||
|
create(:budget_investment, title: "Realocate visitors", budget: @budget, group: group1)
|
||||||
|
create(:budget_investment, title: "Destroy the city", budget: @budget, group: group2)
|
||||||
|
|
||||||
|
visit admin_budget_budget_investments_path(budget_id: @budget.id)
|
||||||
|
|
||||||
|
expect(page).to have_link("Realocate visitors")
|
||||||
|
expect(page).to have_link("Destroy the city")
|
||||||
|
|
||||||
|
select "Parks", from: "group_id"
|
||||||
|
|
||||||
|
expect(page).to have_link("Destroy the city")
|
||||||
|
expect(page).to_not have_link("Realocate visitors")
|
||||||
|
|
||||||
|
select "All voting groups", from: "group_id"
|
||||||
|
|
||||||
|
expect(page).to have_link("Realocate visitors")
|
||||||
|
expect(page).to have_link("Destroy the city")
|
||||||
|
|
||||||
|
select "Street improvments", from: "group_id"
|
||||||
|
|
||||||
|
expect(page).to_not have_link("Destroy the city")
|
||||||
|
expect(page).to have_link("Realocate visitors")
|
||||||
|
|
||||||
|
# click_link("Realocate visitors")
|
||||||
|
# click_link("Back")
|
||||||
|
|
||||||
|
# expect(page).to_not have_link("Destroy the city")
|
||||||
|
# expect(page).to have_link("Realocate visitors")
|
||||||
|
|
||||||
|
# click_link("Realocate visitors")
|
||||||
|
# click_link("Edit classification")
|
||||||
|
# expect(page).to have_button("Update")
|
||||||
|
# click_link("Back")
|
||||||
|
# expect(page).to_not have_button("Update")
|
||||||
|
# click_link("Back")
|
||||||
|
|
||||||
|
# expect(page).to_not have_link("Destroy the city")
|
||||||
|
# expect(page).to have_link("Realocate visitors")
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "Filtering by admin", :js do
|
||||||
|
user = create(:user, username: 'Admin 1')
|
||||||
|
administrator = create(:administrator, user: user)
|
||||||
|
|
||||||
|
create(:budget_investment, title: "Realocate visitors", budget: @budget, administrator: administrator)
|
||||||
|
create(:budget_investment, title: "Destroy the city", budget: @budget)
|
||||||
|
|
||||||
|
visit admin_budget_budget_investments_path(budget_id: @budget.id)
|
||||||
|
expect(page).to have_link("Realocate visitors")
|
||||||
|
expect(page).to have_link("Destroy the city")
|
||||||
|
|
||||||
|
select "Admin 1", from: "administrator_id"
|
||||||
|
|
||||||
|
expect(page).to have_content('There is 1 investment')
|
||||||
|
expect(page).to_not have_link("Destroy the city")
|
||||||
|
expect(page).to have_link("Realocate visitors")
|
||||||
|
|
||||||
|
select "All administrators", from: "administrator_id"
|
||||||
|
|
||||||
|
expect(page).to have_content('There are 2 investments')
|
||||||
|
expect(page).to have_link("Destroy the city")
|
||||||
|
expect(page).to have_link("Realocate visitors")
|
||||||
|
|
||||||
|
select "Admin 1", from: "administrator_id"
|
||||||
|
expect(page).to have_content('There is 1 investment')
|
||||||
|
|
||||||
|
# click_link("Realocate visitors")
|
||||||
|
# click_link("Back")
|
||||||
|
|
||||||
|
# expect(page).to have_content('There is 1 investment')
|
||||||
|
# expect(page).to_not have_link("Destroy the city")
|
||||||
|
# expect(page).to have_link("Realocate visitors")
|
||||||
|
|
||||||
|
# click_link("Realocate visitors")
|
||||||
|
# click_link("Edit classification")
|
||||||
|
# expect(page).to have_button("Update")
|
||||||
|
# click_link("Back")
|
||||||
|
# expect(page).to_not have_button("Update")
|
||||||
|
# click_link("Back")
|
||||||
|
|
||||||
|
# expect(page).to have_content('There is 1 investment')
|
||||||
|
# expect(page).to_not have_link("Destroy the city")
|
||||||
|
# expect(page).to have_link("Realocate visitors")
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "Filtering by valuator", :js do
|
||||||
|
user = create(:user)
|
||||||
|
valuator = create(:valuator, user: user, description: 'Valuator 1')
|
||||||
|
|
||||||
|
budget_investment = create(:budget_investment, title: "Realocate visitors", budget: @budget)
|
||||||
|
budget_investment.valuators << valuator
|
||||||
|
|
||||||
|
create(:budget_investment, title: "Destroy the city", budget: @budget)
|
||||||
|
|
||||||
|
visit admin_budget_budget_investments_path(budget_id: @budget.id)
|
||||||
|
expect(page).to have_link("Realocate visitors")
|
||||||
|
expect(page).to have_link("Destroy the city")
|
||||||
|
|
||||||
|
select "Valuator 1", from: "valuator_id"
|
||||||
|
|
||||||
|
expect(page).to have_content('There is 1 investment')
|
||||||
|
expect(page).to_not have_link("Destroy the city")
|
||||||
|
expect(page).to have_link("Realocate visitors")
|
||||||
|
|
||||||
|
select "All valuators", from: "valuator_id"
|
||||||
|
|
||||||
|
expect(page).to have_content('There are 2 investments')
|
||||||
|
expect(page).to have_link("Destroy the city")
|
||||||
|
expect(page).to have_link("Realocate visitors")
|
||||||
|
|
||||||
|
select "Valuator 1", from: "valuator_id"
|
||||||
|
expect(page).to have_content('There is 1 investment')
|
||||||
|
# click_link("Realocate visitors")
|
||||||
|
# click_link("Back")
|
||||||
|
|
||||||
|
# expect(page).to have_content('There is 1 investment')
|
||||||
|
# expect(page).to_not have_link("Destroy the city")
|
||||||
|
# expect(page).to have_link("Realocate visitors")
|
||||||
|
|
||||||
|
# click_link("Realocate visitors")
|
||||||
|
# click_link("Edit classification")
|
||||||
|
# expect(page).to have_button("Update")
|
||||||
|
# click_link("Back")
|
||||||
|
# expect(page).to_not have_button("Update")
|
||||||
|
# click_link("Back")
|
||||||
|
|
||||||
|
# expect(page).to have_content('There is 1 investment')
|
||||||
|
# expect(page).to_not have_link("Destroy the city")
|
||||||
|
# expect(page).to have_link("Realocate visitors")
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "Current filter is properly highlighted" do
|
||||||
|
filters_links = {'valuation_open' => 'Open',
|
||||||
|
'without_admin' => 'Without assigned admin',
|
||||||
|
'managed' => 'Managed',
|
||||||
|
'valuating' => 'Under valuation',
|
||||||
|
'valuation_finished' => 'Valuation finished',
|
||||||
|
'all' => 'All'}
|
||||||
|
|
||||||
|
visit admin_budget_budget_investments_path(budget_id: @budget.id)
|
||||||
|
|
||||||
|
expect(page).to_not have_link(filters_links.values.first)
|
||||||
|
filters_links.keys.drop(1).each { |filter| expect(page).to have_link(filters_links[filter]) }
|
||||||
|
|
||||||
|
filters_links.each_pair do |current_filter, link|
|
||||||
|
visit admin_budget_budget_investments_path(budget_id: @budget.id, filter: current_filter)
|
||||||
|
|
||||||
|
expect(page).to_not have_link(link)
|
||||||
|
|
||||||
|
(filters_links.keys - [current_filter]).each do |filter|
|
||||||
|
expect(page).to have_link(filters_links[filter])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "Filtering by assignment status" do
|
||||||
|
assigned = create(:budget_investment, title: "Assigned idea", budget: @budget, administrator: create(:administrator))
|
||||||
|
valuating = create(:budget_investment, title: "Evaluating...", budget: @budget)
|
||||||
|
valuating.valuators << create(:valuator)
|
||||||
|
|
||||||
|
visit admin_budget_budget_investments_path(budget_id: @budget.id, filter: 'valuation_open')
|
||||||
|
|
||||||
|
expect(page).to have_content("Assigned idea")
|
||||||
|
expect(page).to have_content("Evaluating...")
|
||||||
|
|
||||||
|
visit admin_budget_budget_investments_path(budget_id: @budget.id, filter: 'without_admin')
|
||||||
|
|
||||||
|
expect(page).to have_content("Evaluating...")
|
||||||
|
expect(page).to_not have_content("Assigned idea")
|
||||||
|
|
||||||
|
visit admin_budget_budget_investments_path(budget_id: @budget.id, filter: 'managed')
|
||||||
|
|
||||||
|
expect(page).to have_content("Assigned idea")
|
||||||
|
expect(page).to_not have_content("Evaluating...")
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "Filtering by valuation status" do
|
||||||
|
valuating = create(:budget_investment, budget: @budget, title: "Ongoing valuation")
|
||||||
|
valuated = create(:budget_investment, budget: @budget, title: "Old idea", valuation_finished: true)
|
||||||
|
valuating.valuators << create(:valuator)
|
||||||
|
valuated.valuators << create(:valuator)
|
||||||
|
|
||||||
|
visit admin_budget_budget_investments_path(budget_id: @budget.id, filter: 'valuation_open')
|
||||||
|
|
||||||
|
expect(page).to have_content("Ongoing valuation")
|
||||||
|
expect(page).to_not have_content("Old idea")
|
||||||
|
|
||||||
|
visit admin_budget_budget_investments_path(budget_id: @budget.id, filter: 'valuating')
|
||||||
|
|
||||||
|
expect(page).to have_content("Ongoing valuation")
|
||||||
|
expect(page).to_not have_content("Old idea")
|
||||||
|
|
||||||
|
visit admin_budget_budget_investments_path(budget_id: @budget.id, filter: 'valuation_finished')
|
||||||
|
|
||||||
|
expect(page).to_not have_content("Ongoing valuation")
|
||||||
|
expect(page).to have_content("Old idea")
|
||||||
|
|
||||||
|
visit admin_budget_budget_investments_path(budget_id: @budget.id, filter: 'all')
|
||||||
|
expect(page).to have_content("Ongoing valuation")
|
||||||
|
expect(page).to have_content("Old idea")
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "Filtering by tag" do
|
||||||
|
create(:budget_investment, budget: @budget, title: 'Educate the children', tag_list: 'Education')
|
||||||
|
create(:budget_investment, budget: @budget, title: 'More schools', tag_list: 'Education')
|
||||||
|
create(:budget_investment, budget: @budget, title: 'More hospitals', tag_list: 'Health')
|
||||||
|
|
||||||
|
visit admin_budget_budget_investments_path(budget_id: @budget.id)
|
||||||
|
|
||||||
|
expect(page).to have_css(".budget_investment", count: 3)
|
||||||
|
expect(page).to have_content("Educate the children")
|
||||||
|
expect(page).to have_content("More schools")
|
||||||
|
expect(page).to have_content("More hospitals")
|
||||||
|
|
||||||
|
visit admin_budget_budget_investments_path(budget_id: @budget.id, tag_name: 'Education')
|
||||||
|
|
||||||
|
expect(page).to_not have_content("More hospitals")
|
||||||
|
expect(page).to have_css(".budget_investment", count: 2)
|
||||||
|
expect(page).to have_content("Educate the children")
|
||||||
|
expect(page).to have_content("More schools")
|
||||||
|
|
||||||
|
# click_link("Educate the children")
|
||||||
|
# click_link("Back")
|
||||||
|
|
||||||
|
# expect(page).to_not have_content("More hospitals")
|
||||||
|
# expect(page).to have_content("Educate the children")
|
||||||
|
# expect(page).to have_content("More schools")
|
||||||
|
|
||||||
|
# click_link("Educate the children")
|
||||||
|
# click_link("Edit classification")
|
||||||
|
# expect(page).to have_button("Update")
|
||||||
|
# click_link("Back")
|
||||||
|
# expect(page).to_not have_button("Update")
|
||||||
|
# click_link("Back")
|
||||||
|
|
||||||
|
# expect(page).to_not have_content("More hospitals")
|
||||||
|
# expect(page).to have_content("Educate the children")
|
||||||
|
# expect(page).to have_content("More schools")
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -105,10 +105,13 @@ feature 'Admin budgets' do
|
|||||||
context 'Manage groups and headings' do
|
context 'Manage groups and headings' do
|
||||||
|
|
||||||
scenario 'Create group', :js do
|
scenario 'Create group', :js do
|
||||||
create(:budget, name: 'Yearly participatory budget')
|
budget = create(:budget, name: 'Yearly participatory budget')
|
||||||
|
|
||||||
visit admin_budgets_path
|
visit admin_budgets_path
|
||||||
click_link 'Yearly participatory budget'
|
|
||||||
|
within("#budget_#{budget.id}") do
|
||||||
|
click_link 'Info'
|
||||||
|
end
|
||||||
|
|
||||||
expect(page).to have_content 'No groups created yet.'
|
expect(page).to have_content 'No groups created yet.'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user