diff --git a/app/components/admin/budget_phases/form_component.html.erb b/app/components/admin/budget_phases/form_component.html.erb index e8e0822c0..3fcaab81c 100644 --- a/app/components/admin/budget_phases/form_component.html.erb +++ b/app/components/admin/budget_phases/form_component.html.erb @@ -4,6 +4,8 @@ <%= render "shared/errors", resource: phase %> + <%= render Admin::BudgetsWizard::ModelFieldComponent.new %> +
<%= t("admin.budget_phases.edit.duration") %> diff --git a/app/components/admin/budget_phases/phases_component.html.erb b/app/components/admin/budget_phases/phases_component.html.erb index 787508634..836ca925e 100644 --- a/app/components/admin/budget_phases/phases_component.html.erb +++ b/app/components/admin/budget_phases/phases_component.html.erb @@ -31,6 +31,7 @@ <%= render Admin::TableActionsComponent.new(phase, actions: [:edit], + edit_path: edit_path(phase), edit_text: t("admin.budgets.edit.edit_phase") ) %> diff --git a/app/components/admin/budget_phases/phases_component.rb b/app/components/admin/budget_phases/phases_component.rb index 25a2d0280..383f46c53 100644 --- a/app/components/admin/budget_phases/phases_component.rb +++ b/app/components/admin/budget_phases/phases_component.rb @@ -37,4 +37,10 @@ class Admin::BudgetPhases::PhasesComponent < ApplicationComponent tag.span t("shared.no"), class: "budget-phase-disabled" end end + + def edit_path(phase) + if helpers.respond_to?(:single_heading?) && helpers.single_heading? + edit_admin_budgets_wizard_budget_budget_phase_path(budget, phase, helpers.url_params) + end + end end diff --git a/app/controllers/admin/budgets_wizard/phases_controller.rb b/app/controllers/admin/budgets_wizard/phases_controller.rb index 785f092f9..59903c3b5 100644 --- a/app/controllers/admin/budgets_wizard/phases_controller.rb +++ b/app/controllers/admin/budgets_wizard/phases_controller.rb @@ -13,7 +13,7 @@ class Admin::BudgetsWizard::PhasesController < Admin::BudgetsWizard::BaseControl private def phases_index - admin_budgets_wizard_budget_budget_phases_path(@phase.budget) + admin_budgets_wizard_budget_budget_phases_path(@phase.budget, url_params) end def phases_params diff --git a/spec/system/admin/budgets_wizard/phases_spec.rb b/spec/system/admin/budgets_wizard/phases_spec.rb index eb2e0b50b..e1f8e7be2 100644 --- a/spec/system/admin/budgets_wizard/phases_spec.rb +++ b/spec/system/admin/budgets_wizard/phases_spec.rb @@ -82,5 +82,18 @@ describe "Budgets wizard, phases step", :admin do expect(page).to have_css ".creation-timeline" within_table("Phases") { expect(page).to have_content "Welcoming projects" } end + + scenario "update phase in single heading budget" do + visit admin_budgets_wizard_budget_budget_phases_path(budget, mode: "single") + + within("tr", text: "Selecting projects") { click_link "Edit phase" } + fill_in "Name", with: "Choosing projects" + click_button "Save changes" + + expect(page).to have_content "Changes saved" + expect(page).to have_css ".creation-timeline" + within_table("Phases") { expect(page).to have_content "Choosing projects" } + expect(page).to have_link "Go back to edit heading" + end end end diff --git a/spec/system/admin/budgets_wizard/wizard_spec.rb b/spec/system/admin/budgets_wizard/wizard_spec.rb index 0d2216ef6..2cd89198e 100644 --- a/spec/system/admin/budgets_wizard/wizard_spec.rb +++ b/spec/system/admin/budgets_wizard/wizard_spec.rb @@ -21,6 +21,26 @@ describe "Budgets creation wizard", :admin do click_button "Continue to phases" expect(page).to have_css ".budget-phases-table" + + click_button "Finish" + + expect(page).to have_content "Phases configured successfully" + + within "tr", text: "Single heading budget" do + click_link "Edit headings groups" + end + + expect(page).to have_content "There is 1 group" + + within "tr", text: "Single heading budget" do + click_link "Manage headings" + end + + expect(page).to have_content "There is 1 heading" + + within "tbody" do + expect(page).to have_content "One and only heading" + end end scenario "Creation of a multiple-headings budget by steps" do @@ -86,5 +106,43 @@ describe "Budgets creation wizard", :admin do click_link "Continue to phases" expect(page).to have_css ".budget-phases-table" + + within("tr", text: "Voting projects") { click_link "Edit phase" } + fill_in "Name", with: "Custom phase name" + uncheck "Phase enabled" + click_button "Save changes" + + expect(page).to have_content "Changes saved" + + within "table" do + expect(page).to have_content "Custom phase name" + expect(page).not_to have_content "Voting projects" + end + + click_button "Finish" + + expect(page).to have_content "Phases configured successfully" + + within "tr", text: "Multiple headings budget" do + click_link "Edit headings groups" + end + + expect(page).to have_content "There are 2 groups" + + within "tbody" do + expect(page).to have_content "All city" + expect(page).to have_content "Districts" + end + + within "tr", text: "Districts" do + click_link "Manage headings" + end + + expect(page).to have_content "There are 2 headings" + + within "tbody" do + expect(page).to have_content "North" + expect(page).to have_content "South" + end end end