From e2efe946c0f0b225689a9745786f59292947abc0 Mon Sep 17 00:00:00 2001 From: Ben Baumann <34001723+benbaumann95@users.noreply.github.com> Date: Mon, 4 Nov 2024 13:54:05 +0000 Subject: [PATCH] Add missing document tags and add spec to validate against schema --- Makefile | 3 +++ app/models/application_type_document_tags.rb | 3 ++- app/models/document.rb | 10 ++++++++++ config/locales/document_tags.yml | 11 +++++++++++ .../spec/requests/v2/planning_applications_spec.rb | 9 +++++++++ .../replacement_document_validation_request_spec.rb | 3 +-- 6 files changed, 36 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index bbfeb0e70e..47afb30ef1 100644 --- a/Makefile +++ b/Makefile @@ -74,6 +74,9 @@ lint: lint-auto-correct: $(DOCKER-RUN) console rake rubocop:fix biome:fix erblint:fix +lint-locales: + $(DOCKER-RUN) console i18n-tasks normalize + # this regenerates the Rubocop TODO and ensures that cops aren't # turned off over a max number of file offenses. Note: we don't want # to run this within Docker so we can avoid a write-projected file (by diff --git a/app/models/application_type_document_tags.rb b/app/models/application_type_document_tags.rb index c198934115..7656a6046c 100644 --- a/app/models/application_type_document_tags.rb +++ b/app/models/application_type_document_tags.rb @@ -41,7 +41,8 @@ def irrelevant_tag_list private def translate_tag(tag) - I18n.t("document_tags.#{tag}") + translation = I18n.t("document_tags.#{tag}") + translation.is_a?(Hash) ? translation[:main] || tag : translation end def build_tag_list(tag) diff --git a/app/models/document.rb b/app/models/document.rb index 25de444b80..080b7c0a30 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -55,6 +55,7 @@ class NotArchiveableError < StandardError; end sitePlan.proposed sketchPlan streetScene + treePlan unitPlan.existing unitPlan.proposed usePlan.existing @@ -98,6 +99,8 @@ class NotArchiveableError < StandardError; end floodRiskAssessment foulDrainageAssessment geodiversityAssessment + hedgerowsInformation + hedgerowsInformation.plantingDate heritageStatement hydrologicalAssessment hydrologyReport @@ -111,19 +114,25 @@ class NotArchiveableError < StandardError; end landscapeStrategy lightingAssessment litterVerminAndBirdControlDetails + methodStatement mineralsAndWasteAssessment + necessaryInformation newDwellingsSchedule noiseAssessment openSpaceAssessment otherDocument parkingPlan planningStatement + recycleWasteStorageDetails + relevantInformation + residentialUnitsDetails statementOfCommunityInvolvement storageTreatmentAndWasteDisposalDetails subsidenceReport sunlightAndDaylightReport sustainabilityStatement technicalEvidence + technicalSpecification townCentreImpactAssessment townCentreSequentialAssessment transportAssessment @@ -137,6 +146,7 @@ class NotArchiveableError < StandardError; end viabilityAppraisal visualisations wasteAndRecyclingStrategy + wasteStorageDetails waterEnvironmentAssessment ].freeze diff --git a/config/locales/document_tags.yml b/config/locales/document_tags.yml index 4d9232128c..ba058e1e2d 100644 --- a/config/locales/document_tags.yml +++ b/config/locales/document_tags.yml @@ -35,6 +35,9 @@ en: proposed: 'Floor plan - proposed' foulDrainageAssessment: 'Foul drainage assessment' geodiversityAssessment: 'Geodiversity assessment' + hedgerowsInformation: + main: 'Hedgerows information' + plantingDate: 'Hedgerows information planting date' heritageStatement: 'Heritage Statement' hydrologicalAssessment: 'Hydrological and hydrogeological assessment' hydrologyReport: 'Hydrology report' @@ -48,7 +51,9 @@ en: lightingAssessment: 'Lighting assessment' litterVerminAndBirdControlDetails: 'Details of litter vermin and bird control' locationPlan: 'Location plan' + methodStatement: 'Method statement' mineralsAndWasteAssessment: 'Minerals and waste assessment' + necessaryInformation: 'Necessary information' newDwellingsSchedule: 'New dwellings schedule' noiseAssessment: 'Noise assessment' openSpaceAssessment: 'Open space assessment' @@ -60,6 +65,9 @@ en: existing: 'Photographs - existing' proposed: 'Photographs - proposed' planningStatement: 'Planning statement' + recycleWasteStorageDetails: 'Recycle waste storage details' + relevantInformation: 'Relevent information' + residentialUnitsDetails: 'Resedential unit details' roofPlan: existing: 'Roof plan - existing' proposed: 'Roof plan - proposed' @@ -78,6 +86,7 @@ en: sunlightAndDaylightReport: 'Sunlight and daylight report' sustainabilityStatement: 'Sustainability statement' technicalEvidence: 'Technical evidence' + technicalSpecification: 'Technical specification' tenancyAgreement: 'Tenancy agreement' tenancyInvoice: 'Tenancy invoice' townCentreImpactAssessment: 'Town centre uses - Impact assessment' @@ -88,6 +97,7 @@ en: treeAndHedgeRemovedOrPruned: 'Removed or pruned trees and hedges' treeCanopyCalculator: 'Tree canopy calculator' treeConditionReport: 'Tree condition report' + treePlan: 'Tree plan' treesReport: 'Trees report' unitPlan: existing: 'Unit plan - existing' @@ -101,4 +111,5 @@ en: viabilityAppraisal: 'Viability Appraisal' visualisations: 'Visualisations' wasteAndRecyclingStrategy: 'Waste and recycling strategy' + wasteStorageDetails: 'Waste storage details' waterEnvironmentAssessment: 'Water environment assessment' diff --git a/engines/bops_api/spec/requests/v2/planning_applications_spec.rb b/engines/bops_api/spec/requests/v2/planning_applications_spec.rb index 518d2cadb1..bc04423fa5 100644 --- a/engines/bops_api/spec/requests/v2/planning_applications_spec.rb +++ b/engines/bops_api/spec/requests/v2/planning_applications_spec.rb @@ -231,6 +231,15 @@ run_test! end + + it "validates document tags against the submission schema" do + schema = BopsApi::Schemas.find!("submission", version: BopsApi::Schemas::DEFAULT_ODP_VERSION).value + + schema_tags = schema["definitions"]["FileType"]["anyOf"].map { |entry| entry["properties"]["value"]["const"] } + missing_tags = schema_tags - Document::TAGS + + expect(missing_tags).to be_empty, "Missing tags in schema for: #{missing_tags.join(", ")}" + end end end diff --git a/spec/system/planning_applications/replacement_document_validation_request_spec.rb b/spec/system/planning_applications/replacement_document_validation_request_spec.rb index 2cf2c6290e..da1bebf8d3 100644 --- a/spec/system/planning_applications/replacement_document_validation_request_spec.rb +++ b/spec/system/planning_applications/replacement_document_validation_request_spec.rb @@ -207,8 +207,7 @@ end click_link "Supporting documents" - - click_link "Show all (60)" + click_link "Show all (69)" check "Sustainability statement"