Display only current budget for Valuators
Before we could have multiple current budgets, as we now only have one current_budget, some specs broke. As there is no need to display multiple budgets to Valuators, only the current budget is necessary, we can remove arrays and assume that only a single budget, the current budget, is displayed to Valuators
This commit is contained in:
@@ -5,10 +5,10 @@ class Valuation::BudgetsController < Valuation::BaseController
|
||||
load_and_authorize_resource
|
||||
|
||||
def index
|
||||
@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
|
||||
@budget = Budget.current
|
||||
if @budget.present?
|
||||
@investments_with_valuation_open = {}
|
||||
@investments_with_valuation_open = @budget.investments
|
||||
.by_valuator(current_user.valuator.try(:id))
|
||||
.valuation_open
|
||||
.count
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
<h2 class="inline-block"><%= t("valuation.budgets.index.title") %></h2>
|
||||
|
||||
<h3><%= page_entries_info @budgets %></h3>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -12,25 +10,21 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @budgets.each do |budget| %>
|
||||
<tr id="<%= dom_id(budget) %>" class="budget">
|
||||
<td>
|
||||
<%= budget.name %>
|
||||
</td>
|
||||
<td>
|
||||
<%= t("budgets.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>
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr id="<%= dom_id(@budget) %>" class="budget">
|
||||
<td>
|
||||
<%= @budget.name %>
|
||||
</td>
|
||||
<td>
|
||||
<%= t("budgets.phase.#{@budget.phase}") %>
|
||||
</td>
|
||||
<td>
|
||||
<%= @investments_with_valuation_open %>
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to t("valuation.budgets.index.evaluate"),
|
||||
valuation_budget_budget_investments_path(budget_id: @budget.id),
|
||||
class: "button hollow expanded" %>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<%= paginate @budgets %>
|
||||
|
||||
@@ -24,18 +24,15 @@ feature 'Valuation budgets' do
|
||||
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)
|
||||
budget1 = create(:budget, :finished)
|
||||
budget2 = create(:budget, :finished)
|
||||
budget3 = create(:budget, :accepting)
|
||||
|
||||
visit valuation_budgets_path
|
||||
expect(page).to have_content(budget1.name)
|
||||
expect(page).to have_content(budget2.name)
|
||||
|
||||
expect(page).to_not have_content(budget1.name)
|
||||
expect(page).to_not have_content(budget2.name)
|
||||
expect(page).to have_content(budget3.name)
|
||||
expect(page).to have_content(budget4.name)
|
||||
expect(page).not_to have_content(budget5.name)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user