From dc6201e318725f6420ff416e7c8260c165124879 Mon Sep 17 00:00:00 2001 From: Ben Baumann <34001723+benbaumann95@users.noreply.github.com> Date: Fri, 13 Dec 2024 12:04:52 +0000 Subject: [PATCH] Toggle features for application type - EIA, CIL and legislative requirements - Default these to true --- .../review/cil_liability_controller.rb | 10 ++++++++ .../validation/cil_liability_controller.rb | 10 ++++++++ ...vironment_impact_assessments_controller.rb | 9 +++++++ .../validation/legislation_controller.rb | 9 +++++++ app/models/application_type.rb | 3 +++ app/models/application_type_feature.rb | 3 +++ .../review/tasks/_review_assessment.html.erb | 25 +++++++++++-------- .../tasks/_application_requirements.html.erb | 8 ++++-- .../application_types/features_controller.rb | 3 +++ .../bops_config/application_type_helper.rb | 14 +++++++++++ .../application_types/features/edit.html.erb | 9 +++---- .../application_types/show.html.erb | 21 +++------------- .../locales/application_type_features.yml | 3 +++ .../spec/system/application_types_spec.rb | 12 +++++++++ spec/factories/application_type.rb | 8 ++++++ .../review/check_cil_liability_spec.rb | 13 ++++++++++ .../validating/check_legislation_spec.rb | 21 ++++++++++++++++ .../validating/cil_liability_spec.rb | 16 ++++++++++++ .../environment_impact_assessment_spec.rb | 16 ++++++++++++ 19 files changed, 177 insertions(+), 36 deletions(-) diff --git a/app/controllers/planning_applications/review/cil_liability_controller.rb b/app/controllers/planning_applications/review/cil_liability_controller.rb index 5265f30a73..a2eb2ef9de 100644 --- a/app/controllers/planning_applications/review/cil_liability_controller.rb +++ b/app/controllers/planning_applications/review/cil_liability_controller.rb @@ -3,6 +3,8 @@ module PlanningApplications module Review class CilLiabilityController < BaseController + before_action :redirect_to_review_tasks, unless: :cil_feature? + def update @previous_decision = @planning_application.cil_liable if @planning_application.update(cil_liability_params) @@ -44,6 +46,14 @@ def activity_information "Reviewer marked application as#{" not" unless @planning_application.cil_liable} liable for CIL" end end + + def redirect_to_review_tasks + redirect_to planning_application_review_tasks_path(@planning_application) + end + + def cil_feature? + @planning_application.application_type.cil? + end end end end diff --git a/app/controllers/planning_applications/validation/cil_liability_controller.rb b/app/controllers/planning_applications/validation/cil_liability_controller.rb index 9ec0c51588..7a1b305608 100644 --- a/app/controllers/planning_applications/validation/cil_liability_controller.rb +++ b/app/controllers/planning_applications/validation/cil_liability_controller.rb @@ -3,6 +3,8 @@ module PlanningApplications module Validation class CilLiabilityController < BaseController + before_action :redirect_to_validation_tasks, unless: :cil_feature? + def edit respond_to do |format| format.html @@ -22,6 +24,14 @@ def update def cil_liability_params params.require(:planning_application).permit([:cil_liable]) end + + def redirect_to_validation_tasks + redirect_to planning_application_validation_tasks_path(@planning_application) + end + + def cil_feature? + @planning_application.application_type.cil? + end end end end diff --git a/app/controllers/planning_applications/validation/environment_impact_assessments_controller.rb b/app/controllers/planning_applications/validation/environment_impact_assessments_controller.rb index 324b929bd3..9ccb3343ff 100644 --- a/app/controllers/planning_applications/validation/environment_impact_assessments_controller.rb +++ b/app/controllers/planning_applications/validation/environment_impact_assessments_controller.rb @@ -3,6 +3,7 @@ module PlanningApplications module Validation class EnvironmentImpactAssessmentsController < BaseController + before_action :redirect_to_validation_tasks, unless: :eia_feature? before_action :set_environment_impact_assessment, only: %i[show update edit] def edit @@ -58,6 +59,14 @@ def environmental_impact_assessment_params def set_environment_impact_assessment @environment_impact_assessment = @planning_application.environment_impact_assessment end + + def redirect_to_validation_tasks + redirect_to planning_application_validation_tasks_path(@planning_application) + end + + def eia_feature? + @planning_application.application_type.eia? + end end end end diff --git a/app/controllers/planning_applications/validation/legislation_controller.rb b/app/controllers/planning_applications/validation/legislation_controller.rb index 8513c7af2f..889e325575 100644 --- a/app/controllers/planning_applications/validation/legislation_controller.rb +++ b/app/controllers/planning_applications/validation/legislation_controller.rb @@ -3,6 +3,7 @@ module PlanningApplications module Validation class LegislationController < BaseController + before_action :redirect_to_validation_tasks, unless: :legislative_requirements_feature? before_action :ensure_legislation_is_defined def show @@ -41,6 +42,14 @@ def ensure_legislation_is_defined def redirect_failed_update redirect_to planning_application_validation_tasks_path(@planning_application), alert: t(".alert") end + + def redirect_to_validation_tasks + redirect_to planning_application_validation_tasks_path(@planning_application) + end + + def legislative_requirements_feature? + @planning_application.application_type.legislative_requirements? + end end end end diff --git a/app/models/application_type.rb b/app/models/application_type.rb index 2e379aa8ae..6c0a9bbb77 100644 --- a/app/models/application_type.rb +++ b/app/models/application_type.rb @@ -86,8 +86,11 @@ class ApplicationType < ApplicationRecord with_options to: :features do delegate :appeals? delegate :assess_against_policies? + delegate :cil? delegate :considerations? + delegate :eia? delegate :informatives? + delegate :legislative_requirements? delegate :ownership_details? delegate :planning_conditions? delegate :permitted_development_rights? diff --git a/app/models/application_type_feature.rb b/app/models/application_type_feature.rb index 47d89cffa3..a1ee30b4e9 100644 --- a/app/models/application_type_feature.rb +++ b/app/models/application_type_feature.rb @@ -5,8 +5,11 @@ class ApplicationTypeFeature attribute :appeals, :boolean, default: true attribute :assess_against_policies, :boolean, default: false + attribute :cil, :boolean, default: true attribute :considerations, :boolean, default: false + attribute :eia, :boolean, default: true attribute :informatives, :boolean, default: false + attribute :legislative_requirements, :boolean, default: true attribute :ownership_details, :boolean, default: true attribute :planning_conditions, :boolean, default: false attribute :permitted_development_rights, :boolean, default: true diff --git a/app/views/planning_applications/review/tasks/_review_assessment.html.erb b/app/views/planning_applications/review/tasks/_review_assessment.html.erb index da31eeffbc..74339817f0 100644 --- a/app/views/planning_applications/review/tasks/_review_assessment.html.erb +++ b/app/views/planning_applications/review/tasks/_review_assessment.html.erb @@ -1,16 +1,19 @@ <%= bops_task_accordion(id: "review-assessment") do |accordion| %> <% accordion.with_heading(text: "Review assessment") %> - <% accordion.with_section(id: "check-cil", expanded: false) do |section| %> - <%= section.with_heading(text: "Check Community Infrastructure Levy (CIL)") %> - <%= section.with_status do %> - <%= render( - StatusTags::BaseComponent.new( - status: (@planning_application.audits.review_cil_liability.any? ? :complete : :not_started) - ) - ) %> - <% end %> - <%= section.with_footer do %> - <%= render(partial: "planning_applications/review/cil_liability/form") %> + + <% if @planning_application.application_type.cil? %> + <% accordion.with_section(id: "check-cil", expanded: false) do |section| %> + <%= section.with_heading(text: "Check Community Infrastructure Levy (CIL)") %> + <%= section.with_status do %> + <%= render( + StatusTags::BaseComponent.new( + status: (@planning_application.audits.review_cil_liability.any? ? :complete : :not_started) + ) + ) %> + <% end %> + <%= section.with_footer do %> + <%= render(partial: "planning_applications/review/cil_liability/form") %> + <% end %> <% end %> <% end %> diff --git a/app/views/planning_applications/validation/tasks/_application_requirements.html.erb b/app/views/planning_applications/validation/tasks/_application_requirements.html.erb index 9d674eabe5..5528265f8c 100644 --- a/app/views/planning_applications/validation/tasks/_application_requirements.html.erb +++ b/app/views/planning_applications/validation/tasks/_application_requirements.html.erb @@ -5,9 +5,13 @@ <%= govuk_task_list(id_prefix: "application-requirements-tasks", html_attributes: {id: "application-requirements-tasks"}) do |task_list| render Validation::FeeValidationTask.new(@planning_application, task_list:) - render Validation::CilLiabilityTask.new(@planning_application, task_list:) + if @planning_application.application_type.cil? + render Validation::CilLiabilityTask.new(@planning_application, task_list:) + end - render Validation::EnvironmentalImpactAssessmentTask.new(@planning_application, task_list:) + if @planning_application.application_type.eia? + render Validation::EnvironmentalImpactAssessmentTask.new(@planning_application, task_list:) + end if @planning_application.application_type.ownership_details? render Validation::OwnershipCertificateTask.new(@planning_application, task_list:) diff --git a/engines/bops_config/app/controllers/bops_config/application_types/features_controller.rb b/engines/bops_config/app/controllers/bops_config/application_types/features_controller.rb index 9125c20706..9cf795fbe8 100644 --- a/engines/bops_config/app/controllers/bops_config/application_types/features_controller.rb +++ b/engines/bops_config/app/controllers/bops_config/application_types/features_controller.rb @@ -33,8 +33,11 @@ def features_attributes [ :appeals, :assess_against_policies, + :cil, :considerations, + :eia, :informatives, + :legislative_requirements, :ownership_details, :planning_conditions, :permitted_development_rights, diff --git a/engines/bops_config/app/helpers/bops_config/application_type_helper.rb b/engines/bops_config/app/helpers/bops_config/application_type_helper.rb index eb6fadeecb..a414b62dac 100644 --- a/engines/bops_config/app/helpers/bops_config/application_type_helper.rb +++ b/engines/bops_config/app/helpers/bops_config/application_type_helper.rb @@ -11,5 +11,19 @@ module ApplicationTypeHelper def tag_colour(tag) COLOURS[tag.to_sym] end + + def application_details_features + %i[ + assess_against_policies + considerations + cil + eia + informatives + legislative_requirements + ownership_details + planning_conditions + permitted_development_rights + ] + end end end diff --git a/engines/bops_config/app/views/bops_config/application_types/features/edit.html.erb b/engines/bops_config/app/views/bops_config/application_types/features/edit.html.erb index b246a80970..7651070516 100644 --- a/engines/bops_config/app/views/bops_config/application_types/features/edit.html.erb +++ b/engines/bops_config/app/views/bops_config/application_types/features/edit.html.erb @@ -21,12 +21,9 @@ <%= form.fields_for :features, @application_type.features do |ff| %> <%= ff.govuk_fieldset legend: {text: t("application_type_features.legends.check_application_details"), size: "s"} do %> - <%= ff.govuk_check_box :assess_against_policies, 1, 0, multiple: false, label: {text: t("application_type_features.labels.assess_against_policies")} %> - <%= ff.govuk_check_box :considerations, 1, 0, multiple: false, label: {text: t("application_type_features.labels.considerations")} %> - <%= ff.govuk_check_box :informatives, 1, 0, multiple: false, label: {text: t("application_type_features.labels.informatives")} %> - <%= ff.govuk_check_box :ownership_details, 1, 0, multiple: false, label: {text: t("application_type_features.labels.ownership_details")} %> - <%= ff.govuk_check_box :planning_conditions, 1, 0, multiple: false, label: {text: t("application_type_features.labels.planning_conditions")} %> - <%= ff.govuk_check_box :permitted_development_rights, 1, 0, multiple: false, label: {text: t("application_type_features.labels.permitted_development_rights")} %> + <% application_details_features.each do |field| %> + <%= ff.govuk_check_box field, 1, 0, multiple: false, label: {text: t("application_type_features.labels.#{field}")} %> + <% end %> <% end %>
diff --git a/engines/bops_config/app/views/bops_config/application_types/show.html.erb b/engines/bops_config/app/views/bops_config/application_types/show.html.erb index dd53c2ac91..b75b1561a1 100644 --- a/engines/bops_config/app/views/bops_config/application_types/show.html.erb +++ b/engines/bops_config/app/views/bops_config/application_types/show.html.erb @@ -59,23 +59,10 @@ row.with_value { %>

Application details

diff --git a/engines/bops_config/config/locales/application_type_features.yml b/engines/bops_config/config/locales/application_type_features.yml index aec1c1bdd4..94a6aa4fc4 100644 --- a/engines/bops_config/config/locales/application_type_features.yml +++ b/engines/bops_config/config/locales/application_type_features.yml @@ -3,9 +3,12 @@ en: labels: appeals: "Enable appeals" assess_against_policies: "Assess against legislation" + cil: "Community Infrastructure Levy" considerations: "Assess policies and guidance (considerations)" consultations_skip_bank_holidays: "Extend consultation periods that contain bank holidays" + eia: "Environmental Impact Assessment" informatives: "Add informatives" + legislative_requirements: "Check legislative requirments" ownership_details: "Ownership details" planning_conditions: "Check planning conditions" permitted_development_rights: "Check permitted development rights" diff --git a/engines/bops_config/spec/system/application_types_spec.rb b/engines/bops_config/spec/system/application_types_spec.rb index 28518712b4..d3e9cd31e8 100644 --- a/engines/bops_config/spec/system/application_types_spec.rb +++ b/engines/bops_config/spec/system/application_types_spec.rb @@ -526,6 +526,9 @@ expect(page).to have_selector("li", text: "Add informatives") expect(page).to have_selector("li", text: "Ownership details") expect(page).to have_selector("li", text: "Check planning conditions") + expect(page).to have_selector("li", text: "Environmental Impact Assessment") + expect(page).to have_selector("li", text: "Community Infrastructure Levy") + expect(page).to have_selector("li", text: "Check legislative requirments") expect(page).not_to have_selector("li", text: "Check permitted development rights") expect(page).not_to have_selector("li", text: "Enable appeals") @@ -555,6 +558,9 @@ uncheck("Ownership details") uncheck("Check planning conditions") + uncheck("Environmental Impact Assessment") + uncheck("Community Infrastructure Levy") + uncheck("Check legislative requirments") check("Check permitted development rights") check("Consultees") check("Enable appeals") @@ -569,6 +575,9 @@ expect(page).to have_selector("li", text: "Add informatives") expect(page).not_to have_selector("li", text: "Ownership details") expect(page).not_to have_selector("li", text: "Check planning conditions") + expect(page).not_to have_selector("li", text: "Environmental Impact Assessment") + expect(page).not_to have_selector("li", text: "Community Infrastructure Levy") + expect(page).not_to have_selector("li", text: "Check legislative requirments") expect(page).to have_selector("li", text: "Check permitted development rights") expect(page).to have_selector("li", text: "Enable appeals") @@ -582,6 +591,9 @@ expect(application_type.informatives?).to eq(true) expect(application_type.ownership_details?).to eq(false) expect(application_type.planning_conditions?).to eq(false) + expect(application_type.eia?).to eq(false) + expect(application_type.cil?).to eq(false) + expect(application_type.legislative_requirements?).to eq(false) expect(application_type.permitted_development_rights?).to eq(true) expect(application_type.consultation_steps).to eq(["neighbour", "consultee", "publicity"]) expect(application_type.appeals?).to eq(true) diff --git a/spec/factories/application_type.rb b/spec/factories/application_type.rb index 187da755c0..9763b62a91 100644 --- a/spec/factories/application_type.rb +++ b/spec/factories/application_type.rb @@ -558,6 +558,14 @@ trait :pre_application do code { "preApp" } suffix { "PRE" } + + features { + { + "cil" => false, + "eia" => false, + "legislative_requirements" => false + } + } end trait :without_consultation do diff --git a/spec/system/planning_applications/review/check_cil_liability_spec.rb b/spec/system/planning_applications/review/check_cil_liability_spec.rb index 0679b36364..79c66f13ba 100644 --- a/spec/system/planning_applications/review/check_cil_liability_spec.rb +++ b/spec/system/planning_applications/review/check_cil_liability_spec.rb @@ -146,4 +146,17 @@ expect(page).to have_content "Reviewer marked application as not liable for CIL" end end + + context "when CIL liability feature is disabled" do + let!(:planning_application) do + create(:planning_application, :awaiting_determination, :pre_application, local_authority: local_authority) + end + + it "does not have a section to review CIL" do + visit "planning_applications/#{planning_application.reference}/review/tasks" + + expect(page).not_to have_css("#check-cil") + expect(page).not_to have_content("Check Community Infrastructure Levy (CIL)") + end + end end diff --git a/spec/system/planning_applications/validating/check_legislation_spec.rb b/spec/system/planning_applications/validating/check_legislation_spec.rb index 3f1009bfe4..2824bb11a2 100644 --- a/spec/system/planning_applications/validating/check_legislation_spec.rb +++ b/spec/system/planning_applications/validating/check_legislation_spec.rb @@ -101,4 +101,25 @@ expect(page).to have_content("Not found") end end + + context "when legislative requirements feature is disabled" do + let!(:planning_application) do + create(:planning_application, :not_started, :pre_application, local_authority: default_local_authority) + end + + before do + sign_in assessor + visit "/planning_applications/#{planning_application.reference}/validation/tasks" + end + + it "does not have a section to check legislative requirements" do + visit "planning_applications/#{planning_application.reference}/validation/tasks" + + expect(page).not_to have_content("Check legislative requirements") + + visit "planning_applications/#{planning_application.reference}/validation/legislation" + + expect(page).to have_current_path("/planning_applications/#{planning_application.reference}/validation/tasks") + end + end end diff --git a/spec/system/planning_applications/validating/cil_liability_spec.rb b/spec/system/planning_applications/validating/cil_liability_spec.rb index c2d4770c90..33a7dfa676 100644 --- a/spec/system/planning_applications/validating/cil_liability_spec.rb +++ b/spec/system/planning_applications/validating/cil_liability_spec.rb @@ -141,4 +141,20 @@ end end end + + context "when CIL liability feature is disabled" do + let!(:planning_application) do + create(:planning_application, :not_started, :pre_application, local_authority: default_local_authority) + end + + it "does not have a section to check CIL" do + visit "planning_applications/#{planning_application.reference}/validation/tasks" + + expect(page).not_to have_content("Check Community Infrastructure Levy (CIL)") + + visit "planning_applications/#{planning_application.reference}/validation/cil_liability/edit" + + expect(page).to have_current_path("/planning_applications/#{planning_application.reference}/validation/tasks") + end + end end diff --git a/spec/system/planning_applications/validating/environment_impact_assessment_spec.rb b/spec/system/planning_applications/validating/environment_impact_assessment_spec.rb index e67853499f..c737d9ccfe 100644 --- a/spec/system/planning_applications/validating/environment_impact_assessment_spec.rb +++ b/spec/system/planning_applications/validating/environment_impact_assessment_spec.rb @@ -194,4 +194,20 @@ end end end + + context "when EIA feature is disabled" do + let!(:planning_application) do + create(:planning_application, :not_started, :pre_application, local_authority: default_local_authority) + end + + it "does not have a section to check EIA" do + visit "planning_applications/#{planning_application.reference}/validation/tasks" + + expect(page).not_to have_content("Check Environment Impact Assessment") + + visit "planning_applications/#{planning_application.reference}/validation/environment_impact_assessment" + + expect(page).to have_current_path("/planning_applications/#{planning_application.reference}/validation/tasks") + end + end end