diff --git a/app/controllers/management/budgets_controller.rb b/app/controllers/management/budgets_controller.rb index dd7259c99..470d1f9fd 100644 --- a/app/controllers/management/budgets_controller.rb +++ b/app/controllers/management/budgets_controller.rb @@ -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 diff --git a/app/views/management/budgets/print_investments.html.erb b/app/views/management/budgets/print_investments.html.erb index bc115ea3d..d5be7c1ff 100644 --- a/app/views/management/budgets/print_investments.html.erb +++ b/app/views/management/budgets/print_investments.html.erb @@ -1,12 +1,10 @@ -<% @budgets.each do |budget| %> - - - + + + -<% end %>
<%= budget.name %><%= budget.translated_phase %>
<%= @budget.name %><%= @budget.translated_phase %> <%= link_to t("management.budgets.print_investments"), - print_management_budget_investments_path(budget) %> + print_management_budget_investments_path(@budget) %>
diff --git a/spec/features/management/budget_investments_spec.rb b/spec/features/management/budget_investments_spec.rb index f1ced7334..6132c40cd 100644 --- a/spec/features/management/budget_investments_spec.rb +++ b/spec/features/management/budget_investments_spec.rb @@ -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"