Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toggle features for application type #2076

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
3 changes: 3 additions & 0 deletions app/models/application_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
3 changes: 3 additions & 0 deletions app/models/application_type_feature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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 %>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ def features_attributes
[
:appeals,
:assess_against_policies,
:cil,
:considerations,
:eia,
:informatives,
:legislative_requirements,
:ownership_details,
:planning_conditions,
:permitted_development_rights,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>

<hr class="govuk-section-break govuk-section-break--m govuk-section-break--visible">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,10 @@
row.with_value { %>
<p class="govuk-body"><strong>Application details</strong></p>
<ul class="govuk-list govuk-list--bullet">
<% if @application_type.assess_against_policies? %>
<li><%= t("application_type_features.labels.assess_against_policies") %></li>
<% end %>
<% if @application_type.informatives? %>
<li><%= t("application_type_features.labels.informatives") %></li>
<% end %>
<% if @application_type.considerations? %>
<li><%= t("application_type_features.labels.considerations") %></li>
<% end %>
<% if @application_type.ownership_details? %>
<li><%= t("application_type_features.labels.ownership_details") %></li>
<% end %>
<% if @application_type.permitted_development_rights? %>
<li><%= t("application_type_features.labels.permitted_development_rights") %></li>
<% end %>
<% if @application_type.planning_conditions? %>
<li><%= t("application_type_features.labels.planning_conditions") %></li>
<% application_details_features.each do |field| %>
<% if @application_type.public_send("#{field}?") %>
<li><%= t("application_type_features.labels.#{field}") %></li>
<% end %>
<% end %>
</ul>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 12 additions & 0 deletions engines/bops_config/spec/system/application_types_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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")
Expand All @@ -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")

Expand All @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions spec/factories/application_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 16 additions & 0 deletions spec/system/planning_applications/validating/cil_liability_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading