Fix staff not being loaded after creating budget

This commit is contained in:
Julian Herrero
2020-03-15 12:26:59 +07:00
committed by Javi Martín
parent 8a3f03c1b3
commit 0b2b8b557d
2 changed files with 9 additions and 6 deletions

View File

@@ -7,6 +7,7 @@ class Admin::BudgetsController < Admin::BaseController
has_filters %w[open finished], only: :index
before_action :load_budget, except: [:index, :new, :create]
before_action :load_staff, only: [:new, :create, :edit, :update, :show]
load_and_authorize_resource
def index
@@ -17,11 +18,9 @@ class Admin::BudgetsController < Admin::BaseController
end
def new
load_staff
end
def edit
load_staff
end
def calculate_winners
@@ -38,7 +37,6 @@ class Admin::BudgetsController < Admin::BaseController
if @budget.update(budget_params)
redirect_to admin_budgets_path, notice: t("admin.budgets.update.notice")
else
load_staff
render :edit
end
end
@@ -48,7 +46,6 @@ class Admin::BudgetsController < Admin::BaseController
if @budget.save
redirect_to admin_budget_path(@budget), notice: t("admin.budgets.create.notice")
else
load_staff
render :new
end
end

View File

@@ -112,6 +112,8 @@ describe "Admin budgets", :admin do
end
scenario "Create budget - Approval voting", :js do
admin = Administrator.first
visit admin_budgets_path
click_link "Create new budget"
@@ -121,8 +123,12 @@ describe "Admin budgets", :admin do
click_button "Create Budget"
expect(page).to have_content "New participatory budget created successfully!"
expect(page).to have_content "M30 - Summer campaign"
expect(Budget.last.voting_style).to eq "approval"
expect(page).to have_field "Name", with: "M30 - Summer campaign"
expect(page).to have_select "Final voting style", selected: "Approval"
click_link "Select administrators"
expect(page).to have_field admin.name
end
scenario "Name is mandatory" do