Merge pull request #1325 from consul/budgets-gaspar
Budgets - several fixes
This commit is contained in:
@@ -2,12 +2,16 @@ class Valuation::BudgetsController < Valuation::BaseController
|
|||||||
include FeatureFlags
|
include FeatureFlags
|
||||||
feature_flag :budgets
|
feature_flag :budgets
|
||||||
|
|
||||||
has_filters %w{current finished}, only: :index
|
|
||||||
|
|
||||||
load_and_authorize_resource
|
load_and_authorize_resource
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@budgets = Budget.send(@current_filter).order(created_at: :desc).page(params[:page])
|
@budgets = @budgets.current.order(created_at: :desc).page(params[:page])
|
||||||
|
@investments_with_valuation_open = {}
|
||||||
|
@budgets.each do |b|
|
||||||
|
@investments_with_valuation_open[b.id] = b.investments
|
||||||
|
.by_valuator(current_user.valuator.try(:id))
|
||||||
|
.valuation_open
|
||||||
|
.count
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ module Abilities
|
|||||||
can [:read, :create, :update, :destroy], Budget::Group
|
can [:read, :create, :update, :destroy], Budget::Group
|
||||||
can [:read, :create, :update, :destroy], Budget::Heading
|
can [:read, :create, :update, :destroy], Budget::Heading
|
||||||
can [:hide, :update, :toggle_selection], Budget::Investment
|
can [:hide, :update, :toggle_selection], Budget::Investment
|
||||||
can :valuate, Budget::Investment, budget: { phase: 'valuating' }
|
can :valuate, Budget::Investment
|
||||||
can :create, Budget::ValuatorAssignment
|
can :create, Budget::ValuatorAssignment
|
||||||
|
|
||||||
can [:search, :edit, :update, :create, :index, :destroy], Banner
|
can [:search, :edit, :update, :create, :index, :destroy], Banner
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ module Abilities
|
|||||||
def initialize(user)
|
def initialize(user)
|
||||||
valuator = user.valuator
|
valuator = user.valuator
|
||||||
can [:read, :update, :valuate], SpendingProposal
|
can [:read, :update, :valuate], SpendingProposal
|
||||||
can [:read, :update, :valuate], Budget::Investment, id: valuator.investment_ids, budget: { phase: 'valuating' }
|
can [:read, :update, :valuate], Budget::Investment, id: valuator.investment_ids
|
||||||
|
cannot [:update, :valuate], Budget::Investment, budget: { phase: 'finished' }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -36,14 +36,17 @@ class Budget
|
|||||||
self.groups.include?(group)
|
self.groups.include?(group)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def wrong_budget?(heading)
|
||||||
|
heading.budget_id != budget_id
|
||||||
|
end
|
||||||
|
|
||||||
|
def different_heading_assigned?(heading)
|
||||||
|
other_heading_ids = heading.group.heading_ids - [heading.id]
|
||||||
|
lines.where(heading_id: other_heading_ids).exists?
|
||||||
|
end
|
||||||
|
|
||||||
def valid_heading?(heading)
|
def valid_heading?(heading)
|
||||||
group = heading.group
|
!wrong_budget?(heading) && !different_heading_assigned?(heading)
|
||||||
return false if group.budget_id != budget_id
|
|
||||||
|
|
||||||
line = lines.where(heading_id: group.heading_ids).first
|
|
||||||
return false if line.present? && line.heading_id != heading.id
|
|
||||||
|
|
||||||
true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def has_lines_with_no_heading?
|
def has_lines_with_no_heading?
|
||||||
|
|||||||
@@ -9,28 +9,24 @@ class Budget
|
|||||||
|
|
||||||
validates :ballot_id, :investment_id, :heading_id, :group_id, :budget_id, presence: true
|
validates :ballot_id, :investment_id, :heading_id, :group_id, :budget_id, presence: true
|
||||||
|
|
||||||
validate :insufficient_funds
|
validate :check_selected
|
||||||
#needed? validate :different_geozone, :if => :district_proposal?
|
validate :check_sufficient_funds
|
||||||
validate :unselected
|
validate :check_valid_heading
|
||||||
|
|
||||||
before_validation :set_denormalized_ids
|
before_validation :set_denormalized_ids
|
||||||
|
|
||||||
def insufficient_funds
|
def check_sufficient_funds
|
||||||
errors.add(:money, "insufficient funds") if ballot.amount_available(investment.heading) < investment.price.to_i
|
errors.add(:money, "insufficient funds") if ballot.amount_available(investment.heading) < investment.price.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
def different_geozone
|
def check_valid_heading
|
||||||
errors.add(:heading, "different heading assigned") if (ballot.heading.present? && investment.heading != ballot.heading)
|
errors.add(:heading, "This heading's budget is invalid, or a heading on the same group was already selected") unless ballot.valid_heading?(self.heading)
|
||||||
end
|
end
|
||||||
|
|
||||||
def unselected
|
def check_selected
|
||||||
errors.add(:investment, "unselected investment") unless investment.selected?
|
errors.add(:investment, "unselected investment") unless investment.selected?
|
||||||
end
|
end
|
||||||
|
|
||||||
def heading_proposal?
|
|
||||||
investment.heading_id.present?
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_denormalized_ids
|
def set_denormalized_ids
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
class Budget
|
class Budget
|
||||||
class Heading < ActiveRecord::Base
|
class Heading < ActiveRecord::Base
|
||||||
belongs_to :group
|
belongs_to :group
|
||||||
belongs_to :geozone
|
|
||||||
|
|
||||||
has_many :investments
|
has_many :investments
|
||||||
|
|
||||||
@@ -11,13 +10,7 @@ class Budget
|
|||||||
|
|
||||||
scope :order_by_group_name, -> { includes(:group).order('budget_groups.name', 'budget_headings.name') }
|
scope :order_by_group_name, -> { includes(:group).order('budget_groups.name', 'budget_headings.name') }
|
||||||
|
|
||||||
def budget
|
delegate :budget, :budget_id, to: :group, allow_nil: true
|
||||||
group.budget
|
|
||||||
end
|
|
||||||
|
|
||||||
def budget=(resource)
|
|
||||||
group.budget = resource
|
|
||||||
end
|
|
||||||
|
|
||||||
def name_scoped_by_group
|
def name_scoped_by_group
|
||||||
"#{group.name}: #{name}"
|
"#{group.name}: #{name}"
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class Budget
|
|||||||
scope :by_tag, -> (tag_name) { tagged_with(tag_name) }
|
scope :by_tag, -> (tag_name) { tagged_with(tag_name) }
|
||||||
scope :by_valuator, -> (valuator_id) { where("budget_valuator_assignments.valuator_id = ?", valuator_id).joins(:valuator_assignments) }
|
scope :by_valuator, -> (valuator_id) { where("budget_valuator_assignments.valuator_id = ?", valuator_id).joins(:valuator_assignments) }
|
||||||
|
|
||||||
scope :for_render, -> { includes(heading: :geozone) }
|
scope :for_render, -> { includes(:heading) }
|
||||||
|
|
||||||
before_save :calculate_confidence_score
|
before_save :calculate_confidence_score
|
||||||
before_validation :set_responsible_name
|
before_validation :set_responsible_name
|
||||||
|
|||||||
@@ -3,10 +3,12 @@
|
|||||||
<%= f.text_field :name, maxlength: Budget.title_max_length %>
|
<%= f.text_field :name, maxlength: Budget.title_max_length %>
|
||||||
|
|
||||||
<% Budget::PHASES.each do |phase| %>
|
<% Budget::PHASES.each do |phase| %>
|
||||||
|
<div class="margin-top">
|
||||||
<%= f.cktext_area "description_#{phase}", maxlength: Budget.description_max_length, ckeditor: { language: I18n.locale } %>
|
<%= f.cktext_area "description_#{phase}", maxlength: Budget.description_max_length, ckeditor: { language: I18n.locale } %>
|
||||||
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row margin-top">
|
||||||
<div class="small-12 medium-9 column">
|
<div class="small-12 medium-9 column">
|
||||||
<%= f.select :phase, budget_phases_select_options %>
|
<%= f.select :phase, budget_phases_select_options %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
<div class="small-12 column">
|
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -21,7 +20,6 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th><%= t("admin.budgets.form.table_heading") %></th>
|
<th><%= t("admin.budgets.form.table_heading") %></th>
|
||||||
<th><%= t("admin.budgets.form.table_amount") %></th>
|
<th><%= t("admin.budgets.form.table_amount") %></th>
|
||||||
<th><%= t("admin.budgets.form.table_geozone") %></th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -45,10 +43,6 @@
|
|||||||
maxlength: 8,
|
maxlength: 8,
|
||||||
placeholder: t("admin.budgets.form.amount") %>
|
placeholder: t("admin.budgets.form.amount") %>
|
||||||
</div>
|
</div>
|
||||||
<div class="small-12 medium-6 column">
|
|
||||||
<label><%= t("admin.budgets.form.geozone") %></label>
|
|
||||||
<%= f.select :geozone_id, geozone_select_options, {include_blank: t("geozones.none"), label: false} %>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= f.submit t("admin.budgets.form.save_heading"), class: "button success" %>
|
<%= f.submit t("admin.budgets.form.save_heading"), class: "button success" %>
|
||||||
@@ -65,9 +59,6 @@
|
|||||||
<td>
|
<td>
|
||||||
<%= heading.price %>
|
<%= heading.price %>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
|
||||||
<%= geozone_name_from_id heading.geozone_id %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
<!-- /. headings list -->
|
<!-- /. headings list -->
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<div class="small-12 column">
|
<h3 class="inline-block"><%= t('admin.budgets.show.groups', count: groups.count) %></h3>
|
||||||
<h3 class="inline-block"><%= t('admin.budgets.show.groups') %></h3>
|
|
||||||
<% if groups.blank? %>
|
<% if groups.blank? %>
|
||||||
<div class="callout primary">
|
<div class="callout primary">
|
||||||
<%= t("admin.budgets.form.no_groups") %>
|
<%= t("admin.budgets.form.no_groups") %>
|
||||||
@@ -27,8 +26,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% groups.each do |group| %>
|
<% groups.each do |group| %>
|
||||||
<div class="row" id="<%= dom_id(group) %>">
|
<div id="<%= dom_id(group) %>">
|
||||||
<%= render "admin/budgets/group", group: group, headings: group.headings %>
|
<%= render "admin/budgets/group", group: group, headings: group.headings %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
|
||||||
@@ -1,3 +1,8 @@
|
|||||||
|
<%= link_to admin_budgets_path do %>
|
||||||
|
<span class="icon-angle-left"></span>
|
||||||
|
<%= t('shared.back') %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="small-12 medium-9 column">
|
<div class="small-12 medium-9 column">
|
||||||
<h2><%= t("admin.budgets.edit.title") %></h2>
|
<h2><%= t("admin.budgets.edit.title") %></h2>
|
||||||
|
|||||||
@@ -6,23 +6,39 @@
|
|||||||
|
|
||||||
<%= render 'shared/filter_subnav', i18n_namespace: "admin.budgets.index" %>
|
<%= render 'shared/filter_subnav', i18n_namespace: "admin.budgets.index" %>
|
||||||
|
|
||||||
|
|
||||||
<h3><%= page_entries_info @budgets %></h3>
|
<h3><%= page_entries_info @budgets %></h3>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th><%= t("admin.budgets.index.table_name") %></th>
|
||||||
|
<th><%= t("admin.budgets.index.table_phase") %></th>
|
||||||
|
<th><%= t("admin.budgets.index.table_investments") %></th>
|
||||||
|
<th><%= t("admin.budgets.index.table_edit_groups") %></th>
|
||||||
|
<th><%= t("admin.budgets.index.table_edit_budget") %></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
<% @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_budget_investments_path(budget_id: budget.id) %>
|
<%= budget.name %>
|
||||||
</td>
|
</td>
|
||||||
<td class="small">
|
<td class="small">
|
||||||
<%= t("budget.phase.#{budget.phase}") %>
|
<%= t("budget.phase.#{budget.phase}") %>
|
||||||
</td>
|
</td>
|
||||||
<td class="small">
|
<td class="small">
|
||||||
<%= link_to t("admin.budgets.index.info_link"), admin_budget_path(budget) %>
|
<%= link_to t("admin.budgets.index.budget_investments"), admin_budget_budget_investments_path(budget_id: budget.id) %>
|
||||||
|
</td>
|
||||||
|
<td class="small">
|
||||||
|
<%= link_to t("admin.budgets.index.edit_groups"), admin_budget_path(budget) %>
|
||||||
|
</td>
|
||||||
|
<td class="small">
|
||||||
|
<%= link_to t("admin.budgets.index.edit_budget"), edit_admin_budget_path(budget) %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<%= paginate @budgets %>
|
<%= paginate @budgets %>
|
||||||
@@ -1,16 +1,10 @@
|
|||||||
<div class="row">
|
<%= link_to admin_budgets_path do %>
|
||||||
<div class="small-12 medium-9 column">
|
<span class="icon-angle-left"></span>
|
||||||
<h2><%= @budget.name %> <small><%= link_to(t('shared.edit'), edit_admin_budget_path(@budget)) %></small></h2>
|
<%= t('shared.back') %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<%= @budget.description %>
|
<h2><%= @budget.name %></h2>
|
||||||
|
|
||||||
<p>
|
<div id="<%= dom_id @budget %>_groups">
|
||||||
<strong><%= t('admin.budgets.show.phase') %>:</strong> <%= t("budget.phase.#{@budget.phase}") %> |
|
|
||||||
<strong><%= t('admin.budgets.show.currency') %>:</strong> <%= @budget.currency_symbol %>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="<%= dom_id @budget %>_groups" class="row">
|
|
||||||
<%= render "groups", groups: @budget.groups %>
|
<%= render "groups", groups: @budget.groups %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
<div class="row progress-votes">
|
<div class="row progress-votes">
|
||||||
<div class="small-12 column">
|
<div class="small-12 column">
|
||||||
<div class="progress-bar-nav" data-fixed-bar>
|
<div class="progress-bar-nav" data-fixed-bar>
|
||||||
<h1 class="inline-block"><%= @filter_geozone_name %></h1>
|
<h1 class="inline-block"><%= @heading.name %></h1>
|
||||||
<div id="check-ballot" style="display: none;">
|
<div id="check-ballot" style="display: none;">
|
||||||
<% if can? :show, @ballot %>
|
<% if can? :show, @ballot %>
|
||||||
<%= link_to t("budget.investments.header.check_ballot"),
|
<%= link_to t("budget.investments.header.check_ballot"),
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
method: "post",
|
method: "post",
|
||||||
remote: true,
|
remote: true,
|
||||||
"aria-hidden" => css_for_aria_hidden(reason) do %>
|
"aria-hidden" => css_for_aria_hidden(reason) do %>
|
||||||
<%= t("budget.investments.investment.vote") %>
|
<%= t("budget.investments.investment.give_support") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
<%= link_to "#{t('valuation.budget_investments.show.title')} #{@investment.id}", valuation_budget_budget_investment_path(@budget, @investment), class: 'back' %>
|
<%= link_to valuation_budget_budget_investment_path(@budget, @investment), class: 'back' do %>
|
||||||
|
<span class="icon-angle-left"></span>
|
||||||
|
<%= "#{t('valuation.budget_investments.show.title')} #{@investment.id}"%>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<h2><%= t("valuation.budget_investments.edit.dossier") %></h2>
|
<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| %>
|
<%= form_for(@investment, url: valuate_valuation_budget_budget_investment_path(@budget, @investment), html: {id: "valuation_budget_investment_edit_form"}) do |f| %>
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
<h2><%= @budget.name %> - <%= t("valuation.budget_investments.index.title") %></h2>
|
<h2>
|
||||||
|
<%= @budget.name %> - <%= t("valuation.budget_investments.index.title") %>
|
||||||
|
<small><%= t('valuation.budget_investments.index.assigned_to', valuator: current_user.name) %></small>
|
||||||
|
</h2>
|
||||||
|
|
||||||
<div class="row collapse">
|
<div class="row collapse">
|
||||||
<% @heading_filters.each_slice(8) do |slice| %>
|
<% @heading_filters.each_slice(8) do |slice| %>
|
||||||
@@ -18,6 +21,15 @@
|
|||||||
<h3><%= page_entries_info @investments %></h3>
|
<h3><%= page_entries_info @investments %></h3>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th><%= t("valuation.budget_investments.index.table_id") %></th>
|
||||||
|
<th><%= t("valuation.budget_investments.index.table_title") %></th>
|
||||||
|
<th><%= t("valuation.budget_investments.index.table_heading_name") %></th>
|
||||||
|
<th><%= t("valuation.budget_investments.index.table_actions") %></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
<% @investments.each do |investment| %>
|
<% @investments.each do |investment| %>
|
||||||
<tr id="<%= dom_id(investment) %>">
|
<tr id="<%= dom_id(investment) %>">
|
||||||
<td>
|
<td>
|
||||||
@@ -26,17 +38,17 @@
|
|||||||
<td>
|
<td>
|
||||||
<%= link_to investment.title, valuation_budget_budget_investment_path(@budget, investment) %>
|
<%= link_to investment.title, valuation_budget_budget_investment_path(@budget, investment) %>
|
||||||
</td>
|
</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">
|
<td class="small">
|
||||||
<%= investment.heading.name %>
|
<%= investment.heading.name %>
|
||||||
</td>
|
</td>
|
||||||
|
<td class="small">
|
||||||
|
<%= link_to t("valuation.budget_investments.index.edit"),
|
||||||
|
edit_valuation_budget_budget_investment_path(@budget, investment),
|
||||||
|
class: "button hollow expanded" %>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<%= paginate @investments %>
|
<%= paginate @investments %>
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
<%= render "shared/back_link" %>
|
<%= link_to valuation_budget_budget_investments_path do %>
|
||||||
|
<span class="icon-angle-left"></span>
|
||||||
|
<%= t('shared.back') %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<h2><%= t("valuation.budget_investments.show.title") %> <%= @investment.id %> </h2>
|
<h2><%= t("valuation.budget_investments.show.title") %> <%= @investment.id %> </h2>
|
||||||
<h1><%= @investment.title %></h1>
|
<h1><%= @investment.title %></h1>
|
||||||
|
|||||||
@@ -1,17 +1,36 @@
|
|||||||
<h2 class="inline-block"><%= t("valuation.budgets.index.title") %></h2>
|
<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>
|
<h3><%= page_entries_info @budgets %></h3>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th><%= t("valuation.budgets.index.table_name") %></th>
|
||||||
|
<th><%= t("valuation.budgets.index.table_phase") %></th>
|
||||||
|
<th><%= t("valuation.budgets.index.table_assigned_investments_valuation_open") %></th>
|
||||||
|
<th><%= t("valuation.budgets.index.table_actions") %></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
<% @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, valuation_budget_budget_investments_path(budget_id: budget.id) %>
|
<%= budget.name %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= t("budget.phase.#{budget.phase}") %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= @investments_with_valuation_open[budget.id] %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= link_to t("valuation.budgets.index.evaluate"),
|
||||||
|
valuation_budget_budget_investments_path(budget_id: budget.id),
|
||||||
|
class: "button hollow expanded" %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<%= paginate @budgets %>
|
<%= paginate @budgets %>
|
||||||
@@ -62,10 +62,17 @@ en:
|
|||||||
index:
|
index:
|
||||||
title: Participatory budgets
|
title: Participatory budgets
|
||||||
new_link: Create new budget
|
new_link: Create new budget
|
||||||
info_link: Info
|
|
||||||
filters:
|
filters:
|
||||||
open: Open
|
current: Open
|
||||||
finished: Finished
|
finished: Finished
|
||||||
|
budget_investments: See budget investments
|
||||||
|
table_name: Name
|
||||||
|
table_phase: Phase
|
||||||
|
table_investments: Investments
|
||||||
|
table_edit_groups: Headings groups
|
||||||
|
table_edit_budget: Edit
|
||||||
|
edit_groups: Edit headings groups
|
||||||
|
edit_budget: Edit budget
|
||||||
create:
|
create:
|
||||||
notice: New participatory budget created successfully!
|
notice: New participatory budget created successfully!
|
||||||
update:
|
update:
|
||||||
@@ -75,9 +82,9 @@ en:
|
|||||||
new:
|
new:
|
||||||
title: New participatory budget
|
title: New participatory budget
|
||||||
show:
|
show:
|
||||||
phase: Current phase
|
groups:
|
||||||
currency: Currency
|
one: 1 Group of budget headings
|
||||||
groups: Groups of budget headings
|
other: "%{count} Groups of budget headings"
|
||||||
form:
|
form:
|
||||||
group: Group name
|
group: Group name
|
||||||
no_groups: No groups created yet. Each user will be able to vote in only one heading per group.
|
no_groups: No groups created yet. Each user will be able to vote in only one heading per group.
|
||||||
@@ -88,10 +95,8 @@ en:
|
|||||||
amount: Amount
|
amount: Amount
|
||||||
save_heading: Save heading
|
save_heading: Save heading
|
||||||
no_heading: This group has no assigned heading.
|
no_heading: This group has no assigned heading.
|
||||||
geozone: Scope of operation
|
|
||||||
table_heading: Heading
|
table_heading: Heading
|
||||||
table_amount: Amount
|
table_amount: Amount
|
||||||
table_geozone: Scope of operation
|
|
||||||
budget_investments:
|
budget_investments:
|
||||||
index:
|
index:
|
||||||
heading_filter_all: All headings
|
heading_filter_all: All headings
|
||||||
|
|||||||
@@ -62,10 +62,17 @@ es:
|
|||||||
index:
|
index:
|
||||||
title: Presupuestos participativos
|
title: Presupuestos participativos
|
||||||
new_link: Crear nuevo presupuesto
|
new_link: Crear nuevo presupuesto
|
||||||
info_link: Info
|
|
||||||
filters:
|
filters:
|
||||||
open: Abiertos
|
current: Abiertos
|
||||||
finished: Terminados
|
finished: Terminados
|
||||||
|
budget_investments: Ver propuestas de inversión
|
||||||
|
table_name: Nombre
|
||||||
|
table_phase: Fase
|
||||||
|
table_investments: Propuestas de inversión
|
||||||
|
table_edit_groups: Grupos de partidas
|
||||||
|
table_edit_budget: Editar
|
||||||
|
edit_groups: Editar grupos de partidas
|
||||||
|
edit_budget: Editar presupuesto
|
||||||
create:
|
create:
|
||||||
notice: ¡Nueva campaña de presupuestos participativos creada con éxito!
|
notice: ¡Nueva campaña de presupuestos participativos creada con éxito!
|
||||||
update:
|
update:
|
||||||
@@ -75,9 +82,9 @@ es:
|
|||||||
new:
|
new:
|
||||||
title: Nuevo presupuesto ciudadano
|
title: Nuevo presupuesto ciudadano
|
||||||
show:
|
show:
|
||||||
phase: Fase actual
|
groups:
|
||||||
currency: Divisa
|
one: 1 Grupo de partidas presupuestarias
|
||||||
groups: Grupos de partidas presupuestarias
|
other: "%{count} Grupos de partidas presupuestarias"
|
||||||
form:
|
form:
|
||||||
group: Nombre del grupo
|
group: Nombre del grupo
|
||||||
no_groups: No hay grupos creados todavía. Cada usuario podrá votar en una sola partida de cada grupo.
|
no_groups: No hay grupos creados todavía. Cada usuario podrá votar en una sola partida de cada grupo.
|
||||||
@@ -88,10 +95,8 @@ es:
|
|||||||
amount: Cantidad
|
amount: Cantidad
|
||||||
save_heading: Guardar partida
|
save_heading: Guardar partida
|
||||||
no_heading: Este grupo no tiene ninguna partida asignada.
|
no_heading: Este grupo no tiene ninguna partida asignada.
|
||||||
geozone: Ámbito de actuación
|
|
||||||
table_heading: Partida
|
table_heading: Partida
|
||||||
table_amount: Cantidad
|
table_amount: Cantidad
|
||||||
table_geozone: Ámbito de actuación
|
|
||||||
budget_investments:
|
budget_investments:
|
||||||
index:
|
index:
|
||||||
heading_filter_all: Todas las partidas
|
heading_filter_all: Todas las partidas
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ en:
|
|||||||
one: 1 support
|
one: 1 support
|
||||||
other: "%{count} supports"
|
other: "%{count} supports"
|
||||||
zero: No supports
|
zero: No supports
|
||||||
vote: Vote
|
give_support: Support
|
||||||
header:
|
header:
|
||||||
check_ballot: Check my ballot
|
check_ballot: Check my ballot
|
||||||
different_heading_assigned_html: "You have active votes in another heading: %{heading_link}"
|
different_heading_assigned_html: "You have active votes in another heading: %{heading_link}"
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ es:
|
|||||||
one: 1 apoyo
|
one: 1 apoyo
|
||||||
other: "%{count} apoyos"
|
other: "%{count} apoyos"
|
||||||
zero: Sin apoyos
|
zero: Sin apoyos
|
||||||
vote: Votar
|
give_support: Apoyar
|
||||||
header:
|
header:
|
||||||
check_ballot: Revisar mis votos
|
check_ballot: Revisar mis votos
|
||||||
different_heading_assigned_html: "Ya apoyaste propuestas de otra sección del presupuesto: %{heading_link}"
|
different_heading_assigned_html: "Ya apoyaste propuestas de otra sección del presupuesto: %{heading_link}"
|
||||||
|
|||||||
@@ -441,7 +441,6 @@ en:
|
|||||||
collective: Collective
|
collective: Collective
|
||||||
flag: Flag as inappropriate
|
flag: Flag as inappropriate
|
||||||
hide: Hide
|
hide: Hide
|
||||||
edit: Editar
|
|
||||||
print:
|
print:
|
||||||
print_button: Print this info
|
print_button: Print this info
|
||||||
search: Search
|
search: Search
|
||||||
|
|||||||
@@ -445,7 +445,6 @@ es:
|
|||||||
print_button: Imprimir esta información
|
print_button: Imprimir esta información
|
||||||
search: Buscar
|
search: Buscar
|
||||||
show: Mostrar
|
show: Mostrar
|
||||||
edit: Editar
|
|
||||||
suggest:
|
suggest:
|
||||||
debate:
|
debate:
|
||||||
found:
|
found:
|
||||||
|
|||||||
@@ -9,8 +9,13 @@ en:
|
|||||||
index:
|
index:
|
||||||
title: Participatory budgets
|
title: Participatory budgets
|
||||||
filters:
|
filters:
|
||||||
open: Open
|
current: Open
|
||||||
finished: Finished
|
finished: Finished
|
||||||
|
table_name: Name
|
||||||
|
table_phase: Phase
|
||||||
|
table_assigned_investments_valuation_open: Investment projects assigned with valuation open
|
||||||
|
table_actions: Actions
|
||||||
|
evaluate: Evaluate
|
||||||
budget_investments:
|
budget_investments:
|
||||||
index:
|
index:
|
||||||
headings_filter_all: All headings
|
headings_filter_all: All headings
|
||||||
@@ -18,12 +23,17 @@ en:
|
|||||||
valuation_open: Open
|
valuation_open: Open
|
||||||
valuating: Under valuation
|
valuating: Under valuation
|
||||||
valuation_finished: Valuation finished
|
valuation_finished: Valuation finished
|
||||||
|
assigned_to: "Assigned to %{valuator}"
|
||||||
title: Investment projects
|
title: Investment projects
|
||||||
edit: Edit
|
edit: Edit dossier
|
||||||
valuators_assigned:
|
valuators_assigned:
|
||||||
one: Assigned valuator
|
one: Assigned valuator
|
||||||
other: "%{count} valuators assigned"
|
other: "%{count} valuators assigned"
|
||||||
no_valuators_assigned: No valuators assigned
|
no_valuators_assigned: No valuators assigned
|
||||||
|
table_id: ID
|
||||||
|
table_title: Title
|
||||||
|
table_heading_name: Heading name
|
||||||
|
table_actions: Actions
|
||||||
show:
|
show:
|
||||||
back: Back
|
back: Back
|
||||||
title: Investment project
|
title: Investment project
|
||||||
|
|||||||
@@ -9,8 +9,13 @@ es:
|
|||||||
index:
|
index:
|
||||||
title: Presupuestos participativos
|
title: Presupuestos participativos
|
||||||
filters:
|
filters:
|
||||||
open: Abiertos
|
current: Abiertos
|
||||||
finished: Terminados
|
finished: Terminados
|
||||||
|
table_name: Nombre
|
||||||
|
table_phase: Fase
|
||||||
|
table_assigned_investments_valuation_open: Prop. Inv. asignadas en evaluación
|
||||||
|
table_actions: Acciones
|
||||||
|
evaluate: Evaluar
|
||||||
budget_investments:
|
budget_investments:
|
||||||
index:
|
index:
|
||||||
headings_filter_all: Todas las partidas
|
headings_filter_all: Todas las partidas
|
||||||
@@ -19,11 +24,16 @@ es:
|
|||||||
valuating: En evaluación
|
valuating: En evaluación
|
||||||
valuation_finished: Evaluación finalizada
|
valuation_finished: Evaluación finalizada
|
||||||
title: Propuestas de inversión
|
title: Propuestas de inversión
|
||||||
edit: Editar
|
assigned_to: "Asignadas a %{valuator}"
|
||||||
|
edit: Editar informe
|
||||||
valuators_assigned:
|
valuators_assigned:
|
||||||
one: Evaluador asignado
|
one: Evaluador asignado
|
||||||
other: "%{count} evaluadores asignados"
|
other: "%{count} evaluadores asignados"
|
||||||
no_valuators_assigned: Sin evaluador
|
no_valuators_assigned: Sin evaluador
|
||||||
|
table_id: ID
|
||||||
|
table_title: Título
|
||||||
|
table_heading_name: Nombre de la partida
|
||||||
|
table_actions: Acciones
|
||||||
show:
|
show:
|
||||||
back: Volver
|
back: Volver
|
||||||
title: Propuesta de inversión
|
title: Propuesta de inversión
|
||||||
|
|||||||
@@ -373,7 +373,7 @@ tags = Faker::Lorem.words(10)
|
|||||||
description: "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>",
|
description: "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>",
|
||||||
created_at: rand((Time.now - 1.week) .. Time.now),
|
created_at: rand((Time.now - 1.week) .. Time.now),
|
||||||
feasibility: %w{undecided unfeasible feasible feasible feasible feasible}.sample,
|
feasibility: %w{undecided unfeasible feasible feasible feasible feasible}.sample,
|
||||||
unfeasibility_explanation: "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>",
|
unfeasibility_explanation: Faker::Lorem.paragraph,
|
||||||
valuation_finished: [false, true].sample,
|
valuation_finished: [false, true].sample,
|
||||||
tag_list: tags.sample(3).join(','),
|
tag_list: tags.sample(3).join(','),
|
||||||
price: rand(1 .. 100) * 100000,
|
price: rand(1 .. 100) * 100000,
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class RemoveGeozoneIdFromBudgetHeadings < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
remove_column :budget_headings, :geozone_id
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20170102080432) do
|
ActiveRecord::Schema.define(version: 20170103170147) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
@@ -107,7 +107,6 @@ ActiveRecord::Schema.define(version: 20170102080432) do
|
|||||||
|
|
||||||
create_table "budget_headings", force: :cascade do |t|
|
create_table "budget_headings", force: :cascade do |t|
|
||||||
t.integer "group_id"
|
t.integer "group_id"
|
||||||
t.integer "geozone_id"
|
|
||||||
t.string "name", limit: 50
|
t.string "name", limit: 50
|
||||||
t.integer "price", limit: 8
|
t.integer "price", limit: 8
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ feature 'Admin budgets' do
|
|||||||
expect(page).to_not have_content(budget4.name)
|
expect(page).to_not have_content(budget4.name)
|
||||||
expect(page).to have_content(budget5.name)
|
expect(page).to have_content(budget5.name)
|
||||||
|
|
||||||
click_link 'Current'
|
click_link 'Open'
|
||||||
expect(page).to have_content(budget1.name)
|
expect(page).to have_content(budget1.name)
|
||||||
expect(page).to have_content(budget2.name)
|
expect(page).to have_content(budget2.name)
|
||||||
expect(page).to have_content(budget3.name)
|
expect(page).to have_content(budget3.name)
|
||||||
@@ -55,8 +55,8 @@ feature 'Admin budgets' do
|
|||||||
expect(page).to_not have_content(budget5.name)
|
expect(page).to_not have_content(budget5.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Current filter is properly highlighted' do
|
scenario 'Open filter is properly highlighted' do
|
||||||
filters_links = {'current' => 'Current', 'finished' => 'Finished'}
|
filters_links = {'current' => 'Open', 'finished' => 'Finished'}
|
||||||
|
|
||||||
visit admin_budgets_path
|
visit admin_budgets_path
|
||||||
|
|
||||||
@@ -110,22 +110,29 @@ feature 'Admin budgets' do
|
|||||||
visit admin_budgets_path
|
visit admin_budgets_path
|
||||||
|
|
||||||
within("#budget_#{budget.id}") do
|
within("#budget_#{budget.id}") do
|
||||||
click_link 'Info'
|
click_link 'Edit headings groups'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
expect(page).to have_content '0 Groups of budget headings'
|
||||||
expect(page).to have_content 'No groups created yet.'
|
expect(page).to have_content 'No groups created yet.'
|
||||||
|
|
||||||
click_link 'Add new group'
|
click_link 'Add new group'
|
||||||
|
|
||||||
fill_in 'budget_group_name', with: 'General improvments'
|
fill_in 'budget_group_name', with: 'Health'
|
||||||
click_button 'Create group'
|
click_button 'Create group'
|
||||||
|
|
||||||
|
expect(page).to have_content '1 Group of budget headings'
|
||||||
|
expect(page).to have_content 'Health'
|
||||||
expect(page).to have_content 'Yearly participatory budget'
|
expect(page).to have_content 'Yearly participatory budget'
|
||||||
expect(page).to_not have_content 'No groups created yet.'
|
expect(page).to_not have_content 'No groups created yet.'
|
||||||
|
|
||||||
visit admin_budgets_path
|
visit admin_budgets_path
|
||||||
click_link 'Yearly participatory budget'
|
within("#budget_#{budget.id}") do
|
||||||
|
click_link 'Edit headings groups'
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(page).to have_content '1 Group of budget headings'
|
||||||
|
expect(page).to have_content 'Health'
|
||||||
expect(page).to have_content 'Yearly participatory budget'
|
expect(page).to have_content 'Yearly participatory budget'
|
||||||
expect(page).to_not have_content 'No groups created yet.'
|
expect(page).to_not have_content 'No groups created yet.'
|
||||||
end
|
end
|
||||||
@@ -153,7 +160,6 @@ feature 'Admin budgets' do
|
|||||||
|
|
||||||
expect(page).to have_content 'District 9 reconstruction'
|
expect(page).to have_content 'District 9 reconstruction'
|
||||||
expect(page).to have_content '6785'
|
expect(page).to have_content '6785'
|
||||||
expect(page).to have_content 'All city'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -344,10 +344,8 @@ feature 'Budget Investments' do
|
|||||||
global_group = create(:budget_group, budget: budget, name: 'Global Group')
|
global_group = create(:budget_group, budget: budget, name: 'Global Group')
|
||||||
global_heading = create(:budget_heading, group: global_group, name: 'Global Heading')
|
global_heading = create(:budget_heading, group: global_group, name: 'Global Heading')
|
||||||
|
|
||||||
carabanchel = create(:geozone, name: "Carabanchel")
|
carabanchel_heading = create(:budget_heading, group: group, name: "Carabanchel")
|
||||||
new_york = create(:geozone, name: "New York")
|
new_york_heading = create(:budget_heading, group: group, name: "New York")
|
||||||
carabanchel_heading = create(:budget_heading, group: group, geozone: carabanchel, name: carabanchel.name)
|
|
||||||
new_york_heading = create(:budget_heading, group: group, geozone: new_york, name: new_york.name)
|
|
||||||
|
|
||||||
|
|
||||||
sp1 = create(:budget_investment, :selected, price: 1, heading: global_heading)
|
sp1 = create(:budget_investment, :selected, price: 1, heading: global_heading)
|
||||||
|
|||||||
@@ -54,34 +54,6 @@ feature 'Valuation budget investments' do
|
|||||||
expect(investment10.title).to appear_before(investment1.title)
|
expect(investment10.title).to appear_before(investment1.title)
|
||||||
end
|
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
|
scenario "Index filtering by heading", :js do
|
||||||
group = create(:budget_group, budget: @budget)
|
group = create(:budget_group, budget: @budget)
|
||||||
heading1 = create(:budget_heading, name: "District 9", group: group)
|
heading1 = create(:budget_heading, name: "District 9", group: group)
|
||||||
@@ -262,7 +234,7 @@ feature 'Valuation budget investments' do
|
|||||||
scenario 'Edit dossier' do
|
scenario 'Edit dossier' do
|
||||||
visit valuation_budget_budget_investments_path(@budget)
|
visit valuation_budget_budget_investments_path(@budget)
|
||||||
within("#budget_investment_#{@investment.id}") do
|
within("#budget_investment_#{@investment.id}") do
|
||||||
click_link "Edit"
|
click_link "Edit dossier"
|
||||||
end
|
end
|
||||||
|
|
||||||
fill_in 'budget_investment_price', with: '12345'
|
fill_in 'budget_investment_price', with: '12345'
|
||||||
@@ -381,7 +353,7 @@ feature 'Valuation budget investments' do
|
|||||||
scenario 'Validates price formats' do
|
scenario 'Validates price formats' do
|
||||||
visit valuation_budget_budget_investments_path(@budget)
|
visit valuation_budget_budget_investments_path(@budget)
|
||||||
within("#budget_investment_#{@investment.id}") do
|
within("#budget_investment_#{@investment.id}") do
|
||||||
click_link "Edit"
|
click_link "Edit dossier"
|
||||||
end
|
end
|
||||||
|
|
||||||
fill_in 'budget_investment_price', with: '12345,98'
|
fill_in 'budget_investment_price', with: '12345,98'
|
||||||
|
|||||||
@@ -34,39 +34,6 @@ feature 'Valuation budgets' do
|
|||||||
expect(page).to have_content(budget3.name)
|
expect(page).to have_content(budget3.name)
|
||||||
expect(page).to have_content(budget4.name)
|
expect(page).to have_content(budget4.name)
|
||||||
expect(page).to_not have_content(budget5.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 'Current'
|
|
||||||
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 = {'current' => 'Current', '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
|
end
|
||||||
|
|||||||
@@ -66,6 +66,6 @@ describe "Abilities::Administrator" do
|
|||||||
it { should be_able_to(:hide, Budget::Investment) }
|
it { should be_able_to(:hide, Budget::Investment) }
|
||||||
|
|
||||||
it { should be_able_to(:valuate, create(:budget_investment, budget: create(:budget, phase: 'valuating'))) }
|
it { should be_able_to(:valuate, create(:budget_investment, budget: create(:budget, phase: 'valuating'))) }
|
||||||
it { should_not be_able_to(:valuate, create(:budget_investment, budget: create(:budget, phase: 'finished'))) }
|
it { should be_able_to(:valuate, create(:budget_investment, budget: create(:budget, phase: 'finished'))) }
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ describe "Abilities::Valuator" do
|
|||||||
let(:assigned_investment) { create(:budget_investment, budget: create(:budget, phase: 'valuating')) }
|
let(:assigned_investment) { create(:budget_investment, budget: create(:budget, phase: 'valuating')) }
|
||||||
before(:each) { assigned_investment.valuators << valuator }
|
before(:each) { assigned_investment.valuators << valuator }
|
||||||
|
|
||||||
let(:assigned_investment_not_valuating) { create(:budget_investment, budget: create(:budget, phase: 'finished')) }
|
let(:finished_assigned_investment) { create(:budget_investment, budget: create(:budget, phase: 'finished')) }
|
||||||
before(:each) { assigned_investment_not_valuating.valuators << valuator }
|
before(:each) { finished_assigned_investment.valuators << valuator }
|
||||||
|
|
||||||
it { should be_able_to(:read, SpendingProposal) }
|
it { should be_able_to(:read, SpendingProposal) }
|
||||||
it { should be_able_to(:update, SpendingProposal) }
|
it { should be_able_to(:update, SpendingProposal) }
|
||||||
@@ -23,6 +23,6 @@ describe "Abilities::Valuator" do
|
|||||||
it { should be_able_to(:update, assigned_investment) }
|
it { should be_able_to(:update, assigned_investment) }
|
||||||
it { should be_able_to(:valuate, assigned_investment) }
|
it { should be_able_to(:valuate, assigned_investment) }
|
||||||
|
|
||||||
it { should_not be_able_to(:update, assigned_investment_not_valuating) }
|
it { should_not be_able_to(:update, finished_assigned_investment) }
|
||||||
it { should_not be_able_to(:valuate, assigned_investment_not_valuating) }
|
it { should_not be_able_to(:valuate, finished_assigned_investment) }
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -23,29 +23,35 @@ describe Budget::Ballot do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "returns the amount spent on all investments assigned to a specific heading" do
|
it "returns the amount spent on all investments assigned to a specific heading" do
|
||||||
heading = create(:budget_heading)
|
budget = create(:budget)
|
||||||
budget = heading.group.budget
|
group1 = create(:budget_group, budget: budget)
|
||||||
inv1 = create(:budget_investment, :selected, price: 10000, heading: heading)
|
group2 = create(:budget_group, budget: budget)
|
||||||
inv2 = create(:budget_investment, :selected, price: 20000, heading: create(:budget_heading, group: heading.group))
|
heading1 = create(:budget_heading, group: group1, price: 100000)
|
||||||
inv3 = create(:budget_investment, :selected, price: 40000, heading: heading)
|
heading2 = create(:budget_heading, group: group2, price: 200000)
|
||||||
|
inv1 = create(:budget_investment, :selected, price: 10000, heading: heading1)
|
||||||
|
inv2 = create(:budget_investment, :selected, price: 20000, heading: heading2)
|
||||||
|
inv3 = create(:budget_investment, :selected, price: 40000, heading: heading1)
|
||||||
|
|
||||||
ballot = create(:budget_ballot, budget: budget)
|
ballot = create(:budget_ballot, budget: budget)
|
||||||
ballot.investments << inv1 << inv2
|
ballot.investments << inv1 << inv2
|
||||||
|
|
||||||
expect(ballot.amount_spent(heading)).to eq 10000
|
expect(ballot.amount_spent(heading1)).to eq 10000
|
||||||
|
expect(ballot.amount_spent(heading2)).to eq 20000
|
||||||
|
|
||||||
ballot.investments << inv3
|
ballot.investments << inv3
|
||||||
|
|
||||||
expect(ballot.amount_spent(heading)).to eq 50000
|
expect(ballot.amount_spent(heading1)).to eq 50000
|
||||||
|
expect(ballot.amount_spent(heading2)).to eq 20000
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#amount_available" do
|
describe "#amount_available" do
|
||||||
it "returns how much is left after taking some investments" do
|
it "returns how much is left after taking some investments" do
|
||||||
budget = create(:budget)
|
budget = create(:budget)
|
||||||
group = create(:budget_group, budget: budget)
|
group1 = create(:budget_group, budget: budget)
|
||||||
heading1 = create(:budget_heading, group: group, price: 1000)
|
group2 = create(:budget_group, budget: budget)
|
||||||
heading2 = create(:budget_heading, group: group, price: 300)
|
heading1 = create(:budget_heading, group: group1, price: 1000)
|
||||||
|
heading2 = create(:budget_heading, group: group2, price: 300)
|
||||||
inv1 = create(:budget_investment, :selected, price: 100, heading: heading1)
|
inv1 = create(:budget_investment, :selected, price: 100, heading: heading1)
|
||||||
inv2 = create(:budget_investment, :selected, price: 200, heading: heading2)
|
inv2 = create(:budget_investment, :selected, price: 200, heading: heading2)
|
||||||
inv3 = create(:budget_investment, :selected, price: 400, heading: heading1)
|
inv3 = create(:budget_investment, :selected, price: 400, heading: heading1)
|
||||||
|
|||||||
Reference in New Issue
Block a user