From 2dbac37a70c4bd05665004c2a54f54f21e6bd51c Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Wed, 24 Apr 2024 08:00:58 +0100 Subject: [PATCH] Refactor created_under_new_regulations? This changes the method to return true if the application form was created under the old regulations and assumes the new regulations by default across the service. --- .../assessment_sections_controller.rb | 2 +- ...application_form_section_status_updater.rb | 20 +- app/lib/assessment_factory.rb | 124 +++++------ app/lib/dqt/recognition_route.rb | 4 +- app/lib/dqt/trn_request_params.rb | 20 +- app/models/application_form.rb | 4 +- app/models/assessment.rb | 10 +- app/models/further_information_request.rb | 2 +- app/models/work_history.rb | 2 +- .../application_form_view_object.rb | 2 +- .../_work_history_summary.html.erb | 14 +- ..._history_old_regulations_summary.html.erb} | 0 .../application_forms/show/_draft.html.erb | 12 +- spec/factories/application_forms.rb | 2 +- spec/jobs/expire_requestable_job_spec.rb | 2 +- ...cation_form_section_status_updater_spec.rb | 14 +- spec/lib/assessment_factory_spec.rb | 198 ++++-------------- spec/lib/dqt/recognition_route_spec.rb | 8 +- spec/lib/dqt/trn_request_params_spec.rb | 43 +--- spec/models/application_form_spec.rb | 44 +--- spec/models/assessment_spec.rb | 6 +- spec/services/send_reminder_email_spec.rb | 6 +- .../assessor_interface/check_work_history.rb | 2 +- .../checking_submitted_details_spec.rb | 1 - .../completing_assessment_spec.rb | 2 +- 25 files changed, 177 insertions(+), 367 deletions(-) rename app/views/shared/application_form/{_work_history_old_regs_summary.html.erb => _work_history_old_regulations_summary.html.erb} (100%) diff --git a/app/controllers/assessor_interface/assessment_sections_controller.rb b/app/controllers/assessor_interface/assessment_sections_controller.rb index 8e17e60d48..2dc1ed3bb0 100644 --- a/app/controllers/assessor_interface/assessment_sections_controller.rb +++ b/app/controllers/assessor_interface/assessment_sections_controller.rb @@ -69,7 +69,7 @@ def form_class if assessment_section.age_range_subjects? CheckAgeRangeSubjectsForm elsif assessment_section.professional_standing? && - application_form.created_under_new_regulations? && + !application_form.created_under_old_regulations? && !application_form.needs_work_history if CountryCode.scotland?(application_form.country.code) ScotlandFullRegistrationForm diff --git a/app/lib/application_form_section_status_updater.rb b/app/lib/application_form_section_status_updater.rb index 6e63b2e308..513c726482 100644 --- a/app/lib/application_form_section_status_updater.rb +++ b/app/lib/application_form_section_status_updater.rb @@ -147,7 +147,16 @@ def english_language_status def work_history_status all_work_histories_complete = work_histories.all?(&:complete?) - if application_form.created_under_new_regulations? + if application_form.created_under_old_regulations? + return :not_started if has_work_history.nil? + + if !has_work_history || + (!work_histories.empty? && all_work_histories_complete) + :completed + else + :in_progress + end + else return :not_started if work_histories.empty? return :in_progress unless all_work_histories_complete @@ -157,15 +166,6 @@ def work_history_status ).enough_for_submission? enough_for_submission ? :completed : :in_progress - else - return :not_started if has_work_history.nil? - - if !has_work_history || - (!work_histories.empty? && all_work_histories_complete) - :completed - else - :in_progress - end end end diff --git a/app/lib/assessment_factory.rb b/app/lib/assessment_factory.rb index 0d25093bf3..eb8f9f40fa 100644 --- a/app/lib/assessment_factory.rb +++ b/app/lib/assessment_factory.rb @@ -49,8 +49,7 @@ def personal_information_section end ), ( - if application_form.created_under_new_regulations? && - application_form.english_language_citizenship_exempt + if application_form.english_language_citizenship_exempt FailureReasons::EL_EXEMPTION_BY_CITIZENSHIP_ID_UNCONFIRMED end ), @@ -87,16 +86,8 @@ def qualifications_section "has_university_degree_transcript", "has_additional_qualification_certificate", "has_additional_degree_transcript", - ( - if application_form.created_under_new_regulations? - "teaching_qualification_pedagogy" - end - ), - ( - if application_form.created_under_new_regulations? - "teaching_qualification_1_year" - end - ), + "teaching_qualification_pedagogy", + "teaching_qualification_1_year", ].compact failure_reasons = [ @@ -104,19 +95,10 @@ def qualifications_section FailureReasons::TEACHING_QUALIFICATIONS_FROM_INELIGIBLE_COUNTRY, FailureReasons::TEACHING_QUALIFICATIONS_NOT_AT_REQUIRED_LEVEL, FailureReasons::TEACHING_HOURS_NOT_FULFILLED, + FailureReasons::TEACHING_QUALIFICATION_PEDAGOGY, + FailureReasons::TEACHING_QUALIFICATION_1_YEAR, ( - if application_form.created_under_new_regulations? - FailureReasons::TEACHING_QUALIFICATION_PEDAGOGY - end - ), - ( - if application_form.created_under_new_regulations? - FailureReasons::TEACHING_QUALIFICATION_1_YEAR - end - ), - ( - if application_form.created_under_new_regulations? && - application_form.english_language_qualification_exempt + if application_form.english_language_qualification_exempt FailureReasons::EL_EXEMPTION_BY_QUALIFICATION_DOCUMENTS_UNCONFIRMED end ), @@ -169,69 +151,57 @@ def age_range_subjects_section end def english_language_proficiency_section - if application_form.created_under_new_regulations? - checks = - if application_form.english_language_exempt? - [] - elsif application_form.english_language_proof_method_medium_of_instruction? - %i[english_language_valid_moi] - else - %i[english_language_valid_provider] - end - - failure_reasons = - if application_form.english_language_exempt? - [] - elsif application_form.english_language_proof_method_medium_of_instruction? - [ - FailureReasons::EL_MOI_NOT_TAUGHT_IN_ENGLISH, - FailureReasons::EL_MOI_INVALID_FORMAT, - ] - else - [ - FailureReasons::EL_QUALIFICATION_INVALID, - ( - if application_form.english_language_provider_other - FailureReasons::EL_PROFICIENCY_DOCUMENT_ILLEGIBLE - else - FailureReasons::EL_UNVERIFIABLE_REFERENCE_NUMBER - end - ), - FailureReasons::EL_GRADE_BELOW_B2, - FailureReasons::EL_SELT_EXPIRED, - ] - end - - AssessmentSection.new( - key: "english_language_proficiency", - checks:, - failure_reasons:, - ) - end - end - - def work_history_section - return nil unless application_form.needs_work_history - checks = - if application_form.created_under_new_regulations? - %i[verify_school_details work_history_references] + if application_form.english_language_exempt? + [] + elsif application_form.english_language_proof_method_medium_of_instruction? + %i[english_language_valid_moi] else - %i[email_contact_current_employer satisfactory_evidence_work_history] + %i[english_language_valid_provider] end failure_reasons = - if application_form.created_under_new_regulations? + if application_form.english_language_exempt? + [] + elsif application_form.english_language_proof_method_medium_of_instruction? [ - FailureReasons::WORK_HISTORY_BREAK, - FailureReasons::SCHOOL_DETAILS_CANNOT_BE_VERIFIED, - FailureReasons::UNRECOGNISED_REFERENCES, - FailureReasons::WORK_HISTORY_DURATION, + FailureReasons::EL_MOI_NOT_TAUGHT_IN_ENGLISH, + FailureReasons::EL_MOI_INVALID_FORMAT, ] else - [FailureReasons::SATISFACTORY_EVIDENCE_WORK_HISTORY] + [ + FailureReasons::EL_QUALIFICATION_INVALID, + ( + if application_form.english_language_provider_other + FailureReasons::EL_PROFICIENCY_DOCUMENT_ILLEGIBLE + else + FailureReasons::EL_UNVERIFIABLE_REFERENCE_NUMBER + end + ), + FailureReasons::EL_GRADE_BELOW_B2, + FailureReasons::EL_SELT_EXPIRED, + ] end + AssessmentSection.new( + key: "english_language_proficiency", + checks:, + failure_reasons:, + ) + end + + def work_history_section + return nil unless application_form.needs_work_history + + checks = %i[verify_school_details work_history_references] + + failure_reasons = [ + FailureReasons::WORK_HISTORY_BREAK, + FailureReasons::SCHOOL_DETAILS_CANNOT_BE_VERIFIED, + FailureReasons::UNRECOGNISED_REFERENCES, + FailureReasons::WORK_HISTORY_DURATION, + ] + AssessmentSection.new(key: "work_history", checks:, failure_reasons:) end diff --git a/app/lib/dqt/recognition_route.rb b/app/lib/dqt/recognition_route.rb index 3bdfc3c57d..011864e49f 100644 --- a/app/lib/dqt/recognition_route.rb +++ b/app/lib/dqt/recognition_route.rb @@ -2,12 +2,12 @@ class DQT::RecognitionRoute class << self - def for_country_code(country_code, under_new_regulations:) + def for_country_code(country_code, under_old_regulations:) if CountryCode.scotland?(country_code) "Scotland" elsif CountryCode.northern_ireland?(country_code) "NorthernIreland" - elsif !under_new_regulations && + elsif under_old_regulations && CountryCode.european_economic_area?(country_code) "EuropeanEconomicArea" else diff --git a/app/lib/dqt/trn_request_params.rb b/app/lib/dqt/trn_request_params.rb index b60c8c3f53..d3e431fbe2 100644 --- a/app/lib/dqt/trn_request_params.rb +++ b/app/lib/dqt/trn_request_params.rb @@ -26,13 +26,13 @@ def call recognitionRoute: RecognitionRoute.for_country_code( application_form.region.country.code, - under_new_regulations: - application_form.created_under_new_regulations?, + under_old_regulations: + application_form.created_under_old_regulations?, ), qtsDate: qts_decision_at.to_date.iso8601, inductionRequired: induction_required, underNewOverseasRegulations: - application_form.created_under_new_regulations?, + !application_form.created_under_old_regulations?, } end @@ -79,19 +79,17 @@ def degree_qualification end def qts_decision_at - if application_form.created_under_new_regulations? - application_form.assessment.recommended_at - else + if application_form.created_under_old_regulations? application_form.submitted_at + else + application_form.assessment.recommended_at end end def induction_required - if application_form.created_under_new_regulations? - assessment.induction_required - else - false - end + return false if application_form.created_under_old_regulations? + + assessment.induction_required end end end diff --git a/app/models/application_form.rb b/app/models/application_form.rb index 5a78ac19fd..d337ed69ec 100644 --- a/app/models/application_form.rb +++ b/app/models/application_form.rb @@ -238,8 +238,8 @@ def english_language_exempt? english_language_citizenship_exempt || english_language_qualification_exempt end - def created_under_new_regulations? - created_at >= Date.parse(ENV.fetch("NEW_REGS_DATE", "2023-02-01")) + def created_under_old_regulations? + created_at < Date.new(2023, 2, 1) end def reminder_email_names diff --git a/app/models/assessment.rb b/app/models/assessment.rb index fa4fe0459a..1a997da4ec 100644 --- a/app/models/assessment.rb +++ b/app/models/assessment.rb @@ -92,7 +92,9 @@ def completed? end def can_award? - if application_form.created_under_new_regulations? + if application_form.created_under_old_regulations? + all_sections_or_further_information_requests_passed? + else return false if induction_required.nil? if verify? @@ -108,8 +110,6 @@ def can_award? else false end - else - all_sections_or_further_information_requests_passed? end end @@ -147,7 +147,7 @@ def can_request_further_information? def can_review? return false unless verify? - return false unless application_form.created_under_new_regulations? + return false if application_form.created_under_old_regulations? return false unless all_consent_requests_verified? return false unless all_reference_requests_verified? @@ -164,7 +164,7 @@ def can_review? def can_verify? return false unless unknown? || request_further_information? - return false unless application_form.created_under_new_regulations? + return false if application_form.created_under_old_regulations? all_sections_or_further_information_requests_passed? end diff --git a/app/models/further_information_request.rb b/app/models/further_information_request.rb index fa67b342ef..612ffc0ceb 100644 --- a/app/models/further_information_request.rb +++ b/app/models/further_information_request.rb @@ -56,7 +56,7 @@ def send_reminder_email(_name, _number_of_reminders_sent) end def expires_after - if !application_form.created_under_new_regulations? && + if application_form.created_under_old_regulations? && FOUR_WEEK_COUNTRY_CODES.include?(application_form.country.code) 4.weeks else diff --git a/app/models/work_history.rb b/app/models/work_history.rb index d96d621073..dc345539ab 100644 --- a/app/models/work_history.rb +++ b/app/models/work_history.rb @@ -73,7 +73,7 @@ def complete? values += [contact_name, contact_email] end - if application_form.created_under_new_regulations? + unless application_form.created_under_old_regulations? values.append(hours_per_week) unless application_form.reduced_evidence_accepted? diff --git a/app/view_objects/teacher_interface/application_form_view_object.rb b/app/view_objects/teacher_interface/application_form_view_object.rb index b3100db511..1612daa028 100644 --- a/app/view_objects/teacher_interface/application_form_view_object.rb +++ b/app/view_objects/teacher_interface/application_form_view_object.rb @@ -31,7 +31,7 @@ def task_list_sections %i[personal_information identification_document], ), task_list_section(:qualifications, %i[qualifications age_range subjects]), - if application_form.created_under_new_regulations? + unless application_form.created_under_old_regulations? task_list_section(:english_language, %i[english_language]) end, if needs_work_history diff --git a/app/views/assessor_interface/assessment_sections/_work_history_summary.html.erb b/app/views/assessor_interface/assessment_sections/_work_history_summary.html.erb index b1fbd1886c..b247b9a1bf 100644 --- a/app/views/assessor_interface/assessment_sections/_work_history_summary.html.erb +++ b/app/views/assessor_interface/assessment_sections/_work_history_summary.html.erb @@ -1,17 +1,17 @@ -<% if application_form.created_under_new_regulations? %> - <%= render "shared/application_form/work_history_summary", - work_histories: application_form.work_histories.order_by_user, - highlighted_contact_emails: highlighted_work_history_contact_emails %> -<% else %> - <%= render "shared/application_form/work_history_old_regs_summary", +<% if application_form.created_under_old_regulations? %> + <%= render "shared/application_form/work_history_old_regulations_summary", application_form:, show_has_work_history: true, work_histories: application_form.work_histories.order_by_user, highlighted_contact_emails: highlighted_work_history_contact_emails, changeable: false %> +<% else %> + <%= render "shared/application_form/work_history_summary", + work_histories: application_form.work_histories.order_by_user, + highlighted_contact_emails: highlighted_work_history_contact_emails %> <% end %> -<% if application_form.created_under_new_regulations? %> +<% unless application_form.created_under_old_regulations? %> <% years, months = WorkHistoryDuration.for_application_form(application_form).count_years_and_months %>

