Fix staff not being loaded after creating budget
This commit is contained in:
committed by
Javi Martín
parent
8a3f03c1b3
commit
0b2b8b557d
@@ -7,6 +7,7 @@ class Admin::BudgetsController < Admin::BaseController
|
|||||||
has_filters %w[open finished], only: :index
|
has_filters %w[open finished], only: :index
|
||||||
|
|
||||||
before_action :load_budget, except: [:index, :new, :create]
|
before_action :load_budget, except: [:index, :new, :create]
|
||||||
|
before_action :load_staff, only: [:new, :create, :edit, :update, :show]
|
||||||
load_and_authorize_resource
|
load_and_authorize_resource
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@@ -17,11 +18,9 @@ class Admin::BudgetsController < Admin::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
load_staff
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
load_staff
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def calculate_winners
|
def calculate_winners
|
||||||
@@ -38,7 +37,6 @@ class Admin::BudgetsController < Admin::BaseController
|
|||||||
if @budget.update(budget_params)
|
if @budget.update(budget_params)
|
||||||
redirect_to admin_budgets_path, notice: t("admin.budgets.update.notice")
|
redirect_to admin_budgets_path, notice: t("admin.budgets.update.notice")
|
||||||
else
|
else
|
||||||
load_staff
|
|
||||||
render :edit
|
render :edit
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -48,7 +46,6 @@ class Admin::BudgetsController < Admin::BaseController
|
|||||||
if @budget.save
|
if @budget.save
|
||||||
redirect_to admin_budget_path(@budget), notice: t("admin.budgets.create.notice")
|
redirect_to admin_budget_path(@budget), notice: t("admin.budgets.create.notice")
|
||||||
else
|
else
|
||||||
load_staff
|
|
||||||
render :new
|
render :new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -112,6 +112,8 @@ describe "Admin budgets", :admin do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Create budget - Approval voting", :js do
|
scenario "Create budget - Approval voting", :js do
|
||||||
|
admin = Administrator.first
|
||||||
|
|
||||||
visit admin_budgets_path
|
visit admin_budgets_path
|
||||||
click_link "Create new budget"
|
click_link "Create new budget"
|
||||||
|
|
||||||
@@ -121,8 +123,12 @@ describe "Admin budgets", :admin do
|
|||||||
click_button "Create Budget"
|
click_button "Create Budget"
|
||||||
|
|
||||||
expect(page).to have_content "New participatory budget created successfully!"
|
expect(page).to have_content "New participatory budget created successfully!"
|
||||||
expect(page).to have_content "M30 - Summer campaign"
|
expect(page).to have_field "Name", with: "M30 - Summer campaign"
|
||||||
expect(Budget.last.voting_style).to eq "approval"
|
expect(page).to have_select "Final voting style", selected: "Approval"
|
||||||
|
|
||||||
|
click_link "Select administrators"
|
||||||
|
|
||||||
|
expect(page).to have_field admin.name
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Name is mandatory" do
|
scenario "Name is mandatory" do
|
||||||
|
|||||||
Reference in New Issue
Block a user