@@ -53,7 +53,8 @@ class Inspection < ApplicationRecord
5353
5454 enum :inspection_type , {
5555 bouncy_castle : "BOUNCY_CASTLE" ,
56- bouncing_pillow : "BOUNCING_PILLOW"
56+ bouncing_pillow : "BOUNCING_PILLOW" ,
57+ pat_testable : "PAT_TESTABLE"
5758 }
5859
5960 CASTLE_ASSESSMENT_TYPES = {
@@ -70,8 +71,14 @@ class Inspection < ApplicationRecord
7071 fan_assessment : Assessments ::FanAssessment
7172 } . freeze
7273
74+ PAT_TESTABLE_ASSESSMENT_TYPES = {
75+ pat_assessment : Assessments ::PatAssessment
76+ } . freeze
77+
7378 ALL_ASSESSMENT_TYPES =
74- CASTLE_ASSESSMENT_TYPES . merge ( PILLOW_ASSESSMENT_TYPES ) . freeze
79+ CASTLE_ASSESSMENT_TYPES
80+ . merge ( PILLOW_ASSESSMENT_TYPES )
81+ . merge ( PAT_TESTABLE_ASSESSMENT_TYPES ) . freeze
7582
7683 USER_EDITABLE_PARAMS = %i[
7784 has_slide
@@ -218,15 +225,19 @@ def complete?
218225
219226 sig { returns ( T ::Hash [ Symbol , T . class_of ( ApplicationRecord ) ] ) }
220227 def assessment_types
221- bouncing_pillow? ? PILLOW_ASSESSMENT_TYPES : CASTLE_ASSESSMENT_TYPES
228+ case
229+ when pat_testable? then PAT_TESTABLE_ASSESSMENT_TYPES
230+ when bouncing_pillow? then PILLOW_ASSESSMENT_TYPES
231+ else CASTLE_ASSESSMENT_TYPES
232+ end
222233 end
223234
224235 sig { returns ( T ::Hash [ Symbol , T . class_of ( ApplicationRecord ) ] ) }
225236 def applicable_assessments
226- if bouncing_pillow?
227- pillow_applicable_assessments
228- else
229- castle_applicable_assessments
237+ case
238+ when pat_testable? then pat_testable_applicable_assessments
239+ when bouncing_pillow? then pillow_applicable_assessments
240+ else castle_applicable_assessments
230241 end
231242 end
232243
@@ -253,6 +264,11 @@ def pillow_applicable_assessments
253264 PILLOW_ASSESSMENT_TYPES
254265 end
255266
267+ sig { returns ( T ::Hash [ Symbol , T . class_of ( ApplicationRecord ) ] ) }
268+ def pat_testable_applicable_assessments
269+ PAT_TESTABLE_ASSESSMENT_TYPES
270+ end
271+
256272 public
257273
258274 # Iterate over only applicable assessments with a block
@@ -279,7 +295,7 @@ def applicable_tabs
279295 applicable = applicable_assessments . keys . map { |k | k . to_s . chomp ( "_assessment" ) }
280296
281297 # Add tabs in the correct UI order
282- ordered_tabs = %w[ user_height slide structure anchorage materials fan enclosed ]
298+ ordered_tabs = %w[ user_height slide structure anchorage materials fan enclosed pat ]
283299 ordered_tabs . each do |tab |
284300 tabs << tab if applicable . include? ( tab )
285301 end
@@ -293,10 +309,14 @@ def applicable_tabs
293309 # Advanced methods
294310 sig { returns ( T ::Boolean ) }
295311 def can_be_completed?
296- unit . present? &&
312+ base_requirements_met = unit . present? &&
297313 all_assessments_complete? &&
298314 !passed . nil? &&
299- inspection_date . present? &&
315+ inspection_date . present?
316+
317+ return base_requirements_met if pat_testable?
318+
319+ base_requirements_met &&
300320 width . present? &&
301321 length . present? &&
302322 height . present? &&
@@ -396,8 +416,12 @@ def field_label(form, field)
396416
397417 sig { returns ( T ::Array [ Symbol ] ) }
398418 def inspection_tab_incomplete_fields
399- # Fields required for the inspection tab specifically (excludes passed which is on results tab)
419+ # Excludes passed which is on results tab
400420 fields = REQUIRED_TO_COMPLETE_FIELDS - [ :passed ]
421+
422+ # PAT testable only needs inspection_date
423+ fields = fields & [ :inspection_date ] if pat_testable?
424+
401425 fields
402426 . reject { |f | f . end_with? ( "_comment" ) }
403427 . select { |f | send ( f ) . nil? }
@@ -526,6 +550,7 @@ def assessment_validation_data
526550 enclosed
527551 fan
528552 materials
553+ pat
529554 slide
530555 structure
531556 user_height
0 commit comments