@@ -42,6 +42,7 @@
|
||||
//= require suggest
|
||||
//= require forms
|
||||
//= require tracks
|
||||
//= require valuation_budget_investment_form
|
||||
//= require valuation_spending_proposal_form
|
||||
//= require embed_video
|
||||
//= require banners
|
||||
@@ -63,6 +64,7 @@ var initialize_modules = function() {
|
||||
App.Suggest.initialize();
|
||||
App.Forms.initialize();
|
||||
App.Tracks.initialize();
|
||||
App.ValuationBudgetInvestmentForm.initialize();
|
||||
App.ValuationSpendingProposalForm.initialize();
|
||||
App.EmbedVideo.initialize();
|
||||
App.Banners.initialize();
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
App.ValuationBudgetInvestmentForm =
|
||||
|
||||
showFeasibleFields: ->
|
||||
$('#valuation_budget_investment_edit_form #unfeasible_fields').hide('down')
|
||||
$('#valuation_budget_investment_edit_form #feasible_fields').show()
|
||||
|
||||
showNotFeasibleFields: ->
|
||||
$('#valuation_budget_investment_edit_form #feasible_fields').hide('down')
|
||||
$('#valuation_budget_investment_edit_form #unfeasible_fields').show()
|
||||
|
||||
showAllFields: ->
|
||||
$('#valuation_budget_investment_edit_form #feasible_fields').show('down')
|
||||
$('#valuation_budget_investment_edit_form #unfeasible_fields').show('down')
|
||||
|
||||
showFeasibilityFields: ->
|
||||
feasibility = $("#valuation_budget_investment_edit_form input[type=radio][name='budget_investment[feasibility]']:checked").val()
|
||||
if feasibility == 'feasible'
|
||||
App.ValuationBudgetInvestmentForm.showFeasibleFields()
|
||||
else if feasibility == 'unfeasible'
|
||||
App.ValuationBudgetInvestmentForm.showNotFeasibleFields()
|
||||
|
||||
|
||||
showFeasibilityFieldsOnChange: ->
|
||||
$("#valuation_budget_investment_edit_form input[type=radio][name='budget_investment[feasibility]']").change ->
|
||||
App.ValuationBudgetInvestmentForm.showAllFields()
|
||||
App.ValuationBudgetInvestmentForm.showFeasibilityFields()
|
||||
|
||||
|
||||
initialize: ->
|
||||
App.ValuationBudgetInvestmentForm.showFeasibilityFields()
|
||||
App.ValuationBudgetInvestmentForm.showFeasibilityFieldsOnChange()
|
||||
false
|
||||
@@ -384,7 +384,7 @@ body.admin {
|
||||
}
|
||||
}
|
||||
|
||||
.admin-content .select-geozone {
|
||||
.admin-content .select-geozone, .admin-content .select-heading {
|
||||
|
||||
a {
|
||||
display: block;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
class Admin::BudgetGroupsController < Admin::BaseController
|
||||
include FeatureFlags
|
||||
feature_flag :budgets
|
||||
|
||||
def create
|
||||
@budget = Budget.find params[:budget_id]
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
class Admin::BudgetHeadingsController < Admin::BaseController
|
||||
include FeatureFlags
|
||||
feature_flag :budgets
|
||||
|
||||
def create
|
||||
@budget = Budget.find params[:budget_id]
|
||||
|
||||
60
app/controllers/admin/budget_investments_controller.rb
Normal file
60
app/controllers/admin/budget_investments_controller.rb
Normal file
@@ -0,0 +1,60 @@
|
||||
class Admin::BudgetInvestmentsController < Admin::BaseController
|
||||
include FeatureFlags
|
||||
feature_flag :budgets
|
||||
|
||||
before_action :load_budget
|
||||
before_action :load_investment, only: [:show, :edit, :update]
|
||||
|
||||
has_filters %w{valuation_open without_admin managed valuating valuation_finished all}, only: :index
|
||||
|
||||
def index
|
||||
@investments = Budget::Investment.scoped_filter(params, @current_filter).order(cached_votes_up: :desc, created_at: :desc).page(params[:page])
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def edit
|
||||
load_admins
|
||||
load_valuators
|
||||
load_tags
|
||||
end
|
||||
|
||||
def update
|
||||
if @investment.update(budget_investment_params)
|
||||
redirect_to admin_budget_budget_investment_path(@budget, @investment, Budget::Investment.filter_params(params)),
|
||||
notice: t("flash.actions.update.budget_investment")
|
||||
else
|
||||
load_admins
|
||||
load_valuators
|
||||
load_tags
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def budget_investment_params
|
||||
params.require(:budget_investment).permit(:title, :description, :external_url, :heading_id, :administrator_id, :tag_list, valuator_ids: [])
|
||||
end
|
||||
|
||||
def load_budget
|
||||
@budget = Budget.includes(:groups).find params[:budget_id]
|
||||
end
|
||||
|
||||
def load_investment
|
||||
@investment = Budget::Investment.where(budget_id: @budget.id).find params[:id]
|
||||
end
|
||||
|
||||
def load_admins
|
||||
@admins = Administrator.includes(:user).all
|
||||
end
|
||||
|
||||
def load_valuators
|
||||
@valuators = Valuator.includes(:user).all.order("description ASC").order("users.email ASC")
|
||||
end
|
||||
|
||||
def load_tags
|
||||
@tags = ActsAsTaggableOn::Tag.budget_investment_tags
|
||||
end
|
||||
end
|
||||
@@ -1,4 +1,6 @@
|
||||
class Admin::BudgetsController < Admin::BaseController
|
||||
include FeatureFlags
|
||||
feature_flag :budgets
|
||||
|
||||
has_filters %w{open finished}, only: :index
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
class BudgetsController < ApplicationController
|
||||
include FeatureFlags
|
||||
feature_flag :budgets
|
||||
|
||||
|
||||
load_and_authorize_resource
|
||||
respond_to :html, :js
|
||||
|
||||
79
app/controllers/valuation/budget_investments_controller.rb
Normal file
79
app/controllers/valuation/budget_investments_controller.rb
Normal file
@@ -0,0 +1,79 @@
|
||||
class Valuation::BudgetInvestmentsController < Valuation::BaseController
|
||||
include FeatureFlags
|
||||
feature_flag :budgets
|
||||
|
||||
before_action :restrict_access_to_assigned_items, only: [:show, :edit, :valuate]
|
||||
before_action :load_budget
|
||||
before_action :load_investment, only: [:show, :edit, :valuate]
|
||||
|
||||
has_filters %w{valuating valuation_finished}, only: :index
|
||||
|
||||
load_and_authorize_resource :investment, class: "Budget::Investment"
|
||||
|
||||
def index
|
||||
@heading_filters = heading_filters
|
||||
if current_user.valuator? && @budget.present?
|
||||
@investments = @budget.investments.scoped_filter(params_for_current_valuator, @current_filter).order(cached_votes_up: :desc).page(params[:page])
|
||||
else
|
||||
@investments = Budget::Investment.none.page(params[:page])
|
||||
end
|
||||
end
|
||||
|
||||
def valuate
|
||||
if valid_price_params? && @investment.update(valuation_params)
|
||||
redirect_to valuation_budget_budget_investment_path(@budget, @investment), notice: t('valuation.budget_investments.notice.valuate')
|
||||
else
|
||||
render action: :edit
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def load_budget
|
||||
@budget = Budget.find(params[:budget_id])
|
||||
end
|
||||
|
||||
def load_investment
|
||||
@investment = @budget.investments.find params[:id]
|
||||
end
|
||||
|
||||
def heading_filters
|
||||
investments = @budget.investments.by_valuator(current_user.valuator.try(:id)).valuation_open.select(:heading_id).all.to_a
|
||||
|
||||
[ { name: t('valuation.budget_investments.index.headings_filter_all'),
|
||||
id: nil,
|
||||
pending_count: investments.size
|
||||
}
|
||||
] + Budget::Heading.where(id: investments.map(&:heading_id).uniq).order(name: :asc).collect do |h|
|
||||
{ name: h.name,
|
||||
id: h.id,
|
||||
pending_count: investments.count{|x| x.heading_id == h.id}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def params_for_current_valuator
|
||||
Budget::Investment.filter_params(params).merge({valuator_id: current_user.valuator.id, budget_id: @budget.id})
|
||||
end
|
||||
|
||||
def valuation_params
|
||||
params.require(:budget_investment).permit(:price, :price_first_year, :price_explanation, :feasibility, :unfeasibility_explanation, :duration, :valuation_finished, :internal_comments)
|
||||
end
|
||||
|
||||
def restrict_access_to_assigned_items
|
||||
raise ActionController::RoutingError.new('Not Found') unless current_user.administrator? || Budget::ValuatorAssignment.exists?(investment_id: params[:id], valuator_id: current_user.valuator.id)
|
||||
end
|
||||
|
||||
def valid_price_params?
|
||||
if /\D/.match params[:budget_investment][:price]
|
||||
@investment.errors.add(:price, I18n.t('budget.investments.wrong_price_format'))
|
||||
end
|
||||
|
||||
if /\D/.match params[:budget_investment][:price_first_year]
|
||||
@investment.errors.add(:price_first_year, I18n.t('budget.investments.wrong_price_format'))
|
||||
end
|
||||
|
||||
@investment.errors.empty?
|
||||
end
|
||||
|
||||
end
|
||||
13
app/controllers/valuation/budgets_controller.rb
Normal file
13
app/controllers/valuation/budgets_controller.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class Valuation::BudgetsController < Valuation::BaseController
|
||||
include FeatureFlags
|
||||
feature_flag :budgets
|
||||
|
||||
has_filters %w{open finished}, only: :index
|
||||
|
||||
load_and_authorize_resource
|
||||
|
||||
def index
|
||||
@budgets = Budget.send(@current_filter).order(created_at: :desc).page(params[:page])
|
||||
end
|
||||
|
||||
end
|
||||
@@ -58,7 +58,7 @@ class Valuation::SpendingProposalsController < Valuation::BaseController
|
||||
end
|
||||
|
||||
def params_for_current_valuator
|
||||
params.merge({valuator_id: current_user.valuator.id})
|
||||
params.merge({valuator_id: current_user.valuator.id})
|
||||
end
|
||||
|
||||
def restrict_access_to_assigned_items
|
||||
|
||||
11
app/helpers/budget_headings_helper.rb
Normal file
11
app/helpers/budget_headings_helper.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
module BudgetHeadingsHelper
|
||||
|
||||
def budget_heading_select_options(budget)
|
||||
budget.headings.map {|heading| [heading.name, heading.id]}
|
||||
end
|
||||
|
||||
def budget_scoped_heading_select_options(budget)
|
||||
budget.headings.includes(:group).order("group_id ASC, budget_headings.name ASC").map {|heading| [heading.group.name + ': ' + heading.name, heading.id]}
|
||||
end
|
||||
|
||||
end
|
||||
@@ -11,14 +11,14 @@ module ValuationHelper
|
||||
def assigned_valuators_info(valuators)
|
||||
case valuators.size
|
||||
when 0
|
||||
t("valuation.spending_proposals.index.no_valuators_assigned")
|
||||
t("valuation.budget_investments.index.no_valuators_assigned")
|
||||
when 1
|
||||
"<span title=\"#{t('valuation.spending_proposals.index.valuators_assigned', count: 1)}\">".html_safe +
|
||||
"<span title=\"#{t('valuation.budget_investments.index.valuators_assigned', count: 1)}\">".html_safe +
|
||||
valuators.first.name +
|
||||
"</span>".html_safe
|
||||
else
|
||||
"<span title=\"".html_safe + valuators.map(&:name).join(', ') + "\">".html_safe +
|
||||
t('valuation.spending_proposals.index.valuators_assigned', count: valuators.size) +
|
||||
t('valuation.budget_investments.index.valuators_assigned', count: valuators.size) +
|
||||
"</span>".html_safe
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@ module Abilities
|
||||
def initialize(user)
|
||||
valuator = user.valuator
|
||||
can [:read, :update, :valuate], SpendingProposal
|
||||
can [:update, :valuate], Budget::Investment, id: valuator.investment_ids, budget: { valuating: true }
|
||||
can [:read, :update, :valuate], Budget::Investment, id: valuator.investment_ids, budget: { valuating: true }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,8 +14,9 @@ class Budget < ActiveRecord::Base
|
||||
has_many :groups, dependent: :destroy
|
||||
has_many :headings, through: :groups
|
||||
|
||||
scope :open, -> { where.not(phase: "finished") }
|
||||
scope :finished, -> { where(phase: "finished") }
|
||||
scope :open, -> { where.not(phase: "finished") }
|
||||
scope :finished, -> { where(phase: "finished") }
|
||||
scope :valuating, -> { where(valuating: true) }
|
||||
|
||||
def on_hold?
|
||||
phase == "on_hold"
|
||||
|
||||
@@ -56,7 +56,7 @@ class Budget
|
||||
before_validation :set_responsible_name
|
||||
|
||||
def self.filter_params(params)
|
||||
params.select{|x,_| %w{heading_id administrator_id tag_name valuator_id}.include? x.to_s }
|
||||
params.select{|x,_| %w{heading_id group_id administrator_id tag_name valuator_id}.include? x.to_s }
|
||||
end
|
||||
|
||||
def self.scoped_filter(params, current_filter)
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<div class="callout primary float-right">
|
||||
<%= t "admin.budget_investments.show.info", budget_name: @budget.name, group_name: @investment.group.name, id: @investment.id %>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<h1 class="inline-block"><%= @investment.title %></h1>
|
||||
|
||||
<div class="row small-collapse spending-proposal-info">
|
||||
<div class="small-12 medium-4 column">
|
||||
<p title="<%= t("admin.budget_investments.show.group") %>: <%= @investment.group.name %>">
|
||||
<strong><%= t("admin.budget_investments.show.heading") %>:</strong>
|
||||
<%= @investment.heading.name %>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-4 column">
|
||||
<p>
|
||||
<strong><%= t("admin.budget_investments.show.by") %>:</strong>
|
||||
<%= link_to @investment.author.name, admin_user_path(@investment.author) %>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-4 column">
|
||||
<p>
|
||||
<strong><%= t("admin.budget_investments.show.sent") %>:</strong>
|
||||
<%= l @investment.created_at, format: :datetime %>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<% if @investment.external_url.present? %>
|
||||
<p><%= text_with_links @investment.external_url %> <span class="icon-external small"></span></p>
|
||||
<% end %>
|
||||
|
||||
<%= safe_html_with_links @investment.description %>
|
||||
69
app/views/admin/budget_investments/edit.html.erb
Normal file
69
app/views/admin/budget_investments/edit.html.erb
Normal file
@@ -0,0 +1,69 @@
|
||||
<%= link_to admin_budget_budget_investment_path(@budget, @investment, Budget::Investment.filter_params(params)), class: 'back' do %>
|
||||
<span class="icon-angle-left"></span> <%= t("shared.back") %>
|
||||
<% end %>
|
||||
|
||||
<%= form_for @investment,
|
||||
url: admin_budget_budget_investment_path(@budget, @investment) do |f| %>
|
||||
|
||||
<% Budget::Investment.filter_params(params).each do |filter_name, filter_value| %>
|
||||
<%= hidden_field_tag filter_name, filter_value %>
|
||||
<% end %>
|
||||
|
||||
<div class="row">
|
||||
<div class="small-12 column">
|
||||
<%= f.text_field :title, maxlength: Budget::Investment.title_max_length %>
|
||||
</div>
|
||||
|
||||
<div class="ckeditor small-12 column">
|
||||
<%= f.cktext_area :description, maxlength: Budget::Investment.description_max_length, ckeditor: { language: I18n.locale } %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 column">
|
||||
<%= f.text_field :external_url %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 column">
|
||||
<%= f.select :heading_id, budget_scoped_heading_select_options(@budget), include_blank: t("admin.budget_investments.edit.select_heading") %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2 id="classification"><%= t("admin.budget_investments.edit.classification") %></h2>
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="small-12 column">
|
||||
<%= f.select(:administrator_id,
|
||||
@admins.collect{ |a| [a.name_and_email, a.id ] },
|
||||
{ include_blank: t("admin.budget_investments.edit.undefined") }) %>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="small-12 column">
|
||||
<%= f.label :tag_list, t("admin.budget_investments.edit.tags") %>
|
||||
<div class="tags">
|
||||
<% @tags.each do |tag| %>
|
||||
<a class="js-add-tag-link"><%= tag.name %></a>
|
||||
<% end %>
|
||||
</div>
|
||||
<%= f.text_field :tag_list, value: @investment.tag_list.to_s,
|
||||
label: false,
|
||||
placeholder: t("admin.budget_investments.edit.tags_placeholder"),
|
||||
class: 'js-tag-list' %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 column">
|
||||
<%= f.label :valuator_ids, t("admin.budget_investments.edit.assigned_valuators") %>
|
||||
|
||||
<%= f.collection_check_boxes :valuator_ids, @valuators, :id, :email do |b| %>
|
||||
<%= b.label(title: valuator_label(b.object)) { b.check_box + truncate(b.object.description_or_email, length: 60) } %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="clear">
|
||||
<%= f.submit(class: "button", value: t("admin.budget_investments.edit.submit_button")) %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<hr>
|
||||
<%# render 'valuation/budget_investments/written_by_valuators' %>
|
||||
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 :heading_id,
|
||||
options_for_select(budget_heading_select_options(@budget), params[:heading_id]),
|
||||
{ prompt: t("admin.budget_investments.index.heading_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, params: 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.heading.name %>
|
||||
</td>
|
||||
<td class="small">
|
||||
<%= t("admin.budget_investments.index.feasibility.#{investment.feasibility}", price: investment.price) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<%= paginate @investments %>
|
||||
49
app/views/admin/budget_investments/show.html.erb
Normal file
49
app/views/admin/budget_investments/show.html.erb
Normal file
@@ -0,0 +1,49 @@
|
||||
<%= link_to admin_budget_budget_investments_path(Budget::Investment.filter_params(params)), data: {no_turbolink: true} do %>
|
||||
<span class="icon-angle-left"></span> <%= t("shared.back") %>
|
||||
<% end %>
|
||||
|
||||
<%= render 'written_by_author' %>
|
||||
|
||||
<%= link_to t("admin.budget_investments.show.edit"),
|
||||
edit_admin_budget_budget_investment_path(@budget, @investment,
|
||||
Budget::Investment.filter_params(params)) %>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2 id="classification"><%= t("admin.budget_investments.show.classification") %></h2>
|
||||
|
||||
<p><strong><%= t("admin.budget_investments.show.assigned_admin") %>:</strong>
|
||||
<%= @investment.administrator.try(:name_and_email) || t("admin.budget_investments.show.undefined") %>
|
||||
</p>
|
||||
|
||||
<p id="tags">
|
||||
<strong><%= t("admin.budget_investments.show.tags") %>:</strong>
|
||||
|
||||
<%= @investment.tags.pluck(:name).join(', ') %>
|
||||
</p>
|
||||
|
||||
<p id="assigned_valuators">
|
||||
<strong><%= t("admin.budget_investments.show.assigned_valuators") %>:</strong>
|
||||
<% if @investment.valuators.any? %>
|
||||
<%= @investment.valuators.collect(&:name_and_email).join(', ') %>
|
||||
<% else %>
|
||||
<%= t("admin.budget_investments.show.undefined") %>
|
||||
<% end %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= link_to t("admin.budget_investments.show.edit_classification"),
|
||||
edit_admin_budget_budget_investment_path(@budget, @investment,
|
||||
{anchor: 'classification'}.merge(Budget::Investment.filter_params(params))) %>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2><%= t("admin.budget_investments.show.dossier") %></h2>
|
||||
|
||||
<%= render 'valuation/budget_investments/written_by_valuators' %>
|
||||
|
||||
<p>
|
||||
<%= link_to t("admin.budget_investments.show.edit_dossier"), edit_valuation_budget_budget_investment_path(@budget, @investment) %>
|
||||
</p>
|
||||
|
||||
@@ -13,11 +13,14 @@
|
||||
<% @budgets.each do |budget| %>
|
||||
<tr id="<%= dom_id(budget) %>" class="budget">
|
||||
<td>
|
||||
<%= link_to budget.name, admin_budget_path(budget) %>
|
||||
<%= link_to budget.name, admin_budget_budget_investments_path(budget_id: budget.id) %>
|
||||
</td>
|
||||
<td class="small">
|
||||
<%= t("budget.phase.#{budget.phase}") %>
|
||||
</td>
|
||||
<td class="small">
|
||||
<%= link_to t("admin.budgets.index.info_link"), admin_budget_path(budget) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
@@ -13,5 +13,14 @@
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
<% if feature?(:budgets) %>
|
||||
<li <%= "class=active" if controller_name == "budget_investments" %>>
|
||||
<%= link_to valuation_budgets_path do %>
|
||||
<span class="icon-budget"></span>
|
||||
<%= t("valuation.menu.budgets") %>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
<p id="price">
|
||||
<strong>
|
||||
<%= t("valuation.budget_investments.show.price") %>
|
||||
(<%= t("valuation.budget_investments.show.currency") %>):
|
||||
</strong>
|
||||
<% if @investment.price.present? %>
|
||||
<%= @investment.price %>
|
||||
<% else %>
|
||||
<%= t("valuation.budget_investments.show.undefined") %>
|
||||
<% end %>
|
||||
</p>
|
||||
|
||||
<p id="price_first_year">
|
||||
<strong>
|
||||
<%= t("valuation.budget_investments.show.price_first_year") %>
|
||||
(<%= t("valuation.budget_investments.show.currency") %>):
|
||||
</strong>
|
||||
|
||||
<% if @investment.price_first_year.present? %>
|
||||
<%= @investment.price_first_year %>
|
||||
<% else %>
|
||||
<%= t("valuation.budget_investments.show.undefined") %>
|
||||
<% end %>
|
||||
</p>
|
||||
|
||||
<%= explanation_field @investment.price_explanation %>
|
||||
|
||||
<p id="duration">
|
||||
<strong><%= t("valuation.budget_investments.show.duration") %>:</strong>
|
||||
<% if @investment.duration.present? %>
|
||||
<%= @investment.duration %>
|
||||
<% else %>
|
||||
<%= t("valuation.budget_investments.show.undefined") %>
|
||||
<% end %>
|
||||
</p>
|
||||
|
||||
<p id="feasibility">
|
||||
<strong><%= t("valuation.budget_investments.show.feasibility") %>:</strong>
|
||||
<%= t("valuation.budget_investments.show.#{@investment.feasibility}") %>
|
||||
</p>
|
||||
|
||||
<%= explanation_field @investment.unfeasibility_explanation %>
|
||||
|
||||
<% if @investment.valuation_finished %>
|
||||
<p id="valuation">
|
||||
<strong><%= t("valuation.budget_investments.show.valuation_finished") %></strong>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<% if @investment.internal_comments.present? %>
|
||||
<h2><%= t("valuation.budget_investments.show.internal_comments") %></h2>
|
||||
<%= explanation_field @investment.internal_comments %>
|
||||
<% end %>
|
||||
141
app/views/valuation/budget_investments/edit.html.erb
Normal file
141
app/views/valuation/budget_investments/edit.html.erb
Normal file
@@ -0,0 +1,141 @@
|
||||
<%= link_to "#{t('valuation.budget_investments.show.title')} #{@investment.id}", valuation_budget_budget_investment_path(@budget, @investment), class: 'back' %>
|
||||
<h2><%= t("valuation.budget_investments.edit.dossier") %></h2>
|
||||
|
||||
<%= form_for(@investment, url: valuate_valuation_budget_budget_investment_path(@budget, @investment), html: {id: "valuation_budget_investment_edit_form"}) do |f| %>
|
||||
<%= render 'shared/errors', resource: @investment %>
|
||||
<div class="row">
|
||||
<div class="small-12 medium-8 column">
|
||||
<fieldset class="fieldset">
|
||||
<legend><%= t('valuation.budget_investments.edit.feasibility') %></legend>
|
||||
<div class="small-4 column">
|
||||
<span class="radio">
|
||||
<%= f.radio_button :feasibility, 'undecided', label: false %>
|
||||
<%= f.label :feasibility_undecided, t('valuation.budget_investments.edit.undefined_feasible') %>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="small-4 column">
|
||||
<span class="radio">
|
||||
<%= f.radio_button :feasibility, 'feasible', label: false %>
|
||||
<%= f.label :feasibility_feasible, t('valuation.budget_investments.edit.feasible') %>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="small-4 column">
|
||||
<span class="radio">
|
||||
<%= f.radio_button :feasibility, 'unfeasible', label: false %>
|
||||
<%= f.label :feasibility_unfeasible, t('valuation.budget_investments.edit.unfeasible') %>
|
||||
</span>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="unfeasible_fields" >
|
||||
|
||||
<div class="row">
|
||||
<div class="small-12 medium-8 column">
|
||||
<%= f.label :unfeasibility_explanation, t("valuation.budget_investments.edit.feasible_explanation_html") %>
|
||||
<%= f.text_area :unfeasibility_explanation, label: false, rows: 3 %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="feasible_fields">
|
||||
|
||||
<div class="row">
|
||||
<div class="small-12 medium-4 column">
|
||||
<%= f.label :price, "#{t('valuation.budget_investments.edit.price_html', currency: @budget.currency_symbol)}" %>
|
||||
<%= f.number_field :price, label: false, max: 1000000000000000 %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-4 column end">
|
||||
<%= f.label :price_first_year, "#{t('valuation.budget_investments.edit.price_first_year_html', currency: @budget.currency_symbol)}" %>
|
||||
<%= f.number_field :price_first_year, label: false, max: 1000000000000000 %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="small-12 medium-8 column">
|
||||
<%= f.label :price_explanation, t("valuation.budget_investments.edit.price_explanation_html") %>
|
||||
<%= f.text_area :price_explanation, label: false, rows: 3 %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="small-12 medium-8 column">
|
||||
<%= f.label :duration, t("valuation.budget_investments.edit.duration_html") %>
|
||||
<%= f.text_field :duration, label: false %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="small-12 medium-8 column">
|
||||
<%= f.label :valuation_finished do %>
|
||||
<%= f.check_box :valuation_finished, title: t('valuation.budget_investments.edit.valuation_finished'), label: false %>
|
||||
<span class="checkbox"><%= t("valuation.budget_investments.edit.valuation_finished") %></span>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="small-12 medium-8 column">
|
||||
<%= f.label :internal_comments, t("valuation.budget_investments.edit.internal_comments_html") %>
|
||||
<%= f.text_area :internal_comments, label: false, rows: 3 %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="actions small-12 medium-4 column">
|
||||
<%= f.submit(class: "button expanded large", value: t("valuation.budget_investments.edit.save")) %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<h1><%= @investment.title %></h1>
|
||||
|
||||
<%= safe_html_with_links @investment.description %>
|
||||
|
||||
<% if @investment.external_url.present? %>
|
||||
<p><%= text_with_links @investment.external_url %></p>
|
||||
<% end %>
|
||||
|
||||
<h2><%= t("valuation.budget_investments.show.info") %></h2>
|
||||
|
||||
<p><strong><%= t("valuation.budget_investments.show.by") %>:</strong>
|
||||
<%= link_to @investment.author.name, user_path(@investment.author) %>
|
||||
</p>
|
||||
|
||||
<p><strong><%= t("valuation.budget_investments.show.heading") %>:</strong>
|
||||
<%= @investment.heading.name %>
|
||||
</p>
|
||||
|
||||
<p><strong><%= t("valuation.budget_investments.show.sent") %>:</strong>
|
||||
<%= l @investment.created_at, format: :datetime %>
|
||||
</p>
|
||||
|
||||
<h2><%= t("valuation.budget_investments.show.responsibles") %></h2>
|
||||
|
||||
<p><strong><%= t("valuation.budget_investments.show.assigned_admin") %>:</strong>
|
||||
<% if @investment.administrator.present? %>
|
||||
<%= @investment.administrator.name %> (<%= @investment.administrator.email %>)
|
||||
<% else %>
|
||||
<%= t("valuation.budget_investments.show.undefined") %></li>
|
||||
<% end %>
|
||||
</p>
|
||||
|
||||
<p><strong><%= t("valuation.budget_investments.show.assigned_valuators") %>:</strong></p>
|
||||
<div id="assigned_valuators">
|
||||
<ul>
|
||||
<% @investment.valuators.each do |valuator| %>
|
||||
<li><%= valuator.name %> (<%= valuator.email %>)</li>
|
||||
<% end %>
|
||||
|
||||
<% if @investment.valuators.empty? %>
|
||||
<li><%= t("valuation.budget_investments.show.undefined") %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
42
app/views/valuation/budget_investments/index.html.erb
Normal file
42
app/views/valuation/budget_investments/index.html.erb
Normal file
@@ -0,0 +1,42 @@
|
||||
<h2><%= @budget.name %> - <%= t("valuation.budget_investments.index.title") %></h2>
|
||||
|
||||
<div class="row collapse">
|
||||
<% @heading_filters.each_slice(8) do |slice| %>
|
||||
<div class="small-12 medium-4 column select-heading">
|
||||
<% slice.each do |filter| %>
|
||||
<%= link_to valuation_budget_budget_investments_path(budget_id: @budget.id, heading_id: filter[:id]),
|
||||
class: "#{'active' if params[:heading_id].to_s == filter[:id].to_s}" do %>
|
||||
<%= filter[:name] %> (<%= filter[:pending_count] %>)
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<%= render 'shared/filter_subnav', i18n_namespace: "valuation.budget_investments.index" %>
|
||||
|
||||
<h3><%= page_entries_info @investments %></h3>
|
||||
|
||||
<table>
|
||||
<% @investments.each do |investment| %>
|
||||
<tr id="<%= dom_id(investment) %>">
|
||||
<td>
|
||||
<strong><%= investment.id %></strong>
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to investment.title, valuation_budget_budget_investment_path(@budget, investment) %>
|
||||
</td>
|
||||
<td class="small">
|
||||
<%= link_to t("valuation.budget_investments.index.edit"), edit_valuation_budget_budget_investment_path(@budget, investment) %>
|
||||
</td>
|
||||
<td class="small">
|
||||
<%= assigned_valuators_info(investment.valuators) %>
|
||||
</td>
|
||||
<td class="small">
|
||||
<%= investment.heading.name %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<%= paginate @investments %>
|
||||
55
app/views/valuation/budget_investments/show.html.erb
Normal file
55
app/views/valuation/budget_investments/show.html.erb
Normal file
@@ -0,0 +1,55 @@
|
||||
<%= render "shared/back_link" %>
|
||||
|
||||
<h2><%= t("valuation.budget_investments.show.title") %> <%= @investment.id %> </h2>
|
||||
<h1><%= @investment.title %></h1>
|
||||
|
||||
<%= safe_html_with_links @investment.description %>
|
||||
|
||||
<% if @investment.external_url.present? %>
|
||||
<p><%= text_with_links @investment.external_url %></p>
|
||||
<% end %>
|
||||
|
||||
<h2><%= t("valuation.budget_investments.show.info") %></h2>
|
||||
|
||||
<p><strong><%= t("valuation.budget_investments.show.by") %>:</strong>
|
||||
<%= link_to @investment.author.name, user_path(@investment.author) %>
|
||||
</p>
|
||||
|
||||
<p><strong><%= t("valuation.budget_investments.show.heading") %>:</strong>
|
||||
<%= @investment.heading.name %>
|
||||
</p>
|
||||
|
||||
<p><strong><%= t("valuation.budget_investments.show.sent") %>:</strong>
|
||||
<%= l @investment.created_at, format: :datetime %>
|
||||
</p>
|
||||
|
||||
<h2><%= t("valuation.budget_investments.show.responsibles") %></h2>
|
||||
|
||||
<p><strong><%= t("valuation.budget_investments.show.assigned_admin") %>:</strong>
|
||||
<% if @investment.administrator.present? %>
|
||||
<%= @investment.administrator.name_and_email %>
|
||||
<% else %>
|
||||
<%= t("valuation.budget_investments.show.undefined") %></li>
|
||||
<% end %>
|
||||
</p>
|
||||
|
||||
<p><strong><%= t("valuation.budget_investments.show.assigned_valuators") %>:</strong></p>
|
||||
<div id="assigned_valuators">
|
||||
<ul>
|
||||
<% @investment.valuators.each do |valuator| %>
|
||||
<li><%= valuator.name_and_email %></li>
|
||||
<% end %>
|
||||
|
||||
<% if @investment.valuators.empty? %>
|
||||
<li><%= t("valuation.budget_investments.show.undefined") %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<h2><%= t("valuation.budget_investments.show.dossier") %></h2>
|
||||
|
||||
<p>
|
||||
<%= link_to t("valuation.budget_investments.show.edit_dossier"), edit_valuation_budget_budget_investment_path(@budget, @investment) %>
|
||||
</p>
|
||||
|
||||
<%= render 'written_by_valuators' %>
|
||||
17
app/views/valuation/budgets/index.html.erb
Normal file
17
app/views/valuation/budgets/index.html.erb
Normal file
@@ -0,0 +1,17 @@
|
||||
<h2 class="inline-block"><%= t("valuation.budgets.index.title") %></h2>
|
||||
|
||||
<%= render 'shared/filter_subnav', i18n_namespace: "valuation.budgets.index" %>
|
||||
|
||||
<h3><%= page_entries_info @budgets %></h3>
|
||||
|
||||
<table>
|
||||
<% @budgets.each do |budget| %>
|
||||
<tr id="<%= dom_id(budget) %>" class="budget">
|
||||
<td>
|
||||
<%= link_to budget.name, valuation_budget_budget_investments_path(budget_id: budget.id) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<%= paginate @budgets %>
|
||||
@@ -117,6 +117,7 @@ ignore_unused:
|
||||
- 'admin.debates.index.filter*'
|
||||
- 'admin.proposals.index.filter*'
|
||||
- 'admin.budgets.index.filter*'
|
||||
- 'admin.budget_investments.index.filter*'
|
||||
- 'admin.spending_proposals.index.filter*'
|
||||
- 'admin.organizations.index.filter*'
|
||||
- 'admin.users.index.filter*'
|
||||
@@ -131,6 +132,8 @@ ignore_unused:
|
||||
- 'moderation.debates.index.filter*'
|
||||
- 'moderation.debates.index.order*'
|
||||
- 'valuation.spending_proposals.index.filter*'
|
||||
- 'valuation.budgets.index.filter*'
|
||||
- 'valuation.budget_investments.index.filter*'
|
||||
- 'users.show.filters.*'
|
||||
- 'debates.index.select_order'
|
||||
- 'debates.index.orders.*'
|
||||
|
||||
@@ -42,6 +42,10 @@ module ActsAsTaggableOn
|
||||
ActsAsTaggableOn::Tag.where('taggings.taggable_type' => 'SpendingProposal').includes(:taggings).order(:name).uniq
|
||||
end
|
||||
|
||||
def self.budget_investment_tags
|
||||
ActsAsTaggableOn::Tag.where('taggings.taggable_type' => 'Budget::Investment').includes(:taggings).order(:name).uniq
|
||||
end
|
||||
|
||||
private
|
||||
def custom_counter_field_name_for(taggable_type)
|
||||
"#{taggable_type.underscore.pluralize}_count"
|
||||
|
||||
@@ -7,6 +7,9 @@ en:
|
||||
budget:
|
||||
one: "Participatory budget"
|
||||
other: "Participatory budgets"
|
||||
budget/investment:
|
||||
one: "Investment"
|
||||
other: "Investments"
|
||||
comment:
|
||||
one: "Comment"
|
||||
other: "Comments"
|
||||
@@ -38,6 +41,12 @@ en:
|
||||
one: "Spending proposal"
|
||||
other: "Spending proposals"
|
||||
attributes:
|
||||
budget/investment:
|
||||
administrator_id: "Administrator"
|
||||
description: "Description"
|
||||
external_url: "Link to additional documentation"
|
||||
heading_id: "Heading"
|
||||
title: "Title"
|
||||
comment:
|
||||
body: "Comment"
|
||||
user: "User"
|
||||
|
||||
@@ -7,6 +7,9 @@ es:
|
||||
budget:
|
||||
one: "Presupuesto participativo"
|
||||
other: "Presupuestos participativos"
|
||||
budget/investment:
|
||||
one: "Propuesta de inversión"
|
||||
other: "Propuestas de inversión"
|
||||
comment:
|
||||
one: "Comentario"
|
||||
other: "Comentarios"
|
||||
@@ -38,6 +41,12 @@ es:
|
||||
one: "Propuesta de inversión"
|
||||
other: "Propuestas de inversión"
|
||||
attributes:
|
||||
budget/investment:
|
||||
administrator_id: "Administrador"
|
||||
description: "Descripción"
|
||||
external_url: "Enlace a documentación adicional"
|
||||
heading_id: "Partida presupuestaria"
|
||||
title: "Título"
|
||||
comment:
|
||||
body: "Comentario"
|
||||
user: "Usuario"
|
||||
|
||||
@@ -62,6 +62,7 @@ en:
|
||||
index:
|
||||
title: Participatory budgets
|
||||
new_link: Create new
|
||||
info_link: Info
|
||||
filters:
|
||||
open: Open
|
||||
finished: Finished
|
||||
@@ -92,6 +93,50 @@ en:
|
||||
table_heading: Heading
|
||||
table_amount: Amount
|
||||
table_geozone: Scope of operation
|
||||
budget_investments:
|
||||
index:
|
||||
heading_filter_all: All headings
|
||||
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"
|
||||
show:
|
||||
assigned_admin: Assigned administrator
|
||||
assigned_valuators: Assigned valuators
|
||||
classification: Clasification
|
||||
info: "%{budget_name} - Group: %{group_name} - Investment project %{id}"
|
||||
edit: Edit
|
||||
edit_classification: Edit classification
|
||||
by: By
|
||||
sent: Sent
|
||||
group: Grupo
|
||||
heading: Partida
|
||||
dossier: Dossier
|
||||
edit_dossier: Edit dossier
|
||||
tags: Tags
|
||||
undefined: Undefined
|
||||
edit:
|
||||
classification: Clasification
|
||||
assigned_valuators: Valuators
|
||||
select_heading: Select heading
|
||||
submit_button: Update
|
||||
tags: Tags
|
||||
tags_placeholder: "Write the tags you want separated by commas (,)"
|
||||
undefined: Undefined
|
||||
comments:
|
||||
index:
|
||||
filter: Filter
|
||||
|
||||
@@ -62,6 +62,7 @@ es:
|
||||
index:
|
||||
title: Presupuestos participativos
|
||||
new_link: Crear nuevo
|
||||
info_link: Info
|
||||
filters:
|
||||
open: Abiertos
|
||||
finished: Terminados
|
||||
@@ -92,6 +93,50 @@ es:
|
||||
table_heading: Partida
|
||||
table_amount: Cantidad
|
||||
table_geozone: Ámbito de actuación
|
||||
budget_investments:
|
||||
index:
|
||||
heading_filter_all: Todas las partidas
|
||||
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"
|
||||
show:
|
||||
assigned_admin: Administrador asignado
|
||||
assigned_valuators: Evaluadores asignados
|
||||
classification: Clasificación
|
||||
info: "%{budget_name} - Grupo: %{group_name} - Propuesta de inversión %{id}"
|
||||
edit: Editar
|
||||
edit_classification: Editar clasificación
|
||||
by: Autor
|
||||
sent: Fecha
|
||||
group: Grupo
|
||||
heading: Partida
|
||||
dossier: Informe
|
||||
edit_dossier: Editar informe
|
||||
tags: Etiquetas
|
||||
undefined: Sin definir
|
||||
edit:
|
||||
classification: Clasificación
|
||||
assigned_valuators: Evaluadores
|
||||
select_heading: Seleccionar partida
|
||||
submit_button: Actualizar
|
||||
tags: Etiquetas
|
||||
tags_placeholder: "Escribe las etiquetas que desees separadas por comas (,)"
|
||||
undefined: Sin definir
|
||||
comments:
|
||||
index:
|
||||
filter: Filtro
|
||||
|
||||
@@ -17,7 +17,7 @@ en:
|
||||
debate: "Debate updated successfully."
|
||||
proposal: "Proposal updated successfully."
|
||||
spending_proposal: "Investment project updated succesfully."
|
||||
budget_investment: "Budget Investment updated succesfully."
|
||||
budget_investment: "Investment project updated succesfully."
|
||||
destroy:
|
||||
spending_proposal: "Spending proposal deleted succesfully."
|
||||
budget_investment: "Budget Investment deleted succesfully."
|
||||
budget_investment: "Investment project deleted succesfully."
|
||||
|
||||
@@ -14,6 +14,7 @@ en:
|
||||
email_domain_for_officials: "Email domain for public officials"
|
||||
per_page_code: "Code to be included on every page"
|
||||
feature:
|
||||
budgets: Participatory budgeting
|
||||
debates: Debates
|
||||
spending_proposals: Investment projects
|
||||
spending_proposal_features:
|
||||
|
||||
@@ -14,7 +14,8 @@ es:
|
||||
email_domain_for_officials: "Dominio de email para cargos públicos"
|
||||
per_page_code: "Código a incluir en cada página"
|
||||
feature:
|
||||
budgets: Presupuestos participativos
|
||||
debates: Debates
|
||||
spending_proposals: Propuestas de inversión
|
||||
spending_proposal_features:
|
||||
voting_allowed: Votaciones sobre propuestas de inversión.
|
||||
voting_allowed: Votaciones sobre propuestas de inversión
|
||||
@@ -3,7 +3,65 @@ en:
|
||||
valuation:
|
||||
menu:
|
||||
title: Valuation
|
||||
budgets: Participatory budgets
|
||||
spending_proposals: Spending proposals
|
||||
budgets:
|
||||
index:
|
||||
title: Participatory budgets
|
||||
filters:
|
||||
open: Open
|
||||
finished: Finished
|
||||
budget_investments:
|
||||
index:
|
||||
headings_filter_all: All headings
|
||||
filters:
|
||||
valuation_open: Open
|
||||
valuating: Under valuation
|
||||
valuation_finished: Valuation finished
|
||||
title: Investment projects
|
||||
edit: Edit
|
||||
valuators_assigned:
|
||||
one: Assigned valuator
|
||||
other: "%{count} valuators assigned"
|
||||
no_valuators_assigned: No valuators assigned
|
||||
show:
|
||||
back: Back
|
||||
title: Investment project
|
||||
info: Author info
|
||||
by: Sent by
|
||||
sent: Sent at
|
||||
heading: Heading
|
||||
dossier: Dossier
|
||||
edit_dossier: Edit dossier
|
||||
price: Price
|
||||
price_first_year: Cost during the first year
|
||||
currency: "€"
|
||||
feasibility: Feasibility
|
||||
feasible: Feasible
|
||||
unfeasible: Unfeasible
|
||||
undefined: Undefined
|
||||
valuation_finished: Valuation finished
|
||||
duration: Time scope
|
||||
internal_comments: Internal comments
|
||||
responsibles: Responsibles
|
||||
assigned_admin: Assigned admin
|
||||
assigned_valuators: Assigned valuators
|
||||
edit:
|
||||
dossier: Dossier
|
||||
price_html: "Price (%{currency})"
|
||||
price_first_year_html: "Cost during the first year (%{currency})"
|
||||
price_explanation_html: Price explanation
|
||||
feasibility: Feasibility
|
||||
feasible: Feasible
|
||||
unfeasible: Not feasible
|
||||
undefined_feasible: Pending
|
||||
feasible_explanation_html: Feasibility explanation
|
||||
valuation_finished: Valuation finished
|
||||
duration_html: Time scope
|
||||
internal_comments_html: Internal comments
|
||||
save: Save changes
|
||||
notice:
|
||||
valuate: "Dossier updated"
|
||||
spending_proposals:
|
||||
index:
|
||||
geozone_filter_all: All zones
|
||||
@@ -13,10 +71,6 @@ en:
|
||||
valuation_finished: Valuation finished
|
||||
title: Investment projects for participatory budgeting
|
||||
edit: Edit
|
||||
valuators_assigned:
|
||||
one: Assigned valuator
|
||||
other: "%{count} valuators assigned"
|
||||
no_valuators_assigned: No valuators assigned
|
||||
show:
|
||||
back: Back
|
||||
heading: Investment project
|
||||
|
||||
@@ -3,7 +3,65 @@ es:
|
||||
valuation:
|
||||
menu:
|
||||
title: Evaluación
|
||||
budgets: Presupuestos participativos
|
||||
spending_proposals: Propuestas de inversión
|
||||
budgets:
|
||||
index:
|
||||
title: Presupuestos participativos
|
||||
filters:
|
||||
open: Abiertos
|
||||
finished: Terminados
|
||||
budget_investments:
|
||||
index:
|
||||
headings_filter_all: Todas las partidas
|
||||
filters:
|
||||
valuation_open: Abiertas
|
||||
valuating: En evaluación
|
||||
valuation_finished: Evaluación finalizada
|
||||
title: Propuestas de inversión
|
||||
edit: Editar
|
||||
valuators_assigned:
|
||||
one: Evaluador asignado
|
||||
other: "%{count} evaluadores asignados"
|
||||
no_valuators_assigned: Sin evaluador
|
||||
show:
|
||||
back: Volver
|
||||
title: Propuesta de inversión
|
||||
info: Datos de envío
|
||||
by: Enviada por
|
||||
sent: Fecha de creación
|
||||
heading: Partida
|
||||
dossier: Informe
|
||||
edit_dossier: Editar informe
|
||||
price: Coste
|
||||
price_first_year: Coste en el primer año
|
||||
currency: "€"
|
||||
feasibility: Viabilidad
|
||||
feasible: Viable
|
||||
unfeasible: Inviable
|
||||
undefined: Sin definir
|
||||
valuation_finished: Informe finalizado
|
||||
duration: Plazo de ejecución
|
||||
internal_comments: Comentarios internos
|
||||
responsibles: Responsables
|
||||
assigned_admin: Administrador asignado
|
||||
assigned_valuators: Evaluadores asignados
|
||||
edit:
|
||||
dossier: Informe
|
||||
price_html: "Coste (%{currency}) <small>(dato público)</small>"
|
||||
price_first_year_html: "Coste en el primer año (%{currency}) <small>(opcional, privado)</small>"
|
||||
price_explanation_html: "Informe de coste <small>(opcional, dato público)</small>"
|
||||
feasibility: Viabilidad
|
||||
feasible: Viable
|
||||
unfeasible: Inviable
|
||||
undefined_feasible: Sin decidir
|
||||
feasible_explanation_html: "Informe de inviabilidad <small>(en caso de que lo sea, dato público)</small>"
|
||||
valuation_finished: Informe finalizado
|
||||
duration_html: "Plazo de ejecución <small>(opcional, dato no público)</small>"
|
||||
internal_comments_html: "Comentarios y observaciones <small>(para responsables internos, dato no público)</small>"
|
||||
save: Guardar cambios
|
||||
notice:
|
||||
valuate: "Dossier actualizado"
|
||||
spending_proposals:
|
||||
index:
|
||||
geozone_filter_all: Todos los ámbitos de actuación
|
||||
@@ -13,10 +71,6 @@ es:
|
||||
valuation_finished: Evaluación finalizada
|
||||
title: Propuestas de inversión para presupuestos participativos
|
||||
edit: Editar
|
||||
valuators_assigned:
|
||||
one: Evaluador asignado
|
||||
other: "%{count} evaluadores asignados"
|
||||
no_valuators_assigned: Sin evaluador
|
||||
show:
|
||||
back: Volver
|
||||
heading: Propuesta de inversión
|
||||
|
||||
@@ -161,6 +161,8 @@ Rails.application.routes.draw do
|
||||
resources :budget_headings do
|
||||
end
|
||||
end
|
||||
|
||||
resources :budget_investments, only: [:index, :show, :edit, :update]
|
||||
end
|
||||
|
||||
resources :banners, only: [:index, :new, :create, :edit, :update, :destroy] do
|
||||
@@ -235,11 +237,17 @@ Rails.application.routes.draw do
|
||||
end
|
||||
|
||||
namespace :valuation do
|
||||
root to: "spending_proposals#index"
|
||||
root to: "budgets#index"
|
||||
|
||||
resources :spending_proposals, only: [:index, :show, :edit] do
|
||||
patch :valuate, on: :member
|
||||
end
|
||||
|
||||
resources :budgets, only: :index do
|
||||
resources :budget_investments, only: [:index, :show, :edit] do
|
||||
patch :valuate, on: :member
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
namespace :management do
|
||||
|
||||
467
spec/features/admin/budget_investments_spec.rb
Normal file
467
spec/features/admin/budget_investments_spec.rb
Normal file
@@ -0,0 +1,467 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature 'Admin budget investments' do
|
||||
|
||||
background do
|
||||
admin = create(:administrator)
|
||||
login_as(admin.user)
|
||||
|
||||
@budget = create(:budget)
|
||||
end
|
||||
|
||||
context "Feature flag" do
|
||||
|
||||
scenario 'Disabled with a feature flag' do
|
||||
Setting['feature.budgets'] = nil
|
||||
expect{ visit admin_budgets_path }.to raise_exception(FeatureFlags::FeatureDisabled)
|
||||
end
|
||||
|
||||
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 heading", :js do
|
||||
group1 = create(:budget_group, name: "Streets", budget: @budget)
|
||||
group2 = create(:budget_group, name: "Parks", budget: @budget)
|
||||
|
||||
group1_heading1 = create(:budget_heading, group: group1, name: "Main Avenue")
|
||||
group1_heading2 = create(:budget_heading, group: group1, name: "Mercy Street")
|
||||
group2_heading1 = create(:budget_heading, group: group2, name: "Central Park")
|
||||
|
||||
create(:budget_investment, title: "Realocate visitors", budget: @budget, group: group1, heading: group1_heading1)
|
||||
create(:budget_investment, title: "Change name", budget: @budget, group: group1, heading: group1_heading2)
|
||||
create(:budget_investment, title: "Plant trees", budget: @budget, group: group2, heading: group2_heading1)
|
||||
|
||||
visit admin_budget_budget_investments_path(budget_id: @budget.id)
|
||||
|
||||
expect(page).to have_link("Realocate visitors")
|
||||
expect(page).to have_link("Change name")
|
||||
expect(page).to have_link("Plant trees")
|
||||
|
||||
select "Central Park", from: "heading_id"
|
||||
|
||||
expect(page).to_not have_link("Realocate visitors")
|
||||
expect(page).to_not have_link("Change name")
|
||||
expect(page).to have_link("Plant trees")
|
||||
|
||||
select "All headings", from: "heading_id"
|
||||
|
||||
expect(page).to have_link("Realocate visitors")
|
||||
expect(page).to have_link("Change name")
|
||||
expect(page).to have_link("Plant trees")
|
||||
|
||||
select "Main Avenue", from: "heading_id"
|
||||
|
||||
expect(page).to have_link("Realocate visitors")
|
||||
expect(page).to_not have_link("Change name")
|
||||
expect(page).to_not have_link("Plant trees")
|
||||
|
||||
select "Mercy Street", from: "heading_id"
|
||||
|
||||
expect(page).to_not have_link("Realocate visitors")
|
||||
expect(page).to have_link("Change name")
|
||||
expect(page).to_not have_link("Plant trees")
|
||||
|
||||
click_link("Change name")
|
||||
click_link("Go back")
|
||||
|
||||
expect(page).to_not have_link("Realocate visitors")
|
||||
expect(page).to have_link("Change name")
|
||||
expect(page).to_not have_link("Plant trees")
|
||||
|
||||
click_link("Change name")
|
||||
click_link("Edit classification")
|
||||
expect(page).to have_button("Update")
|
||||
click_link("Go back")
|
||||
expect(page).to_not have_button("Update")
|
||||
click_link("Go back")
|
||||
|
||||
expect(page).to_not have_link("Realocate visitors")
|
||||
expect(page).to have_link("Change name")
|
||||
expect(page).to_not have_link("Plant trees")
|
||||
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("Go 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("Go back")
|
||||
expect(page).to_not have_button("Update")
|
||||
click_link("Go 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("Go 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("Go back")
|
||||
expect(page).to_not have_button("Update")
|
||||
click_link("Go 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("Go 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("Go back")
|
||||
expect(page).to_not have_button("Update")
|
||||
click_link("Go 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
|
||||
|
||||
scenario 'Show' do
|
||||
administrator = create(:administrator, user: create(:user, username: 'Ana', email: 'ana@admins.org'))
|
||||
valuator = create(:valuator, user: create(:user, username: 'Rachel', email: 'rachel@valuators.org'))
|
||||
budget_investment = create(:budget_investment,
|
||||
price: 1234,
|
||||
price_first_year: 1000,
|
||||
feasibility: "unfeasible",
|
||||
unfeasibility_explanation: 'It is impossible',
|
||||
administrator: administrator)
|
||||
budget_investment.valuators << valuator
|
||||
|
||||
visit admin_budget_budget_investments_path(budget_investment.budget)
|
||||
|
||||
click_link budget_investment.title
|
||||
|
||||
expect(page).to have_content(budget_investment.title)
|
||||
expect(page).to have_content(budget_investment.description)
|
||||
expect(page).to have_content(budget_investment.author.name)
|
||||
expect(page).to have_content(budget_investment.heading.name)
|
||||
expect(page).to have_content('1234')
|
||||
expect(page).to have_content('1000')
|
||||
expect(page).to have_content('Unfeasible')
|
||||
expect(page).to have_content('It is impossible')
|
||||
expect(page).to have_content('Ana (ana@admins.org)')
|
||||
|
||||
within('#assigned_valuators') do
|
||||
expect(page).to have_content('Rachel (rachel@valuators.org)')
|
||||
end
|
||||
end
|
||||
|
||||
context "Edit" do
|
||||
|
||||
scenario "Change title, description or heading" do
|
||||
budget_investment = create(:budget_investment)
|
||||
create(:budget_heading, group: budget_investment.group, name: "Barbate")
|
||||
|
||||
visit admin_budget_budget_investment_path(budget_investment.budget, budget_investment)
|
||||
click_link 'Edit'
|
||||
|
||||
fill_in 'budget_investment_title', with: 'Potatoes'
|
||||
fill_in 'budget_investment_description', with: 'Carrots'
|
||||
select "#{budget_investment.group.name}: Barbate", from: 'budget_investment[heading_id]'
|
||||
|
||||
click_button 'Update'
|
||||
|
||||
expect(page).to have_content 'Potatoes'
|
||||
expect(page).to have_content 'Carrots'
|
||||
expect(page).to have_content 'Barbate'
|
||||
end
|
||||
|
||||
scenario "Add administrator" do
|
||||
budget_investment = create(:budget_investment)
|
||||
administrator = create(:administrator, user: create(:user, username: 'Marta', email: 'marta@admins.org'))
|
||||
|
||||
visit admin_budget_budget_investment_path(budget_investment.budget, budget_investment)
|
||||
click_link 'Edit classification'
|
||||
|
||||
select 'Marta (marta@admins.org)', from: 'budget_investment[administrator_id]'
|
||||
click_button 'Update'
|
||||
|
||||
expect(page).to have_content 'Investment project updated succesfully.'
|
||||
expect(page).to have_content 'Assigned administrator: Marta'
|
||||
end
|
||||
|
||||
scenario "Add valuators" do
|
||||
budget_investment = create(:budget_investment)
|
||||
|
||||
valuator1 = create(:valuator, user: create(:user, username: 'Valentina', email: 'v1@valuators.org'))
|
||||
valuator2 = create(:valuator, user: create(:user, username: 'Valerian', email: 'v2@valuators.org'))
|
||||
valuator3 = create(:valuator, user: create(:user, username: 'Val', email: 'v3@valuators.org'))
|
||||
|
||||
visit admin_budget_budget_investment_path(budget_investment.budget, budget_investment)
|
||||
click_link 'Edit classification'
|
||||
|
||||
check "budget_investment_valuator_ids_#{valuator1.id}"
|
||||
check "budget_investment_valuator_ids_#{valuator3.id}"
|
||||
|
||||
click_button 'Update'
|
||||
|
||||
expect(page).to have_content 'Investment project updated succesfully.'
|
||||
|
||||
within('#assigned_valuators') do
|
||||
expect(page).to have_content('Valentina (v1@valuators.org)')
|
||||
expect(page).to have_content('Val (v3@valuators.org)')
|
||||
expect(page).to_not have_content('Undefined')
|
||||
expect(page).to_not have_content('Valerian (v2@valuators.org)')
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Adds existing tags", :js do
|
||||
create(:budget_investment, tag_list: 'Education, Health')
|
||||
|
||||
budget_investment = create(:budget_investment)
|
||||
|
||||
visit admin_budget_budget_investment_path(budget_investment.budget, budget_investment)
|
||||
click_link 'Edit classification'
|
||||
|
||||
find('.js-add-tag-link', text: 'Education').click
|
||||
|
||||
fill_in 'budget_investment_title', with: 'Updated title'
|
||||
|
||||
click_button 'Update'
|
||||
|
||||
expect(page).to have_content 'Investment project updated succesfully.'
|
||||
|
||||
within "#tags" do
|
||||
expect(page).to have_content 'Education'
|
||||
expect(page).to_not have_content 'Health'
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Adds non existent tags" do
|
||||
budget_investment = create(:budget_investment)
|
||||
|
||||
visit admin_budget_budget_investment_path(budget_investment.budget, budget_investment)
|
||||
click_link 'Edit classification'
|
||||
|
||||
fill_in 'budget_investment_tag_list', with: 'Refugees, Solidarity'
|
||||
click_button 'Update'
|
||||
|
||||
expect(page).to have_content 'Investment project updated succesfully.'
|
||||
|
||||
within "#tags" do
|
||||
expect(page).to have_content 'Refugees'
|
||||
expect(page).to have_content 'Solidarity'
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Errors on update" do
|
||||
budget_investment = create(:budget_investment)
|
||||
|
||||
visit admin_budget_budget_investment_path(budget_investment.budget, budget_investment)
|
||||
click_link 'Edit'
|
||||
|
||||
fill_in 'budget_investment_title', with: ''
|
||||
|
||||
click_button 'Update'
|
||||
|
||||
expect(page).to have_content "can't be blank"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@@ -9,7 +9,7 @@ feature 'Admin budgets' do
|
||||
|
||||
context 'Feature flag' do
|
||||
|
||||
xscenario 'Disabled with a feature flag' do
|
||||
scenario 'Disabled with a feature flag' do
|
||||
Setting['feature.budgets'] = nil
|
||||
expect{ visit admin_budgets_path }.to raise_exception(FeatureFlags::FeatureDisabled)
|
||||
end
|
||||
@@ -105,10 +105,13 @@ feature 'Admin budgets' do
|
||||
context 'Manage groups and headings' do
|
||||
|
||||
scenario 'Create group', :js do
|
||||
create(:budget, name: 'Yearly participatory budget')
|
||||
budget = create(:budget, name: 'Yearly participatory budget')
|
||||
|
||||
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.'
|
||||
|
||||
|
||||
395
spec/features/valuation/budget_investments_spec.rb
Normal file
395
spec/features/valuation/budget_investments_spec.rb
Normal file
@@ -0,0 +1,395 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature 'Valuation budget investments' do
|
||||
|
||||
background do
|
||||
@valuator = create(:valuator, user: create(:user, username: 'Rachel', email: 'rachel@valuators.org'))
|
||||
login_as(@valuator.user)
|
||||
@budget = create(:budget, valuating: true)
|
||||
end
|
||||
|
||||
scenario 'Disabled with a feature flag' do
|
||||
Setting['feature.budgets'] = nil
|
||||
expect{ visit valuation_budget_budget_investments_path(create(:budget)) }.to raise_exception(FeatureFlags::FeatureDisabled)
|
||||
end
|
||||
|
||||
scenario 'Index shows budget investments assigned to current valuator' do
|
||||
investment1 = create(:budget_investment, budget: @budget)
|
||||
investment2 = create(:budget_investment, budget: @budget)
|
||||
|
||||
investment1.valuators << @valuator
|
||||
|
||||
visit valuation_budget_budget_investments_path(@budget)
|
||||
|
||||
expect(page).to have_content(investment1.title)
|
||||
expect(page).to_not have_content(investment2.title)
|
||||
end
|
||||
|
||||
scenario 'Index shows no budget investment to admins no valuators' do
|
||||
investment1 = create(:budget_investment, budget: @budget)
|
||||
investment2 = create(:budget_investment, budget: @budget)
|
||||
|
||||
investment1.valuators << @valuator
|
||||
|
||||
logout
|
||||
login_as create(:administrator).user
|
||||
visit valuation_budget_budget_investments_path(@budget)
|
||||
|
||||
expect(page).to_not have_content(investment1.title)
|
||||
expect(page).to_not have_content(investment2.title)
|
||||
end
|
||||
|
||||
scenario 'Index orders budget investments by votes' do
|
||||
investment10 = create(:budget_investment, budget: @budget, cached_votes_up: 10)
|
||||
investment100 = create(:budget_investment, budget: @budget, cached_votes_up: 100)
|
||||
investment1 = create(:budget_investment, budget: @budget, cached_votes_up: 1)
|
||||
|
||||
investment1.valuators << @valuator
|
||||
investment10.valuators << @valuator
|
||||
investment100.valuators << @valuator
|
||||
|
||||
visit valuation_budget_budget_investments_path(@budget)
|
||||
|
||||
expect(investment100.title).to appear_before(investment10.title)
|
||||
expect(investment10.title).to appear_before(investment1.title)
|
||||
end
|
||||
|
||||
scenario 'Index shows assignments info' do
|
||||
investment1 = create(:budget_investment, budget: @budget)
|
||||
investment2 = create(:budget_investment, budget: @budget)
|
||||
investment3 = create(:budget_investment, budget: @budget)
|
||||
|
||||
valuator1 = create(:valuator, user: create(:user))
|
||||
valuator2 = create(:valuator, user: create(:user))
|
||||
valuator3 = create(:valuator, user: create(:user))
|
||||
|
||||
investment1.valuator_ids = [@valuator.id]
|
||||
investment2.valuator_ids = [@valuator.id, valuator1.id, valuator2.id]
|
||||
investment3.valuator_ids = [@valuator.id, valuator3.id]
|
||||
|
||||
visit valuation_budget_budget_investments_path(@budget)
|
||||
|
||||
within("#budget_investment_#{investment1.id}") do
|
||||
expect(page).to have_content("Rachel")
|
||||
end
|
||||
|
||||
within("#budget_investment_#{investment2.id}") do
|
||||
expect(page).to have_content("3 valuators assigned")
|
||||
end
|
||||
|
||||
within("#budget_investment_#{investment3.id}") do
|
||||
expect(page).to have_content("2 valuators assigned")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Index filtering by heading", :js do
|
||||
group = create(:budget_group, budget: @budget)
|
||||
heading1 = create(:budget_heading, name: "District 9", group: group)
|
||||
heading2 = create(:budget_heading, name: "Down to the river", group: group)
|
||||
investment1 = create(:budget_investment, title: "Realocate visitors", heading: heading1, group: group, budget: @budget)
|
||||
investment2 = create(:budget_investment, title: "Destroy the city", heading: heading2, group: group, budget: @budget)
|
||||
investment1.valuators << @valuator
|
||||
investment2.valuators << @valuator
|
||||
|
||||
visit valuation_budget_budget_investments_path(@budget)
|
||||
|
||||
expect(page).to have_link("Realocate visitors")
|
||||
expect(page).to have_link("Destroy the city")
|
||||
|
||||
|
||||
expect(page).to have_content "All headings (2)"
|
||||
expect(page).to have_content "District 9 (1)"
|
||||
expect(page).to have_content "Down to the river (1)"
|
||||
|
||||
click_link "District 9", exact: false
|
||||
|
||||
expect(page).to have_link("Realocate visitors")
|
||||
expect(page).to_not have_link("Destroy the city")
|
||||
|
||||
click_link "Down to the river", exact: false
|
||||
|
||||
expect(page).to have_link("Destroy the city")
|
||||
expect(page).to_not have_link("Realocate visitors")
|
||||
|
||||
click_link "All headings", exact: false
|
||||
expect(page).to have_link("Realocate visitors")
|
||||
expect(page).to have_link("Destroy the city")
|
||||
end
|
||||
|
||||
scenario "Current filter is properly highlighted" do
|
||||
filters_links = {'valuating' => 'Under valuation',
|
||||
'valuation_finished' => 'Valuation finished'}
|
||||
|
||||
visit valuation_budget_budget_investments_path(@budget)
|
||||
|
||||
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 valuation_budget_budget_investments_path(@budget, 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 "Index 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 << @valuator
|
||||
valuated.valuators << @valuator
|
||||
|
||||
visit valuation_budget_budget_investments_path(@budget)
|
||||
|
||||
expect(page).to have_content("Ongoing valuation")
|
||||
expect(page).to_not have_content("Old idea")
|
||||
|
||||
visit valuation_budget_budget_investments_path(@budget, filter: 'valuating')
|
||||
|
||||
expect(page).to have_content("Ongoing valuation")
|
||||
expect(page).to_not have_content("Old idea")
|
||||
|
||||
visit valuation_budget_budget_investments_path(@budget, filter: 'valuation_finished')
|
||||
|
||||
expect(page).to_not have_content("Ongoing valuation")
|
||||
expect(page).to have_content("Old idea")
|
||||
end
|
||||
|
||||
feature 'Show' do
|
||||
scenario 'visible for assigned valuators' do
|
||||
administrator = create(:administrator, user: create(:user, username: 'Ana', email: 'ana@admins.org'))
|
||||
valuator2 = create(:valuator, user: create(:user, username: 'Rick', email: 'rick@valuators.org'))
|
||||
investment = create(:budget_investment,
|
||||
budget: @budget,
|
||||
price: 1234,
|
||||
feasibility: 'unfeasible',
|
||||
unfeasibility_explanation: 'It is impossible',
|
||||
administrator: administrator)
|
||||
investment.valuators << [@valuator, valuator2]
|
||||
|
||||
visit valuation_budget_budget_investments_path(@budget)
|
||||
|
||||
click_link investment.title
|
||||
|
||||
expect(page).to have_content(investment.title)
|
||||
expect(page).to have_content(investment.description)
|
||||
expect(page).to have_content(investment.author.name)
|
||||
expect(page).to have_content(investment.heading.name)
|
||||
expect(page).to have_content('1234')
|
||||
expect(page).to have_content('Unfeasible')
|
||||
expect(page).to have_content('It is impossible')
|
||||
expect(page).to have_content('Ana (ana@admins.org)')
|
||||
|
||||
within('#assigned_valuators') do
|
||||
expect(page).to have_content('Rachel (rachel@valuators.org)')
|
||||
expect(page).to have_content('Rick (rick@valuators.org)')
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'visible for admins' do
|
||||
logout
|
||||
login_as create(:administrator).user
|
||||
|
||||
administrator = create(:administrator, user: create(:user, username: 'Ana', email: 'ana@admins.org'))
|
||||
valuator2 = create(:valuator, user: create(:user, username: 'Rick', email: 'rick@valuators.org'))
|
||||
investment = create(:budget_investment,
|
||||
budget: @budget,
|
||||
price: 1234,
|
||||
feasibility: 'unfeasible',
|
||||
unfeasibility_explanation: 'It is impossible',
|
||||
administrator: administrator)
|
||||
investment.valuators << [@valuator, valuator2]
|
||||
|
||||
visit valuation_budget_budget_investment_path(@budget, investment)
|
||||
|
||||
expect(page).to have_content(investment.title)
|
||||
expect(page).to have_content(investment.description)
|
||||
expect(page).to have_content(investment.author.name)
|
||||
expect(page).to have_content(investment.heading.name)
|
||||
expect(page).to have_content('1234')
|
||||
expect(page).to have_content('Unfeasible')
|
||||
expect(page).to have_content('It is impossible')
|
||||
expect(page).to have_content('Ana (ana@admins.org)')
|
||||
|
||||
within('#assigned_valuators') do
|
||||
expect(page).to have_content('Rachel (rachel@valuators.org)')
|
||||
expect(page).to have_content('Rick (rick@valuators.org)')
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'not visible for not assigned valuators' do
|
||||
logout
|
||||
login_as create(:valuator).user
|
||||
|
||||
valuator2 = create(:valuator, user: create(:user, username: 'Rick', email: 'rick@valuators.org'))
|
||||
investment = create(:budget_investment,
|
||||
budget: @budget,
|
||||
price: 1234,
|
||||
feasibility: 'unfeasible',
|
||||
unfeasibility_explanation: 'It is impossible',
|
||||
administrator: create(:administrator))
|
||||
investment.valuators << [@valuator, valuator2]
|
||||
|
||||
expect { visit valuation_budget_budget_investment_path(@budget, investment) }.to raise_error "Not Found"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
feature 'Valuate' do
|
||||
background do
|
||||
@investment = create(:budget_investment,
|
||||
budget: @budget,
|
||||
price: nil,
|
||||
administrator: create(:administrator))
|
||||
@investment.valuators << @valuator
|
||||
end
|
||||
|
||||
scenario 'Dossier empty by default' do
|
||||
visit valuation_budget_budget_investments_path(@budget)
|
||||
click_link @investment.title
|
||||
|
||||
within('#price') { expect(page).to have_content('Undefined') }
|
||||
within('#price_first_year') { expect(page).to have_content('Undefined') }
|
||||
within('#duration') { expect(page).to have_content('Undefined') }
|
||||
within('#feasibility') { expect(page).to have_content('Undecided') }
|
||||
expect(page).to_not have_content('Valuation finished')
|
||||
expect(page).to_not have_content('Internal comments')
|
||||
end
|
||||
|
||||
scenario 'Edit dossier' do
|
||||
visit valuation_budget_budget_investments_path(@budget)
|
||||
within("#budget_investment_#{@investment.id}") do
|
||||
click_link "Edit"
|
||||
end
|
||||
|
||||
fill_in 'budget_investment_price', with: '12345'
|
||||
fill_in 'budget_investment_price_first_year', with: '9876'
|
||||
fill_in 'budget_investment_price_explanation', with: 'Very cheap idea'
|
||||
choose 'budget_investment_feasibility_feasible'
|
||||
fill_in 'budget_investment_duration', with: '19 months'
|
||||
fill_in 'budget_investment_internal_comments', with: 'Should be double checked by the urbanism area'
|
||||
click_button 'Save changes'
|
||||
|
||||
expect(page).to have_content "Dossier updated"
|
||||
|
||||
visit valuation_budget_budget_investments_path(@budget)
|
||||
click_link @investment.title
|
||||
|
||||
within('#price') { expect(page).to have_content('12345') }
|
||||
within('#price_first_year') { expect(page).to have_content('9876') }
|
||||
expect(page).to have_content('Very cheap idea')
|
||||
within('#duration') { expect(page).to have_content('19 months') }
|
||||
within('#feasibility') { expect(page).to have_content('Feasible') }
|
||||
expect(page).to_not have_content('Valuation finished')
|
||||
expect(page).to have_content('Internal comments')
|
||||
expect(page).to have_content('Should be double checked by the urbanism area')
|
||||
end
|
||||
|
||||
scenario 'Feasibility can be marked as pending' do
|
||||
visit valuation_budget_budget_investment_path(@budget, @investment)
|
||||
click_link 'Edit dossier'
|
||||
|
||||
expect(find "#budget_investment_feasibility_undecided").to be_checked
|
||||
choose 'budget_investment_feasibility_feasible'
|
||||
click_button 'Save changes'
|
||||
|
||||
visit edit_valuation_budget_budget_investment_path(@budget, @investment)
|
||||
|
||||
expect(find "#budget_investment_feasibility_undecided").to_not be_checked
|
||||
expect(find "#budget_investment_feasibility_feasible").to be_checked
|
||||
|
||||
choose 'budget_investment_feasibility_undecided'
|
||||
click_button 'Save changes'
|
||||
|
||||
visit edit_valuation_budget_budget_investment_path(@budget, @investment)
|
||||
expect(find "#budget_investment_feasibility_undecided").to be_checked
|
||||
end
|
||||
|
||||
scenario 'Feasibility selection makes proper fields visible', :js do
|
||||
feasible_fields = ['Price (€)','Cost during the first year (€)','Price explanation','Time scope']
|
||||
unfeasible_fields = ['Feasibility explanation']
|
||||
any_feasibility_fields = ['Valuation finished','Internal comments']
|
||||
undecided_fields = feasible_fields + unfeasible_fields + any_feasibility_fields
|
||||
|
||||
visit edit_valuation_budget_budget_investment_path(@budget, @investment)
|
||||
|
||||
expect(find "#budget_investment_feasibility_undecided").to be_checked
|
||||
|
||||
undecided_fields.each do |field|
|
||||
expect(page).to have_content(field)
|
||||
end
|
||||
|
||||
choose 'budget_investment_feasibility_feasible'
|
||||
|
||||
unfeasible_fields.each do |field|
|
||||
expect(page).to_not have_content(field)
|
||||
end
|
||||
|
||||
(feasible_fields + any_feasibility_fields).each do |field|
|
||||
expect(page).to have_content(field)
|
||||
end
|
||||
|
||||
choose 'budget_investment_feasibility_unfeasible'
|
||||
|
||||
feasible_fields.each do |field|
|
||||
expect(page).to_not have_content(field)
|
||||
end
|
||||
|
||||
(unfeasible_fields + any_feasibility_fields).each do |field|
|
||||
expect(page).to have_content(field)
|
||||
end
|
||||
|
||||
click_button 'Save changes'
|
||||
|
||||
visit edit_valuation_budget_budget_investment_path(@budget, @investment)
|
||||
|
||||
expect(find "#budget_investment_feasibility_unfeasible").to be_checked
|
||||
feasible_fields.each do |field|
|
||||
expect(page).to_not have_content(field)
|
||||
end
|
||||
|
||||
(unfeasible_fields + any_feasibility_fields).each do |field|
|
||||
expect(page).to have_content(field)
|
||||
end
|
||||
|
||||
choose 'budget_investment_feasibility_undecided'
|
||||
|
||||
undecided_fields.each do |field|
|
||||
expect(page).to have_content(field)
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Finish valuation' do
|
||||
visit valuation_budget_budget_investment_path(@budget, @investment)
|
||||
click_link 'Edit dossier'
|
||||
|
||||
check 'budget_investment_valuation_finished'
|
||||
click_button 'Save changes'
|
||||
|
||||
visit valuation_budget_budget_investments_path(@budget)
|
||||
expect(page).to_not have_content @investment.title
|
||||
click_link 'Valuation finished'
|
||||
|
||||
expect(page).to have_content @investment.title
|
||||
click_link @investment.title
|
||||
expect(page).to have_content('Valuation finished')
|
||||
end
|
||||
|
||||
scenario 'Validates price formats' do
|
||||
visit valuation_budget_budget_investments_path(@budget)
|
||||
within("#budget_investment_#{@investment.id}") do
|
||||
click_link "Edit"
|
||||
end
|
||||
|
||||
fill_in 'budget_investment_price', with: '12345,98'
|
||||
fill_in 'budget_investment_price_first_year', with: '9876.6'
|
||||
click_button 'Save changes'
|
||||
|
||||
expect(page).to have_content('2 errors')
|
||||
expect(page).to have_content('Only integer numbers', count: 2)
|
||||
end
|
||||
end
|
||||
end
|
||||
74
spec/features/valuation/budgets_spec.rb
Normal file
74
spec/features/valuation/budgets_spec.rb
Normal file
@@ -0,0 +1,74 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature 'Valuation budgets' do
|
||||
|
||||
background do
|
||||
@valuator = create(:valuator, user: create(:user, username: 'Rachel', email: 'rachel@valuators.org'))
|
||||
login_as(@valuator.user)
|
||||
end
|
||||
|
||||
scenario 'Disabled with a feature flag' do
|
||||
Setting['feature.budgets'] = nil
|
||||
expect{ visit valuation_budgets_path }.to raise_exception(FeatureFlags::FeatureDisabled)
|
||||
end
|
||||
|
||||
context 'Index' do
|
||||
|
||||
scenario 'Displaying budgets' do
|
||||
budget = create(:budget)
|
||||
visit valuation_budgets_path
|
||||
|
||||
expect(page).to have_content(budget.name)
|
||||
end
|
||||
|
||||
scenario 'Filters by phase' do
|
||||
budget1 = create(:budget)
|
||||
budget2 = create(:budget, :accepting)
|
||||
budget3 = create(:budget, :selecting)
|
||||
budget4 = create(:budget, :balloting)
|
||||
budget5 = create(:budget, :finished)
|
||||
|
||||
visit valuation_budgets_path
|
||||
expect(page).to have_content(budget1.name)
|
||||
expect(page).to have_content(budget2.name)
|
||||
expect(page).to have_content(budget3.name)
|
||||
expect(page).to have_content(budget4.name)
|
||||
expect(page).to_not have_content(budget5.name)
|
||||
|
||||
click_link 'Finished'
|
||||
expect(page).to_not have_content(budget1.name)
|
||||
expect(page).to_not have_content(budget2.name)
|
||||
expect(page).to_not have_content(budget3.name)
|
||||
expect(page).to_not have_content(budget4.name)
|
||||
expect(page).to have_content(budget5.name)
|
||||
|
||||
click_link 'Open'
|
||||
expect(page).to have_content(budget1.name)
|
||||
expect(page).to have_content(budget2.name)
|
||||
expect(page).to have_content(budget3.name)
|
||||
expect(page).to have_content(budget4.name)
|
||||
expect(page).to_not have_content(budget5.name)
|
||||
end
|
||||
|
||||
scenario 'Current filter is properly highlighted' do
|
||||
filters_links = {'open' => 'Open', 'finished' => 'Finished'}
|
||||
|
||||
visit valuation_budgets_path
|
||||
|
||||
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 valuation_budgets_path(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
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user