diff --git a/app/views/shared/application_form/_work_history_old_regs_summary.html.erb b/app/views/shared/application_form/_work_history_old_regulations_summary.html.erb similarity index 100% rename from app/views/shared/application_form/_work_history_old_regs_summary.html.erb rename to app/views/shared/application_form/_work_history_old_regulations_summary.html.erb diff --git a/app/views/teacher_interface/application_forms/show/_draft.html.erb b/app/views/teacher_interface/application_forms/show/_draft.html.erb index 48729b4fba..60b91073db 100644 --- a/app/views/teacher_interface/application_forms/show/_draft.html.erb +++ b/app/views/teacher_interface/application_forms/show/_draft.html.erb @@ -40,13 +40,11 @@ You have completed <%= view_object.completed_task_list_sections.count %> of <%= view_object.task_list_sections.count %> sections.

-<% if view_object.application_form.created_under_new_regulations? %> - <%= govuk_inset_text do %> -

- You started this application on <%= view_object.started_at %>. - Applications must be completed within 6 months, so you’ll need to complete it before <%= view_object.expires_at %>. -

- <% end %> +<%= govuk_inset_text do %> +

+ You started this application on <%= view_object.started_at %>. + Applications must be completed within 6 months, so you’ll need to complete it before <%= view_object.expires_at %>. +

