diff --git a/app/controllers/management/budget_investments_controller.rb b/app/controllers/management/budget_investments_controller.rb index 31706ce89..64dd30492 100644 --- a/app/controllers/management/budget_investments_controller.rb +++ b/app/controllers/management/budget_investments_controller.rb @@ -2,6 +2,7 @@ class Management::BudgetInvestmentsController < Management::BaseController before_action :only_verified_users, except: :print before_action :set_budget_investment, only: [:vote, :show] + before_action :load_budget def index @budget_investments = apply_filters_and_search(Budget::Investment).order(cached_votes_up: :desc).page(params[:page]).for_render diff --git a/app/controllers/management/budgets_controller.rb b/app/controllers/management/budgets_controller.rb new file mode 100644 index 000000000..d4d5b8592 --- /dev/null +++ b/app/controllers/management/budgets_controller.rb @@ -0,0 +1,16 @@ +class Management::BudgetsController < Management::BaseController + include FeatureFlags + feature_flag :budgets + + has_filters %w{open finished}, only: :index + + load_and_authorize_resource + + def index + @budgets = @budgets.send(@current_filter).order(created_at: :desc).page(params[:page]) + end + + def show + @budget = Budget.includes(groups: :headings).find(params[:id]) + end +end diff --git a/app/views/budgets/investments/_form.html.erb b/app/views/budgets/investments/_form.html.erb index 249637d40..37de94a2c 100644 --- a/app/views/budgets/investments/_form.html.erb +++ b/app/views/budgets/investments/_form.html.erb @@ -21,7 +21,7 @@
<%= f.label :heading_id, t("budget.investments.form.heading") %> - <%= f.select :heading_id, heading_select_options, {include_blank: t("budget.headings.none"), label: false} %> + <%= f.select :heading_id, budget_heading_select_options(@budget), {include_blank: t("budget.headings.none"), label: false} %>
diff --git a/spec/features/management/budget_investments_spec.rb b/spec/features/management/budget_investments_spec.rb index 7d793bfd3..75cc7b4eb 100644 --- a/spec/features/management/budget_investments_spec.rb +++ b/spec/features/management/budget_investments_spec.rb @@ -4,6 +4,15 @@ feature 'Budget Investments' do background do login_as_manager + @budget = create(:budget) + end + + context "Select a budget" do + budget2 = create(:budget) + budget3 = create(:budget) + + click_link "Create budget investment" + end context "Create" do @@ -12,7 +21,6 @@ feature 'Budget Investments' do user = create(:user, :level_two) login_managed_user(user) - save_and_open_page click_link "Create budget investment" within(".account-info") do