Skip to content

Commit

Permalink
Merge pull request #2129 from unboxed/optional-validation-requests
Browse files Browse the repository at this point in the history
Skip description change approval for specific application types
  • Loading branch information
benjamineskola authored Jan 24, 2025
2 parents 8435a62 + 1749ca0 commit 195b852
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 10 deletions.
7 changes: 4 additions & 3 deletions app/models/application_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,16 @@ class ApplicationType < ApplicationRecord
delegate :assess_against_policies?
delegate :cil?
delegate :considerations?
delegate :consultation_steps
delegate :consultations_skip_bank_holidays?
delegate :description_change_requires_validation?
delegate :eia?
delegate :informatives?
delegate :legislative_requirements?
delegate :ownership_details?
delegate :planning_conditions?
delegate :permitted_development_rights?
delegate :planning_conditions?
delegate :site_visits?
delegate :consultations_skip_bank_holidays?
delegate :consultation_steps
end

with_options to: :legislation, prefix: true, allow_nil: true do
Expand Down
7 changes: 4 additions & 3 deletions app/models/application_type_feature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ class ApplicationTypeFeature
attribute :assess_against_policies, :boolean, default: false
attribute :cil, :boolean, default: true
attribute :considerations, :boolean, default: false
attribute :consultation_steps, :list, default: -> { [] }
attribute :consultations_skip_bank_holidays, :boolean, default: false
attribute :description_change_requires_validation, :boolean, default: true
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
attribute :planning_conditions, :boolean, default: false
attribute :site_visits, :boolean, default: true
attribute :consultations_skip_bank_holidays, :boolean, default: false
attribute :consultation_steps, :list, default: -> { [] }

validate :consultation_steps_are_valid

Expand Down
8 changes: 7 additions & 1 deletion app/models/description_change_validation_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class DescriptionChangeValidationRequest < ValidationRequest
validate :rejected_reason_is_present?

before_create :set_previous_application_description
after_save :preapplication_auto_close, if: -> { open? && !planning_application.application_type.description_change_requires_validation? }

def response_due
RESPONSE_TIME_IN_DAYS.business_days.after(created_at).to_date
Expand All @@ -25,7 +26,7 @@ def create_audit!
end

def email_and_timestamp
send_description_request_email
send_description_request_email if planning_application.application_type.description_change_requires_validation?

mark_as_sent!
end
Expand Down Expand Up @@ -75,4 +76,9 @@ def audit_api_comment
def update_planning_application_for_auto_closed_request!
planning_application.update!(description: proposed_description)
end

def preapplication_auto_close
auto_close_request!
planning_application.update!(valid_description: true)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@
<h2 class="govuk-heading-m govuk-!-margin-top-3">
Suggest a new description to the applicant
</h2>
<p class="govuk-body">
This will be sent to the applicant immediately. If the applicant does not respond within 5 days, the amended description will be automatically accepted.
</p>

<% if @planning_application.application_type.description_change_requires_validation? %>
<p class="govuk-body">
This will be sent to the applicant immediately. If the applicant does not respond within 5 days, the amended description will be automatically accepted.
</p>
<% end %>

<div class="govuk-inset-text">
<h3 class="govuk-heading-s">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def application_details_features
eia
ownership_details
site_visits
description_change_requires_validation
]
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ en:
cil: "Community Infrastructure Levy"
considerations: "Assess policies and guidance (considerations)"
consultations_skip_bank_holidays: "Extend consultation periods that contain bank holidays"
description_change_requires_validation: "Require applicants to approve changes to descriptions"
eia: "Environmental Impact Assessment"
informatives: "Add informatives"
legislative_requirements: "Check legislative requirments"
Expand Down
1 change: 1 addition & 0 deletions spec/factories/application_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,7 @@
features {
{
"cil" => false,
"description_change_requires_validation" => false,
"eia" => false,
"legislative_requirements" => false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,57 @@
end
end
end

context "when the application is a pre-application" do
let(:planning_application) do
create(
:planning_application, :not_started, :pre_application, local_authority: default_local_authority
)
end

it "I can request a change and it will be automatically accepted immediately" do
visit "/planning_applications/#{planning_application.reference}/validation/tasks"
click_link "Check description"

within(".govuk-fieldset") do
within(".govuk-radios") { choose "No" }
end

click_button "Save and mark as complete"

expect(page).to have_current_path(
"/planning_applications/#{planning_application.reference}/validation/validation_requests/new?type=description_change"
)
expect(page).to have_content("Description change")
expect(page).to have_content("Application number: #{planning_application.reference}")

fill_in(
"Enter an amended description to send to the applicant",
with: "My better description"
)

click_button "Send request"

expect(page).to have_content("Description change request successfully sent.")

within("#check-description-task") do
expect(page).to have_content("Completed")
end

expect(planning_application.reload.valid_description).to be true
expect(DescriptionChangeValidationRequest.all.length).to eq(1)
expect(DescriptionChangeValidationRequest.closed.length).to eq(1)

click_link "Check description"

expect(page).to have_current_path(
"/planning_applications/#{planning_application.reference}/validation/description_changes"
)

expect(page).to have_content("My better description")

click_link "Back"
expect(page).to have_current_path("/planning_applications/#{planning_application.reference}/validation/tasks")
end
end
end

0 comments on commit 195b852

Please sign in to comment.