Display only current budget to Managers printing investments

In the specs, some investment were missing a heading_id, thus creating
another unexpected budget

By explicitly setting the heading_id we can control better which
budgets are created in each test
This commit is contained in:
rgarcia
2018-01-15 20:26:57 +01:00
parent 349780922d
commit 01ef439053
3 changed files with 10 additions and 9 deletions

View File

@@ -19,7 +19,7 @@ class Management::BudgetsController < Management::BaseController
end
def print_investments
@budgets = Budget.current.order(created_at: :desc).page(params[:page])
@budget = Budget.current
end
private

View File

@@ -1,12 +1,10 @@
<table>
<% @budgets.each do |budget| %>
<tr id="<%= dom_id(budget) %>">
<td><%= budget.name %></td>
<td><%= budget.translated_phase %></td>
<tr id="<%= dom_id(@budget) %>">
<td><%= @budget.name %></td>
<td><%= @budget.translated_phase %></td>
<td align="right">
<%= link_to t("management.budgets.print_investments"),
print_management_budget_investments_path(budget) %>
print_management_budget_investments_path(@budget) %>
</td>
</tr>
<% end %>
</table>

View File

@@ -259,9 +259,10 @@ feature 'Budget Investments' do
context "Printing" do
scenario 'Printing budget investments' do
16.times { create(:budget_investment, budget: @budget) }
16.times { create(:budget_investment, budget: @budget, heading: @heading) }
click_link "Print Budget Investments"
expect(page).to have_content(@budget.name)
within "#budget_#{@budget.id}" do
click_link "Print Budget Investments"
@@ -273,15 +274,17 @@ feature 'Budget Investments' do
scenario "Filtering budget investments by heading to be printed", :js do
district_9 = create(:budget_heading, group: @group, name: "District Nine")
another_heading = create(:budget_heading, group: @group)
low_investment = create(:budget_investment, budget: @budget, title: 'Nuke district 9', heading: district_9, cached_votes_up: 1)
mid_investment = create(:budget_investment, budget: @budget, title: 'Change district 9', heading: district_9, cached_votes_up: 10)
top_investment = create(:budget_investment, budget: @budget, title: 'Destroy district 9', heading: district_9, cached_votes_up: 100)
unvoted_investment = create(:budget_investment, budget: @budget, title: 'Add new districts to the city')
unvoted_investment = create(:budget_investment, budget: @budget, heading: another_heading, title: 'Add new districts to the city')
user = create(:user, :level_two)
login_managed_user(user)
click_link "Print Budget Investments"
expect(page).to have_content(@budget.name)
within "#budget_#{@budget.id}" do
click_link "Print Budget Investments"