<% end %> <%= render TaskList::Component.new(view_object.task_list_sections) %> diff --git a/spec/factories/application_forms.rb b/spec/factories/application_forms.rb index 0e4e29ab96..48fbb1e592 100644 --- a/spec/factories/application_forms.rb +++ b/spec/factories/application_forms.rb @@ -211,7 +211,7 @@ withdrawn_at { Time.zone.now } end - trait :old_regs do + trait :old_regulations do created_at { Date.new(2023, 1, 31) } needs_work_history do (region.status_check_none? || region.sanction_check_none?) && diff --git a/spec/jobs/expire_requestable_job_spec.rb b/spec/jobs/expire_requestable_job_spec.rb index 7780be08cc..28ce70ff0e 100644 --- a/spec/jobs/expire_requestable_job_spec.rb +++ b/spec/jobs/expire_requestable_job_spec.rb @@ -47,7 +47,7 @@ context "when the applicant is from a country with a 4 week expiry" do let(:application_form) do - create(:application_form, :submitted, :old_regs, region:) + create(:application_form, :submitted, :old_regulations, region:) end # Australia, Canada, Gibraltar, New Zealand, US diff --git a/spec/lib/application_form_section_status_updater_spec.rb b/spec/lib/application_form_section_status_updater_spec.rb index d3cdb393a3..80a4cc9349 100644 --- a/spec/lib/application_form_section_status_updater_spec.rb +++ b/spec/lib/application_form_section_status_updater_spec.rb @@ -255,13 +255,13 @@ context "under the old regulations" do context "with unknown work history" do - let(:application_form) { create(:application_form, :old_regs) } + let(:application_form) { create(:application_form, :old_regulations) } it { is_expected.to eq("not_started") } end context "with no work history" do let(:application_form) do - create(:application_form, :old_regs, has_work_history: false) + create(:application_form, :old_regulations, has_work_history: false) end it { is_expected.to eq("completed") } end @@ -269,7 +269,11 @@ context "with has work history" do context "without work history" do let(:application_form) do - create(:application_form, :old_regs, has_work_history: true) + create( + :application_form, + :old_regulations, + has_work_history: true, + ) end it { is_expected.to eq("in_progress") } end @@ -278,7 +282,7 @@ let(:application_form) do create( :application_form, - :old_regs, + :old_regulations, has_work_history: true, ).tap do |application_form| create(:work_history, application_form:) @@ -291,7 +295,7 @@ let(:application_form) do create( :application_form, - :old_regs, + :old_regulations, has_work_history: true, ).tap do |application_form| create(:work_history, :completed, application_form:) diff --git a/spec/lib/assessment_factory_spec.rb b/spec/lib/assessment_factory_spec.rb index ae6b3105e6..e8a63e1369 100644 --- a/spec/lib/assessment_factory_spec.rb +++ b/spec/lib/assessment_factory_spec.rb @@ -7,7 +7,6 @@ let(:application_form) do create( :application_form, - :old_regs, region: create(:region, country:), needs_work_history: false, needs_written_statement: false, @@ -35,8 +34,8 @@ describe "sections" do subject(:sections) { call.sections } - it "creates three sections" do - expect(sections.count).to eq(3) + it "creates four sections" do + expect(sections.count).to eq(4) end describe "personal information section" do @@ -84,92 +83,48 @@ expect(sections.qualifications.count).to eq(1) end - context "under the old regulations" do - it "has the right checks and failure reasons" do - section = sections.qualifications.first - - expect(section.checks).to eq( - %w[ - qualifications_meet_level_6_or_equivalent - teaching_qualifications_completed_in_eligible_country - qualified_in_mainstream_education - has_teacher_qualification_certificate - has_teacher_qualification_transcript - has_university_degree_certificate - has_university_degree_transcript - has_additional_qualification_certificate - has_additional_degree_transcript - ], - ) - - expect(section.failure_reasons).to eq( - %w[ - application_and_qualification_names_do_not_match - teaching_qualifications_from_ineligible_country - teaching_qualifications_not_at_required_level - teaching_hours_not_fulfilled - not_qualified_to_teach_mainstream - qualifications_dont_match_subjects - qualifications_dont_match_other_details - teaching_certificate_illegible - teaching_transcript_illegible - degree_certificate_illegible - degree_transcript_illegible - additional_degree_certificate_illegible - additional_degree_transcript_illegible - ], - ) - end - - context "when secondary education teaching qualification is required" do - let(:country) { create(:country, :subject_limited) } - - it "has the right checks and failure reasons" do - section = sections.qualifications.first + it "has the right checks and failure reasons" do + section = sections.qualifications.first - expect(section.checks).to eq( - %w[ - qualifications_meet_level_6_or_equivalent - teaching_qualifications_completed_in_eligible_country - qualified_in_mainstream_education - qualified_to_teach_children_11_to_16 - teaching_qualification_subjects_criteria - has_teacher_qualification_certificate - has_teacher_qualification_transcript - has_university_degree_certificate - has_university_degree_transcript - has_additional_qualification_certificate - has_additional_degree_transcript - ], - ) + expect(section.checks).to eq( + %w[ + qualifications_meet_level_6_or_equivalent + teaching_qualifications_completed_in_eligible_country + qualified_in_mainstream_education + has_teacher_qualification_certificate + has_teacher_qualification_transcript + has_university_degree_certificate + has_university_degree_transcript + has_additional_qualification_certificate + has_additional_degree_transcript + teaching_qualification_pedagogy + teaching_qualification_1_year + ], + ) - expect(section.failure_reasons).to eq( - %w[ - application_and_qualification_names_do_not_match - teaching_qualifications_from_ineligible_country - teaching_qualifications_not_at_required_level - teaching_hours_not_fulfilled - not_qualified_to_teach_mainstream - qualifications_dont_match_subjects - qualifications_dont_match_other_details - qualified_to_teach_children_11_to_16 - teaching_qualification_subjects_criteria - teaching_certificate_illegible - teaching_transcript_illegible - degree_certificate_illegible - degree_transcript_illegible - additional_degree_certificate_illegible - additional_degree_transcript_illegible - ], - ) - end - end + expect(section.failure_reasons).to eq( + %w[ + application_and_qualification_names_do_not_match + teaching_qualifications_from_ineligible_country + teaching_qualifications_not_at_required_level + teaching_hours_not_fulfilled + teaching_qualification_pedagogy + teaching_qualification_1_year + not_qualified_to_teach_mainstream + qualifications_dont_match_subjects + qualifications_dont_match_other_details + teaching_certificate_illegible + teaching_transcript_illegible + degree_certificate_illegible + degree_transcript_illegible + additional_degree_certificate_illegible + additional_degree_transcript_illegible + ], + ) end - context "under the new regulations" do - let(:application_form) do - create(:application_form, region: create(:region, country:)) - end + context "when secondary education teaching qualification is required" do + let(:country) { create(:country, :subject_limited) } it "has the right checks and failure reasons" do section = sections.qualifications.first @@ -179,6 +134,8 @@ qualifications_meet_level_6_or_equivalent teaching_qualifications_completed_in_eligible_country qualified_in_mainstream_education + qualified_to_teach_children_11_to_16 + teaching_qualification_subjects_criteria has_teacher_qualification_certificate has_teacher_qualification_transcript has_university_degree_certificate @@ -201,6 +158,8 @@ not_qualified_to_teach_mainstream qualifications_dont_match_subjects qualifications_dont_match_other_details + qualified_to_teach_children_11_to_16 + teaching_qualification_subjects_criteria teaching_certificate_illegible teaching_transcript_illegible degree_certificate_illegible @@ -210,54 +169,6 @@ ], ) end - - context "when secondary education teaching qualification is required" do - let(:country) { create(:country, :subject_limited) } - - it "has the right checks and failure reasons" do - section = sections.qualifications.first - - expect(section.checks).to eq( - %w[ - qualifications_meet_level_6_or_equivalent - teaching_qualifications_completed_in_eligible_country - qualified_in_mainstream_education - qualified_to_teach_children_11_to_16 - teaching_qualification_subjects_criteria - has_teacher_qualification_certificate - has_teacher_qualification_transcript - has_university_degree_certificate - has_university_degree_transcript - has_additional_qualification_certificate - has_additional_degree_transcript - teaching_qualification_pedagogy - teaching_qualification_1_year - ], - ) - - expect(section.failure_reasons).to eq( - %w[ - application_and_qualification_names_do_not_match - teaching_qualifications_from_ineligible_country - teaching_qualifications_not_at_required_level - teaching_hours_not_fulfilled - teaching_qualification_pedagogy - teaching_qualification_1_year - not_qualified_to_teach_mainstream - qualifications_dont_match_subjects - qualifications_dont_match_other_details - qualified_to_teach_children_11_to_16 - teaching_qualification_subjects_criteria - teaching_certificate_illegible - teaching_transcript_illegible - degree_certificate_illegible - degree_transcript_illegible - additional_degree_certificate_illegible - additional_degree_transcript_illegible - ], - ) - end - end end end @@ -356,30 +267,13 @@ expect(sections.work_history.count).to eq(0) end - context "when application form form needs work history" do + context "when an application requires work history" do before { application_form.needs_work_history = true } it "is created" do expect(sections.work_history.count).to eq(1) end - it "has the right checks and failure reasons" do - section = sections.work_history.first - expect(section.checks).to eq( - %w[ - email_contact_current_employer - satisfactory_evidence_work_history - ], - ) - expect(section.failure_reasons).to eq( - ["satisfactory_evidence_work_history"], - ) - end - end - - context "with a new regulations application form" do - let(:application_form) { create(:application_form) } - it "has the right checks and failure reasons" do section = sections.work_history.first @@ -401,7 +295,7 @@ describe "professional standing section" do it "is not created" do - expect(sections.work_history.count).to eq(0) + expect(sections.professional_standing.count).to eq(0) end context "when application form needs a written statement and work history" do diff --git a/spec/lib/dqt/recognition_route_spec.rb b/spec/lib/dqt/recognition_route_spec.rb index aae77eb27f..2fd36816b1 100644 --- a/spec/lib/dqt/recognition_route_spec.rb +++ b/spec/lib/dqt/recognition_route_spec.rb @@ -5,10 +5,10 @@ RSpec.describe DQT::RecognitionRoute do describe "#for_code" do subject(:recognition_route) do - described_class.for_country_code(country_code, under_new_regulations:) + described_class.for_country_code(country_code, under_old_regulations:) end - let(:under_new_regulations) { false } + let(:under_old_regulations) { nil } context "with Scotland" do let(:country_code) { "GB-SCT" } @@ -21,7 +21,7 @@ end context "under the new regulations" do - let(:under_new_regulations) { true } + let(:under_old_regulations) { false } (Country::CODES - %w[GB-SCT GB-NIR]).each do |country_code| context "with #{country_code}" do @@ -32,7 +32,7 @@ end context "under the old regulations" do - let(:under_new_regulations) { false } + let(:under_old_regulations) { true } Country::CODES_IN_EUROPEAN_ECONOMIC_AREA.each do |country_code| context "with #{country_code}" do diff --git a/spec/lib/dqt/trn_request_params_spec.rb b/spec/lib/dqt/trn_request_params_spec.rb index c219abd363..a4f829252d 100644 --- a/spec/lib/dqt/trn_request_params_spec.rb +++ b/spec/lib/dqt/trn_request_params_spec.rb @@ -11,8 +11,8 @@ :application_form, :awarded, teacher:, - created_at: Date.new(2020, 1, 1), - submitted_at: Date.new(2020, 1, 1), + created_at: Date.new(2024, 1, 1), + submitted_at: Date.new(2024, 1, 1), region: create(:region, :in_country, country_code: "AU"), date_of_birth: Date.new(1960, 1, 1), given_names: "Given", @@ -25,11 +25,12 @@ create( :assessment, :award, - recommended_at: Date.new(2020, 1, 7), + recommended_at: Date.new(2024, 1, 7), application_form:, age_range_min: 7, age_range_max: 11, subjects: %w[physics french_language], + induction_required: true, ) end @@ -57,7 +58,7 @@ emailAddress: "teacher@example.com", firstName: "Given", genderCode: "NotAvailable", - inductionRequired: false, + inductionRequired: true, initialTeacherTraining: { ageRangeFrom: 7, ageRangeTo: 11, @@ -71,7 +72,7 @@ }, lastName: "Family", middleName: nil, - qtsDate: "2020-01-01", + qtsDate: "2024-01-07", qualification: { class: "NotKnown", countryCode: "FR", @@ -81,39 +82,9 @@ }, recognitionRoute: "OverseasTrainedTeachers", teacherType: "OverseasQualifiedTeacher", - underNewOverseasRegulations: false, + underNewOverseasRegulations: true, }, ) end - - context "with a new regulations application form" do - around do |example| - ClimateControl.modify(NEW_REGS_DATE: "2020-01-01") { example.run } - end - - it "should use the assessment recommendation date" do - expect(call[:qtsDate]).to eq("2020-01-07") - end - - it "sends the new regulations field" do - expect(call[:underNewOverseasRegulations]).to be true - end - - describe "induction required" do - subject(:induction_required) { call[:inductionRequired] } - - it { is_expected.to be_nil } - - context "when induction is required" do - before { assessment.update!(induction_required: true) } - it { is_expected.to be true } - end - - context "when induction is not required" do - before { assessment.update!(induction_required: false) } - it { is_expected.to be false } - end - end - end end end diff --git a/spec/models/application_form_spec.rb b/spec/models/application_form_spec.rb index ff66525d02..47275addf6 100644 --- a/spec/models/application_form_spec.rb +++ b/spec/models/application_form_spec.rb @@ -444,45 +444,23 @@ it { is_expected.to eq(application_form.reference) } end - describe "#created_under_new_regulations?" do - subject(:created_under_new_regulations?) do - application_form.created_under_new_regulations? + describe "#created_under_old_regulations?" do + subject(:created_under_old_regulations?) do + application_form.created_under_old_regulations? end - context "with default new regulations date" do - context "with an old application form" do - let(:application_form) do - create(:application_form, created_at: Date.new(2020, 1, 1)) - end - it { is_expected.to be false } - end - - context "with a new application form" do - let(:application_form) do - create(:application_form, created_at: Date.new(2024, 1, 1)) - end - it { is_expected.to be true } + context "with an old application form" do + let(:application_form) do + create(:application_form, created_at: Date.new(2020, 1, 1)) end + it { is_expected.to be true } end - context "with a custom new regulations date" do - around do |example| - ClimateControl.modify(NEW_REGS_DATE: "2023-01-01") { example.run } - end - - context "with an old application form" do - let(:application_form) do - create(:application_form, created_at: Date.new(2021, 12, 31)) - end - it { is_expected.to be false } - end - - context "with a new application form" do - let(:application_form) do - create(:application_form, created_at: Date.new(2023, 1, 1)) - end - it { is_expected.to be true } + context "with a new application form" do + let(:application_form) do + create(:application_form, created_at: Date.new(2024, 1, 1)) end + it { is_expected.to be false } end end end diff --git a/spec/models/assessment_spec.rb b/spec/models/assessment_spec.rb index 5682b15822..7468f4218b 100644 --- a/spec/models/assessment_spec.rb +++ b/spec/models/assessment_spec.rb @@ -72,7 +72,7 @@ subject(:can_award?) { assessment.can_award? } context "with an application under old regulations" do - let(:application_form) { create(:application_form, :old_regs) } + let(:application_form) { create(:application_form, :old_regulations) } context "with an unknown assessment" do before do @@ -353,7 +353,7 @@ end context "with an application under old regulations" do - let(:application_form) { create(:application_form, :old_regs) } + let(:application_form) { create(:application_form, :old_regulations) } it { is_expected.to be false } end end @@ -428,7 +428,7 @@ end context "with an application under old regulations" do - let(:application_form) { create(:application_form, :old_regs) } + let(:application_form) { create(:application_form, :old_regulations) } it { is_expected.to be false } end end diff --git a/spec/services/send_reminder_email_spec.rb b/spec/services/send_reminder_email_spec.rb index 053b0da8f8..fe59a70abd 100644 --- a/spec/services/send_reminder_email_spec.rb +++ b/spec/services/send_reminder_email_spec.rb @@ -215,7 +215,7 @@ context "with a requested FI request" do let(:application_form) do - create(:application_form, :submitted, :old_regs, region:) + create(:application_form, :submitted, :old_regulations, region:) end let(:assessment) { create(:assessment, application_form:) } let(:region) { create(:region, :in_country, country_code: "FR") } @@ -284,9 +284,7 @@ end context "with a requested reference request" do - let(:application_form) do - create(:application_form, :submitted, :old_regs, region:) - end + let(:application_form) { create(:application_form, :submitted, region:) } let(:assessment) { create(:assessment, application_form:) } let(:region) { create(:region, :in_country, country_code: "FR") } let(:work_history) { remindable.work_history } diff --git a/spec/support/autoload/page_objects/assessor_interface/check_work_history.rb b/spec/support/autoload/page_objects/assessor_interface/check_work_history.rb index c140e958a2..7fe22ccce7 100644 --- a/spec/support/autoload/page_objects/assessor_interface/check_work_history.rb +++ b/spec/support/autoload/page_objects/assessor_interface/check_work_history.rb @@ -16,7 +16,7 @@ class CheckWorkHistory < AssessmentSection ".govuk-checkboxes__conditional .govuk-checkboxes__item" def most_recent_role - cards&.second + cards&.first end end end diff --git a/spec/system/assessor_interface/checking_submitted_details_spec.rb b/spec/system/assessor_interface/checking_submitted_details_spec.rb index 52695c9932..48d2c00244 100644 --- a/spec/system/assessor_interface/checking_submitted_details_spec.rb +++ b/spec/system/assessor_interface/checking_submitted_details_spec.rb @@ -460,7 +460,6 @@ def application_form application_form = create( :application_form, - :old_regs, :with_teaching_qualification, :with_work_history, :with_registration_number, diff --git a/spec/system/assessor_interface/completing_assessment_spec.rb b/spec/system/assessor_interface/completing_assessment_spec.rb index 5c1b7a8ec6..592e0f61e9 100644 --- a/spec/system/assessor_interface/completing_assessment_spec.rb +++ b/spec/system/assessor_interface/completing_assessment_spec.rb @@ -9,7 +9,7 @@ it "award" do given_i_am_authorized_as_an_assessor_user - given_there_is_an_awardable_application_form(%i[old_regs]) + given_there_is_an_awardable_application_form(%i[old_regulations]) given_i_can_request_dqt_api when_i_visit_the(