Skip to content

Commit

Permalink
Merge pull request #2000 from unboxed/reporting-type
Browse files Browse the repository at this point in the history
Only validate for reporting type if present on application type
  • Loading branch information
benbaumann95 authored Oct 23, 2024
2 parents cf40ec9 + 274bef0 commit f5ce1ee
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
3 changes: 2 additions & 1 deletion app/models/planning_application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class WithdrawOrCancelError < RuntimeError; end
delegate :consultee_consultation_feature?
delegate :publicity_consultation_feature?
delegate :prior_approval?
delegate :selected_reporting_types?
end

delegate :reviewer_group_email, to: :local_authority
Expand Down Expand Up @@ -203,7 +204,7 @@ class WithdrawOrCancelError < RuntimeError; end

with_options on: :reporting_types do
validate :regulation_present, if: :regulation?
validates :reporting_type, presence: true
validates :reporting_type, presence: true, if: :selected_reporting_types?
end

def regulation_present
Expand Down
4 changes: 2 additions & 2 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1863,11 +1863,11 @@ en:
reporting_types:
form:
legislation: Legislation
no_applicable_reporting_types: No applicable reporting types
no_applicable_reporting_types: No applicable reporting types. Please configure them for the application type if they are required.
read_more: Read more guidance on GOV.UK (opens in a new tab)
update:
failure: Please select a development type for reporting
success: Planning application's development type for reporting was successfully selected
success: Planning application's reporting details were successfully updated.
sitemaps:
update:
error: Something went wrong. Please contact support.
Expand Down
22 changes: 18 additions & 4 deletions spec/system/planning_applications/validating/reporting_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
click_button "Save and mark as complete"

within(".govuk-notification-banner--notice") do
expect(page).to have_content("Planning application's development type for reporting was successfully selected")
expect(page).to have_content("Planning application's reporting details were successfully updated")
end

within("#reporting-details-task") do
Expand All @@ -64,6 +64,20 @@
expect(page).to have_content "Please select a development type for reporting"
end

context "when no reporting type for the application type exists" do
let!(:planning_application) do
create(:planning_application, :planning_permission, :not_started, local_authority: default_local_authority)
end

it "I can save and mark as complete" do
click_link "Add reporting details"
expect(page).to have_content("No applicable reporting types. Please configure them for the application type if they are required.")
click_button "Save and mark as complete"

expect(page).to have_content "Planning application's reporting details were successfully updated"
end
end

it "shows errors when Yes or No is not selected for whether the local authority is carrying out the works proposed" do
click_link "Add reporting details"
page.find(:xpath, '//*[@id="planning-application-regulation-true-field"]').click
Expand All @@ -85,7 +99,7 @@
click_button "Save and mark as complete"

within(".govuk-notification-banner--notice") do
expect(page).to have_content("Planning application's development type for reporting was successfully selected")
expect(page).to have_content("Planning application's reporting details were successfully updated")
end

within("#reporting-details-task") do
Expand All @@ -109,7 +123,7 @@
click_button "Save and mark as complete"

within(".govuk-notification-banner--notice") do
expect(page).to have_content("Planning application's development type for reporting was successfully selected")
expect(page).to have_content("Planning application's reporting details were successfully updated")
end

within("#reporting-details-task") do
Expand All @@ -134,7 +148,7 @@
click_button "Save and mark as complete"

within(".govuk-notification-banner--notice") do
expect(page).to have_content("Planning application's development type for reporting was successfully selected")
expect(page).to have_content("Planning application's reporting details were successfully updated")
end

within("#reporting-details-task") do
Expand Down

0 comments on commit f5ce1ee

Please sign in to comment.