Skip to content

Commit

Permalink
Add missing document tags and add spec to validate against schema
Browse files Browse the repository at this point in the history
  • Loading branch information
benbaumann95 committed Nov 4, 2024
1 parent 5e98d87 commit e2efe94
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion app/models/application_type_document_tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions app/models/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class NotArchiveableError < StandardError; end
sitePlan.proposed
sketchPlan
streetScene
treePlan
unitPlan.existing
unitPlan.proposed
usePlan.existing
Expand Down Expand Up @@ -98,6 +99,8 @@ class NotArchiveableError < StandardError; end
floodRiskAssessment
foulDrainageAssessment
geodiversityAssessment
hedgerowsInformation
hedgerowsInformation.plantingDate
heritageStatement
hydrologicalAssessment
hydrologyReport
Expand All @@ -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
Expand All @@ -137,6 +146,7 @@ class NotArchiveableError < StandardError; end
viabilityAppraisal
visualisations
wasteAndRecyclingStrategy
wasteStorageDetails
waterEnvironmentAssessment
].freeze

Expand Down
11 changes: 11 additions & 0 deletions config/locales/document_tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand All @@ -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'
Expand All @@ -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'
Expand All @@ -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'
Expand All @@ -101,4 +111,5 @@ en:
viabilityAppraisal: 'Viability Appraisal'
visualisations: 'Visualisations'
wasteAndRecyclingStrategy: 'Waste and recycling strategy'
wasteStorageDetails: 'Waste storage details'
waterEnvironmentAssessment: 'Water environment assessment'
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,7 @@
end

click_link "Supporting documents"

click_link "Show all (60)"
click_link "Show all (69)"

check "Sustainability statement"

Expand Down

0 comments on commit e2efe94

Please sign in to comment.