diff --git a/app/lib/assessment_factory.rb b/app/lib/assessment_factory.rb index 57bdd364e..b353ea38a 100644 --- a/app/lib/assessment_factory.rb +++ b/app/lib/assessment_factory.rb @@ -56,11 +56,16 @@ def personal_information_section FailureReasons::DUPLICATE_APPLICATION, FailureReasons::APPLICANT_ALREADY_QTS, FailureReasons::APPLICANT_ALREADY_DQT, - FailureReasons::SUITABILITY, - FailureReasons::SUITABILITY_PREVIOUSLY_DECLINED, - FailureReasons::FRAUD, ].compact + if suitability_active? + failure_reasons += [ + FailureReasons::SUITABILITY, + FailureReasons::SUITABILITY_PREVIOUSLY_DECLINED, + FailureReasons::FRAUD, + ] + end + AssessmentSection.new( key: "personal_information", checks:, @@ -124,12 +129,17 @@ def qualifications_section FailureReasons::DEGREE_TRANSCRIPT_ILLEGIBLE, FailureReasons::ADDITIONAL_DEGREE_CERTIFICATE_ILLEGIBLE, FailureReasons::ADDITIONAL_DEGREE_TRANSCRIPT_ILLEGIBLE, - FailureReasons::SUITABILITY, - FailureReasons::SUITABILITY_PREVIOUSLY_DECLINED, FailureReasons::SPECIAL_EDUCATION_ONLY, - FailureReasons::FRAUD, ].compact + if suitability_active? + failure_reasons += [ + FailureReasons::SUITABILITY, + FailureReasons::SUITABILITY_PREVIOUSLY_DECLINED, + FailureReasons::FRAUD, + ] + end + AssessmentSection.new(key: "qualifications", checks:, failure_reasons:) end @@ -152,11 +162,16 @@ def age_range_subjects_section failure_reasons = [ FailureReasons::NOT_QUALIFIED_TO_TEACH_MAINSTREAM, FailureReasons::AGE_RANGE, - FailureReasons::SUITABILITY, - FailureReasons::SUITABILITY_PREVIOUSLY_DECLINED, - FailureReasons::FRAUD, ] + if suitability_active? + failure_reasons += [ + FailureReasons::SUITABILITY, + FailureReasons::SUITABILITY_PREVIOUSLY_DECLINED, + FailureReasons::FRAUD, + ] + end + AssessmentSection.new(key: "age_range_subjects", checks:, failure_reasons:) end @@ -193,11 +208,13 @@ def english_language_proficiency_section ] end - failure_reasons += [ - FailureReasons::SUITABILITY, - FailureReasons::SUITABILITY_PREVIOUSLY_DECLINED, - FailureReasons::FRAUD, - ] + if suitability_active? + failure_reasons += [ + FailureReasons::SUITABILITY, + FailureReasons::SUITABILITY_PREVIOUSLY_DECLINED, + FailureReasons::FRAUD, + ] + end AssessmentSection.new( key: "english_language_proficiency", @@ -216,11 +233,16 @@ def work_history_section FailureReasons::SCHOOL_DETAILS_CANNOT_BE_VERIFIED, FailureReasons::UNRECOGNISED_REFERENCES, FailureReasons::WORK_HISTORY_DURATION, - FailureReasons::SUITABILITY, - FailureReasons::SUITABILITY_PREVIOUSLY_DECLINED, - FailureReasons::FRAUD, ] + if suitability_active? + failure_reasons += [ + FailureReasons::SUITABILITY, + FailureReasons::SUITABILITY_PREVIOUSLY_DECLINED, + FailureReasons::FRAUD, + ] + end + AssessmentSection.new(key: "work_history", checks:, failure_reasons:) end @@ -277,15 +299,24 @@ def professional_standing_section FailureReasons::CONFIRM_AGE_RANGE_SUBJECTS, FailureReasons::QUALIFIED_TO_TEACH, FailureReasons::FULL_PROFESSIONAL_STATUS, - FailureReasons::SUITABILITY, - FailureReasons::SUITABILITY_PREVIOUSLY_DECLINED, - FailureReasons::FRAUD, ].compact + if suitability_active? + failure_reasons += [ + FailureReasons::SUITABILITY, + FailureReasons::SUITABILITY_PREVIOUSLY_DECLINED, + FailureReasons::FRAUD, + ] + end + AssessmentSection.new( key: "professional_standing", checks:, failure_reasons:, ) end + + def suitability_active? + @suitability_active ||= FeatureFlags::FeatureFlag.active?(:suitability) + end end diff --git a/spec/lib/assessment_factory_spec.rb b/spec/lib/assessment_factory_spec.rb index 8412ff26d..ef834dc46 100644 --- a/spec/lib/assessment_factory_spec.rb +++ b/spec/lib/assessment_factory_spec.rb @@ -16,6 +16,10 @@ ) end + before { FeatureFlags::FeatureFlag.activate(:suitability) } + + after { FeatureFlags::FeatureFlag.deactivate(:suitability) } + describe "#call" do subject(:call) { described_class.call(application_form:) } @@ -122,9 +126,9 @@ degree_transcript_illegible additional_degree_certificate_illegible additional_degree_transcript_illegible + special_education_only suitability suitability_previously_declined - special_education_only fraud ], ) @@ -173,9 +177,9 @@ degree_transcript_illegible additional_degree_certificate_illegible additional_degree_transcript_illegible + special_education_only suitability suitability_previously_declined - special_education_only fraud ], )