Skip to content

Commit

Permalink
Put suitability decline reasons behind feature flag
Browse files Browse the repository at this point in the history
This allows us to turn on the feature in the testing environments before
going live, and also allows us to go live immediately.
  • Loading branch information
thomasleese committed Jul 22, 2024
1 parent 24427f0 commit 1555eda
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 22 deletions.
71 changes: 51 additions & 20 deletions app/lib/assessment_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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:,
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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",
Expand All @@ -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

Expand Down Expand Up @@ -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
8 changes: 6 additions & 2 deletions spec/lib/assessment_factory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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:) }

Expand Down Expand Up @@ -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
],
)
Expand Down Expand Up @@ -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
],
)
Expand Down

0 comments on commit 1555eda

Please sign in to comment.