From 089f20bdb33a530ad427db7dbfd97e6aba49227e Mon Sep 17 00:00:00 2001 From: Leandro C Date: Thu, 30 May 2024 20:33:29 +0100 Subject: [PATCH] [CPDLP-3079] Update Application table with fields for participant profile from ECF (#1398) * [CPDLP-3079] Update Application table with fields for participant profile from ECF * [CPDLP-3079] Fix broken tests * [CPDLP-3079] Address PR comments --- app/models/application.rb | 7 +++++ app/models/application_state.rb | 12 ++++++++ ...145610_create_application_statuses_enum.rb | 5 ++++ ...625_add_training_status_to_applications.rb | 5 ++++ ...0240529151128_create_application_states.rb | 12 ++++++++ db/schema.rb | 17 ++++++++++- db/seeds/base/add_applications.rb | 28 +++++++++++++++++++ spec/factories/application_states.rb | 8 ++++++ spec/factories/applications.rb | 24 ++++++++++++++++ ..._receive_targeted_delivery_funding_spec.rb | 1 + .../basic_registration_journey_spec.rb | 1 + ...ou_work_in_a_school_from_no_to_yes_spec.rb | 1 + ...u_work_in_childcare_from_yes_to_no_spec.rb | 1 + ...utside_of_catchment_area_to_inside_spec.rb | 1 + ...ne_leadprovider_no_longer_supports_spec.rb | 1 + .../funded_ehco_registration_journey_spec.rb | 1 + ...international_teacher_npqh_journey_spec.rb | 1 + ...r_funded_ehco_registration_journey_spec.rb | 1 + ...received_targeted_delivery_funding_spec.rb | 1 + ...ia_using_old_name_and_not_headship_spec.rb | 1 + .../happy_paths/via_using_same_name_spec.rb | 1 + .../when_choose_lead_mentor_course_spec.rb | 1 + .../when_choose_maths_course_spec.rb | 1 + ...hen_get_an_identity_returns_no_trn_spec.rb | 1 + ..._catchment_area_crown_dependencies_spec.rb | 1 + .../when_outside_of_catchment_area_spec.rb | 1 + .../when_previously_funded_spec.rb | 1 + ...king_at_an_eligible_primary_school_spec.rb | 1 + ...le_not_currently_working_at_school_spec.rb | 1 + ...ildcare_provider_but_not_a_nursery_spec.rb | 1 + .../while_working_at_private_nursery_spec.rb | 1 + .../while_working_at_public_nursery_spec.rb | 1 + ..._in_neither_a_school_nor_childcare_spec.rb | 1 + ...g_for_ehco_but_not_new_headteacher_spec.rb | 1 + ...ntor_journey_with_incorrect_course_spec.rb | 1 + ...ks_in_childcare_but_not_in_england_spec.rb | 1 + .../handle_submission_for_store_spec.rb | 2 ++ spec/models/application_spec.rb | 9 ++++++ spec/models/application_state_spec.rb | 18 ++++++++++++ 39 files changed, 173 insertions(+), 1 deletion(-) create mode 100644 app/models/application_state.rb create mode 100644 db/migrate/20240529145610_create_application_statuses_enum.rb create mode 100644 db/migrate/20240529145625_add_training_status_to_applications.rb create mode 100644 db/migrate/20240529151128_create_application_states.rb create mode 100644 spec/factories/application_states.rb create mode 100644 spec/models/application_state_spec.rb diff --git a/app/models/application.rb b/app/models/application.rb index d3049bbb09..12f037c96d 100644 --- a/app/models/application.rb +++ b/app/models/application.rb @@ -19,6 +19,7 @@ class Application < ApplicationRecord has_many :ecf_sync_request_logs, as: :syncable, dependent: :destroy has_many :participant_id_changes, through: :user + has_many :application_states scope :unsynced, -> { where(ecf_id: nil) } scope :expired_applications, -> { where(lead_provider_approval_status: "rejected").where("created_at < ?", cut_off_date_for_expired_applications) } @@ -56,6 +57,12 @@ class Application < ApplicationRecord rejected: "rejected", } + enum training_status: { + active: "active", + deferred: "deferred", + withdrawn: "withdrawn", + } + def previously_funded? # This is an optimization used by the API Applications::Query in order # to speed up the bulk-retrieval of Applications. diff --git a/app/models/application_state.rb b/app/models/application_state.rb new file mode 100644 index 0000000000..31cce8a6af --- /dev/null +++ b/app/models/application_state.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +class ApplicationState < ApplicationRecord + belongs_to :application + belongs_to :lead_provider, optional: true + + enum state: { + active: "active", + deferred: "deferred", + withdrawn: "withdrawn", + } +end diff --git a/db/migrate/20240529145610_create_application_statuses_enum.rb b/db/migrate/20240529145610_create_application_statuses_enum.rb new file mode 100644 index 0000000000..f43e9ce3c4 --- /dev/null +++ b/db/migrate/20240529145610_create_application_statuses_enum.rb @@ -0,0 +1,5 @@ +class CreateApplicationStatusesEnum < ActiveRecord::Migration[7.1] + def change + create_enum :application_statuses, %w[active deferred withdrawn] + end +end diff --git a/db/migrate/20240529145625_add_training_status_to_applications.rb b/db/migrate/20240529145625_add_training_status_to_applications.rb new file mode 100644 index 0000000000..a8db1b4b86 --- /dev/null +++ b/db/migrate/20240529145625_add_training_status_to_applications.rb @@ -0,0 +1,5 @@ +class AddTrainingStatusToApplications < ActiveRecord::Migration[7.1] + def change + add_column :applications, :training_status, :enum, enum_type: "application_statuses", default: "active", null: false + end +end diff --git a/db/migrate/20240529151128_create_application_states.rb b/db/migrate/20240529151128_create_application_states.rb new file mode 100644 index 0000000000..8cf5d27ef4 --- /dev/null +++ b/db/migrate/20240529151128_create_application_states.rb @@ -0,0 +1,12 @@ +class CreateApplicationStates < ActiveRecord::Migration[7.1] + def change + create_table :application_states do |t| + t.references :application, null: false, foreign_key: true + t.references :lead_provider, foreign_key: true + t.enum :state, enum_type: "application_statuses", default: "active", null: false + t.text :reason + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 050b832c16..dc9d3e3cd9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_05_28_103508) do +ActiveRecord::Schema[7.1].define(version: 2024_05_29_151128) do # These are extensions that must be enabled in order to support this database enable_extension "btree_gin" enable_extension "citext" @@ -19,6 +19,7 @@ # Custom types defined in this database. # Note that some types may not work with other database engines. Be careful if changing database. + create_enum "application_statuses", ["active", "deferred", "withdrawn"] create_enum "funding_choices", ["school", "trust", "self", "another", "employer"] create_enum "headteacher_statuses", ["no", "yes_when_course_starts", "yes_in_first_two_years", "yes_over_two_years", "yes_in_first_five_years", "yes_over_five_years"] create_enum "lead_provider_approval_statuses", ["pending", "accepted", "rejected"] @@ -45,6 +46,17 @@ t.index ["lead_provider_id"], name: "index_api_tokens_on_lead_provider_id" end + create_table "application_states", force: :cascade do |t| + t.bigint "application_id", null: false + t.bigint "lead_provider_id" + t.enum "state", default: "active", null: false, enum_type: "application_statuses" + t.text "reason" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["application_id"], name: "index_application_states_on_application_id" + t.index ["lead_provider_id"], name: "index_application_states_on_lead_provider_id" + end + create_table "applications", force: :cascade do |t| t.bigint "user_id", null: false t.bigint "course_id", null: false @@ -89,6 +101,7 @@ t.string "notes" t.bigint "cohort_id" t.boolean "funded_place" + t.enum "training_status", default: "active", null: false, enum_type: "application_statuses" t.index ["cohort_id"], name: "index_applications_on_cohort_id" t.index ["course_id"], name: "index_applications_on_course_id" t.index ["itt_provider_id"], name: "index_applications_on_itt_provider_id" @@ -394,6 +407,8 @@ end add_foreign_key "api_tokens", "lead_providers" + add_foreign_key "application_states", "applications" + add_foreign_key "application_states", "lead_providers" add_foreign_key "applications", "cohorts" add_foreign_key "applications", "courses" add_foreign_key "applications", "itt_providers" diff --git a/db/seeds/base/add_applications.rb b/db/seeds/base/add_applications.rb index 6ebbe4948f..82fd417888 100644 --- a/db/seeds/base/add_applications.rb +++ b/db/seeds/base/add_applications.rb @@ -55,5 +55,33 @@ participant_outcome_state: "failed", cohort: Cohort.all.sample, ) + + # users with one deferred application each + FactoryBot.create_list( + :application, + 4, + :deferred, + :with_random_user, + :with_random_work_setting, + :with_random_lead_provider_approval_status, + :with_random_participant_outcome_state, + lead_provider:, + course: Course.all.sample, + cohort: Cohort.all.sample, + ) + + # users with one withdrawn application each + FactoryBot.create_list( + :application, + 4, + :withdrawn, + :with_random_user, + :with_random_work_setting, + :with_random_lead_provider_approval_status, + :with_random_participant_outcome_state, + lead_provider:, + course: Course.all.sample, + cohort: Cohort.all.sample, + ) end end diff --git a/spec/factories/application_states.rb b/spec/factories/application_states.rb new file mode 100644 index 0000000000..e44c90180f --- /dev/null +++ b/spec/factories/application_states.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :application_state do + application + lead_provider { LeadProvider.all.sample } + end +end diff --git a/spec/factories/applications.rb b/spec/factories/applications.rb index 7f13050e37..42c0a98190 100644 --- a/spec/factories/applications.rb +++ b/spec/factories/applications.rb @@ -99,5 +99,29 @@ FactoryBot.create(:participant_id_change, to_participant: user, user:) end end + + trait :withdrawn do + after(:create) do |application| + application.update!(training_status: ApplicationState.states[:withdrawn]) + + FactoryBot.create(:application_state, + application:, + lead_provider: application.lead_provider, + state: ApplicationState.states[:withdrawn], + reason: "other") + end + end + + trait :deferred do + after(:create) do |application| + application.update!(training_status: ApplicationState.states[:deferred]) + + FactoryBot.create(:application_state, + application:, + lead_provider: application.lead_provider, + state: ApplicationState.states[:deferred], + reason: "other") + end + end end end diff --git a/spec/features/journeys/happy_paths/able_to_receive_targeted_delivery_funding_spec.rb b/spec/features/journeys/happy_paths/able_to_receive_targeted_delivery_funding_spec.rb index e04727210d..726649efe6 100644 --- a/spec/features/journeys/happy_paths/able_to_receive_targeted_delivery_funding_spec.rb +++ b/spec/features/journeys/happy_paths/able_to_receive_targeted_delivery_funding_spec.rb @@ -156,6 +156,7 @@ def run_scenario(js:) "teacher_catchment_country" => nil, "teacher_catchment_iso_country_code" => nil, "teacher_catchment_synced_to_ecf" => false, + "training_status" => "active", "ukprn" => nil, "primary_establishment" => false, "number_of_pupils" => 100, diff --git a/spec/features/journeys/happy_paths/basic_registration_journey_spec.rb b/spec/features/journeys/happy_paths/basic_registration_journey_spec.rb index 1afebb07ef..bdd7b7fd20 100644 --- a/spec/features/journeys/happy_paths/basic_registration_journey_spec.rb +++ b/spec/features/journeys/happy_paths/basic_registration_journey_spec.rb @@ -174,6 +174,7 @@ def run_scenario(js:) "teacher_catchment_country" => nil, "teacher_catchment_iso_country_code" => nil, "teacher_catchment_synced_to_ecf" => false, + "training_status" => "active", "ukprn" => nil, "primary_establishment" => false, "number_of_pupils" => nil, diff --git a/spec/features/journeys/happy_paths/changing_do_you_work_in_a_school_from_no_to_yes_spec.rb b/spec/features/journeys/happy_paths/changing_do_you_work_in_a_school_from_no_to_yes_spec.rb index b221e5137b..1ce9e68256 100644 --- a/spec/features/journeys/happy_paths/changing_do_you_work_in_a_school_from_no_to_yes_spec.rb +++ b/spec/features/journeys/happy_paths/changing_do_you_work_in_a_school_from_no_to_yes_spec.rb @@ -201,6 +201,7 @@ def run_scenario(js:) "teacher_catchment_country" => nil, "teacher_catchment_iso_country_code" => nil, "teacher_catchment_synced_to_ecf" => false, + "training_status" => "active", "ukprn" => nil, "primary_establishment" => false, "number_of_pupils" => nil, diff --git a/spec/features/journeys/happy_paths/changing_do_you_work_in_childcare_from_yes_to_no_spec.rb b/spec/features/journeys/happy_paths/changing_do_you_work_in_childcare_from_yes_to_no_spec.rb index 48be7782b3..aad2736057 100644 --- a/spec/features/journeys/happy_paths/changing_do_you_work_in_childcare_from_yes_to_no_spec.rb +++ b/spec/features/journeys/happy_paths/changing_do_you_work_in_childcare_from_yes_to_no_spec.rb @@ -211,6 +211,7 @@ def run_scenario(js:) "teacher_catchment_country" => nil, "teacher_catchment_iso_country_code" => nil, "teacher_catchment_synced_to_ecf" => false, + "training_status" => "active", "ukprn" => nil, "primary_establishment" => false, "number_of_pupils" => 0, diff --git a/spec/features/journeys/happy_paths/changing_from_outside_of_catchment_area_to_inside_spec.rb b/spec/features/journeys/happy_paths/changing_from_outside_of_catchment_area_to_inside_spec.rb index e6a9edb24a..2a7084969a 100644 --- a/spec/features/journeys/happy_paths/changing_from_outside_of_catchment_area_to_inside_spec.rb +++ b/spec/features/journeys/happy_paths/changing_from_outside_of_catchment_area_to_inside_spec.rb @@ -193,6 +193,7 @@ def run_scenario(js:) "teacher_catchment_country" => nil, "teacher_catchment_iso_country_code" => nil, "teacher_catchment_synced_to_ecf" => false, + "training_status" => "active", "ukprn" => nil, "primary_establishment" => false, "number_of_pupils" => nil, diff --git a/spec/features/journeys/happy_paths/changing_npq_to_one_leadprovider_no_longer_supports_spec.rb b/spec/features/journeys/happy_paths/changing_npq_to_one_leadprovider_no_longer_supports_spec.rb index 08183696e1..41e7f1884d 100644 --- a/spec/features/journeys/happy_paths/changing_npq_to_one_leadprovider_no_longer_supports_spec.rb +++ b/spec/features/journeys/happy_paths/changing_npq_to_one_leadprovider_no_longer_supports_spec.rb @@ -203,6 +203,7 @@ def run_scenario(js:) "teacher_catchment_country" => nil, "teacher_catchment_iso_country_code" => nil, "teacher_catchment_synced_to_ecf" => false, + "training_status" => "active", "ukprn" => nil, "primary_establishment" => false, "number_of_pupils" => nil, diff --git a/spec/features/journeys/happy_paths/funded_ehco_registration_journey_spec.rb b/spec/features/journeys/happy_paths/funded_ehco_registration_journey_spec.rb index 08dbde2a51..c5ec1c091b 100644 --- a/spec/features/journeys/happy_paths/funded_ehco_registration_journey_spec.rb +++ b/spec/features/journeys/happy_paths/funded_ehco_registration_journey_spec.rb @@ -178,6 +178,7 @@ def run_scenario(js:) "teacher_catchment_country" => nil, "teacher_catchment_iso_country_code" => nil, "teacher_catchment_synced_to_ecf" => false, + "training_status" => "active", "ukprn" => nil, "primary_establishment" => false, "number_of_pupils" => nil, diff --git a/spec/features/journeys/happy_paths/international_teacher_npqh_journey_spec.rb b/spec/features/journeys/happy_paths/international_teacher_npqh_journey_spec.rb index 45ba6bab24..f9ee53c46c 100644 --- a/spec/features/journeys/happy_paths/international_teacher_npqh_journey_spec.rb +++ b/spec/features/journeys/happy_paths/international_teacher_npqh_journey_spec.rb @@ -145,6 +145,7 @@ def run_scenario(*) "teacher_catchment_country" => nil, "teacher_catchment_iso_country_code" => nil, "teacher_catchment_synced_to_ecf" => false, + "training_status" => "active", "ukprn" => nil, "primary_establishment" => false, "number_of_pupils" => 0, diff --git a/spec/features/journeys/happy_paths/other_funded_ehco_registration_journey_spec.rb b/spec/features/journeys/happy_paths/other_funded_ehco_registration_journey_spec.rb index 8708eb5c23..c4bb462825 100644 --- a/spec/features/journeys/happy_paths/other_funded_ehco_registration_journey_spec.rb +++ b/spec/features/journeys/happy_paths/other_funded_ehco_registration_journey_spec.rb @@ -177,6 +177,7 @@ def run_scenario(js:) "teacher_catchment_country" => nil, "teacher_catchment_iso_country_code" => nil, "teacher_catchment_synced_to_ecf" => false, + "training_status" => "active", "ukprn" => nil, "primary_establishment" => false, "number_of_pupils" => nil, diff --git a/spec/features/journeys/happy_paths/previously_received_targeted_delivery_funding_spec.rb b/spec/features/journeys/happy_paths/previously_received_targeted_delivery_funding_spec.rb index 9bd23697a9..f4766538c3 100644 --- a/spec/features/journeys/happy_paths/previously_received_targeted_delivery_funding_spec.rb +++ b/spec/features/journeys/happy_paths/previously_received_targeted_delivery_funding_spec.rb @@ -151,6 +151,7 @@ def run_scenario(js:) "teacher_catchment_country" => nil, "teacher_catchment_iso_country_code" => nil, "teacher_catchment_synced_to_ecf" => false, + "training_status" => "active", "ukprn" => nil, "primary_establishment" => false, "number_of_pupils" => 100, diff --git a/spec/features/journeys/happy_paths/via_using_old_name_and_not_headship_spec.rb b/spec/features/journeys/happy_paths/via_using_old_name_and_not_headship_spec.rb index dd63115013..b320fc6065 100644 --- a/spec/features/journeys/happy_paths/via_using_old_name_and_not_headship_spec.rb +++ b/spec/features/journeys/happy_paths/via_using_old_name_and_not_headship_spec.rb @@ -137,6 +137,7 @@ def run_scenario(js:) "teacher_catchment_country" => nil, "teacher_catchment_iso_country_code" => nil, "teacher_catchment_synced_to_ecf" => false, + "training_status" => "active", "ukprn" => nil, "primary_establishment" => false, "number_of_pupils" => nil, diff --git a/spec/features/journeys/happy_paths/via_using_same_name_spec.rb b/spec/features/journeys/happy_paths/via_using_same_name_spec.rb index 242889bccf..1f7e30691d 100644 --- a/spec/features/journeys/happy_paths/via_using_same_name_spec.rb +++ b/spec/features/journeys/happy_paths/via_using_same_name_spec.rb @@ -163,6 +163,7 @@ def run_scenario(js:) "teacher_catchment_country" => nil, "teacher_catchment_iso_country_code" => nil, "teacher_catchment_synced_to_ecf" => false, + "training_status" => "active", "ukprn" => nil, "primary_establishment" => false, "number_of_pupils" => nil, diff --git a/spec/features/journeys/happy_paths/when_choose_lead_mentor_course_spec.rb b/spec/features/journeys/happy_paths/when_choose_lead_mentor_course_spec.rb index a82f99fc52..f5ca3867b4 100644 --- a/spec/features/journeys/happy_paths/when_choose_lead_mentor_course_spec.rb +++ b/spec/features/journeys/happy_paths/when_choose_lead_mentor_course_spec.rb @@ -173,6 +173,7 @@ def run_scenario(js:) "teacher_catchment_country" => nil, "teacher_catchment_iso_country_code" => nil, "teacher_catchment_synced_to_ecf" => false, + "training_status" => "active", "ukprn" => nil, "primary_establishment" => false, "number_of_pupils" => 0, diff --git a/spec/features/journeys/happy_paths/when_choose_maths_course_spec.rb b/spec/features/journeys/happy_paths/when_choose_maths_course_spec.rb index 8281315a36..3ac4c76e53 100644 --- a/spec/features/journeys/happy_paths/when_choose_maths_course_spec.rb +++ b/spec/features/journeys/happy_paths/when_choose_maths_course_spec.rb @@ -194,6 +194,7 @@ def run_scenario(*) "teacher_catchment_country" => nil, "teacher_catchment_iso_country_code" => nil, "teacher_catchment_synced_to_ecf" => false, + "training_status" => "active", "ukprn" => nil, "primary_establishment" => true, "number_of_pupils" => 150, diff --git a/spec/features/journeys/happy_paths/when_get_an_identity_returns_no_trn_spec.rb b/spec/features/journeys/happy_paths/when_get_an_identity_returns_no_trn_spec.rb index 253bd4613c..bed6092d38 100644 --- a/spec/features/journeys/happy_paths/when_get_an_identity_returns_no_trn_spec.rb +++ b/spec/features/journeys/happy_paths/when_get_an_identity_returns_no_trn_spec.rb @@ -209,6 +209,7 @@ def run_scenario(js:) "teacher_catchment_country" => nil, "teacher_catchment_iso_country_code" => nil, "teacher_catchment_synced_to_ecf" => false, + "training_status" => "active", "ukprn" => nil, "primary_establishment" => false, "number_of_pupils" => nil, diff --git a/spec/features/journeys/happy_paths/when_outside_of_catchment_area_crown_dependencies_spec.rb b/spec/features/journeys/happy_paths/when_outside_of_catchment_area_crown_dependencies_spec.rb index 96b5600092..8cc072fb36 100644 --- a/spec/features/journeys/happy_paths/when_outside_of_catchment_area_crown_dependencies_spec.rb +++ b/spec/features/journeys/happy_paths/when_outside_of_catchment_area_crown_dependencies_spec.rb @@ -138,6 +138,7 @@ def run_scenario(js:) # rubocop:disable Lint/UnusedMethodArgument "teacher_catchment_country" => nil, "teacher_catchment_iso_country_code" => nil, "teacher_catchment_synced_to_ecf" => false, + "training_status" => "active", "ukprn" => nil, "primary_establishment" => false, "number_of_pupils" => 0, diff --git a/spec/features/journeys/happy_paths/when_outside_of_catchment_area_spec.rb b/spec/features/journeys/happy_paths/when_outside_of_catchment_area_spec.rb index 0c595aa976..c3a98675db 100644 --- a/spec/features/journeys/happy_paths/when_outside_of_catchment_area_spec.rb +++ b/spec/features/journeys/happy_paths/when_outside_of_catchment_area_spec.rb @@ -132,6 +132,7 @@ def run_scenario(js:) "teacher_catchment_country" => nil, "teacher_catchment_iso_country_code" => nil, "teacher_catchment_synced_to_ecf" => false, + "training_status" => "active", "ukprn" => nil, "primary_establishment" => false, "number_of_pupils" => 0, diff --git a/spec/features/journeys/happy_paths/when_previously_funded_spec.rb b/spec/features/journeys/happy_paths/when_previously_funded_spec.rb index 20aa150cc0..3f0c05f86d 100644 --- a/spec/features/journeys/happy_paths/when_previously_funded_spec.rb +++ b/spec/features/journeys/happy_paths/when_previously_funded_spec.rb @@ -191,6 +191,7 @@ def run_scenario(js:) "teacher_catchment_country" => nil, "teacher_catchment_iso_country_code" => nil, "teacher_catchment_synced_to_ecf" => false, + "training_status" => "active", "ukprn" => nil, "primary_establishment" => false, "number_of_pupils" => 0, diff --git a/spec/features/journeys/happy_paths/when_working_at_an_eligible_primary_school_spec.rb b/spec/features/journeys/happy_paths/when_working_at_an_eligible_primary_school_spec.rb index ce5f49f91a..e9c531c881 100644 --- a/spec/features/journeys/happy_paths/when_working_at_an_eligible_primary_school_spec.rb +++ b/spec/features/journeys/happy_paths/when_working_at_an_eligible_primary_school_spec.rb @@ -178,6 +178,7 @@ def run_scenario(js:) "teacher_catchment_country" => nil, "teacher_catchment_iso_country_code" => nil, "teacher_catchment_synced_to_ecf" => false, + "training_status" => "active", "ukprn" => nil, "primary_establishment" => true, "number_of_pupils" => 150, diff --git a/spec/features/journeys/happy_paths/while_not_currently_working_at_school_spec.rb b/spec/features/journeys/happy_paths/while_not_currently_working_at_school_spec.rb index 634eaaa378..7ae5b3e8f1 100644 --- a/spec/features/journeys/happy_paths/while_not_currently_working_at_school_spec.rb +++ b/spec/features/journeys/happy_paths/while_not_currently_working_at_school_spec.rb @@ -140,6 +140,7 @@ def run_scenario(*) "teacher_catchment_country" => nil, "teacher_catchment_iso_country_code" => nil, "teacher_catchment_synced_to_ecf" => false, + "training_status" => "active", "ukprn" => nil, "primary_establishment" => false, "number_of_pupils" => 0, diff --git a/spec/features/journeys/happy_paths/while_working_at_private_childcare_provider_but_not_a_nursery_spec.rb b/spec/features/journeys/happy_paths/while_working_at_private_childcare_provider_but_not_a_nursery_spec.rb index 9c33865906..a99b82f039 100644 --- a/spec/features/journeys/happy_paths/while_working_at_private_childcare_provider_but_not_a_nursery_spec.rb +++ b/spec/features/journeys/happy_paths/while_working_at_private_childcare_provider_but_not_a_nursery_spec.rb @@ -165,6 +165,7 @@ def run_scenario(js:) "teacher_catchment_country" => nil, "teacher_catchment_iso_country_code" => nil, "teacher_catchment_synced_to_ecf" => false, + "training_status" => "active", "ukprn" => nil, "primary_establishment" => false, "number_of_pupils" => 0, diff --git a/spec/features/journeys/happy_paths/while_working_at_private_nursery_spec.rb b/spec/features/journeys/happy_paths/while_working_at_private_nursery_spec.rb index e8c796fad8..f6102018cc 100644 --- a/spec/features/journeys/happy_paths/while_working_at_private_nursery_spec.rb +++ b/spec/features/journeys/happy_paths/while_working_at_private_nursery_spec.rb @@ -167,6 +167,7 @@ def run_scenario(js:) "teacher_catchment_country" => nil, "teacher_catchment_iso_country_code" => nil, "teacher_catchment_synced_to_ecf" => false, + "training_status" => "active", "ukprn" => nil, "primary_establishment" => false, "number_of_pupils" => 0, diff --git a/spec/features/journeys/happy_paths/while_working_at_public_nursery_spec.rb b/spec/features/journeys/happy_paths/while_working_at_public_nursery_spec.rb index 533c6ae1e8..bbdb69f74e 100644 --- a/spec/features/journeys/happy_paths/while_working_at_public_nursery_spec.rb +++ b/spec/features/journeys/happy_paths/while_working_at_public_nursery_spec.rb @@ -162,6 +162,7 @@ def run_scenario(js:) "teacher_catchment_country" => nil, "teacher_catchment_iso_country_code" => nil, "teacher_catchment_synced_to_ecf" => false, + "training_status" => "active", "ukprn" => nil, "primary_establishment" => false, "number_of_pupils" => nil, diff --git a/spec/features/journeys/happy_paths/while_working_in_neither_a_school_nor_childcare_spec.rb b/spec/features/journeys/happy_paths/while_working_in_neither_a_school_nor_childcare_spec.rb index 3ef0cdd8e9..cdbcccefbc 100644 --- a/spec/features/journeys/happy_paths/while_working_in_neither_a_school_nor_childcare_spec.rb +++ b/spec/features/journeys/happy_paths/while_working_in_neither_a_school_nor_childcare_spec.rb @@ -139,6 +139,7 @@ def run_scenario(*) "teacher_catchment_country" => nil, "teacher_catchment_iso_country_code" => nil, "teacher_catchment_synced_to_ecf" => false, + "training_status" => "active", "ukprn" => nil, "primary_establishment" => false, "number_of_pupils" => 0, diff --git a/spec/features/journeys/sad_paths/applying_for_ehco_but_not_new_headteacher_spec.rb b/spec/features/journeys/sad_paths/applying_for_ehco_but_not_new_headteacher_spec.rb index 682a2f0360..21f0cd4c9f 100644 --- a/spec/features/journeys/sad_paths/applying_for_ehco_but_not_new_headteacher_spec.rb +++ b/spec/features/journeys/sad_paths/applying_for_ehco_but_not_new_headteacher_spec.rb @@ -169,6 +169,7 @@ def run_scenario(js:) "teacher_catchment_country" => nil, "teacher_catchment_iso_country_code" => nil, "teacher_catchment_synced_to_ecf" => false, + "training_status" => "active", "ukprn" => nil, "primary_establishment" => false, "number_of_pupils" => nil, diff --git a/spec/features/journeys/sad_paths/lead_mentor_journey_with_incorrect_course_spec.rb b/spec/features/journeys/sad_paths/lead_mentor_journey_with_incorrect_course_spec.rb index f7d9109eaa..b42a068dae 100644 --- a/spec/features/journeys/sad_paths/lead_mentor_journey_with_incorrect_course_spec.rb +++ b/spec/features/journeys/sad_paths/lead_mentor_journey_with_incorrect_course_spec.rb @@ -185,6 +185,7 @@ def run_scenario(js:) "teacher_catchment_country" => nil, "teacher_catchment_iso_country_code" => nil, "teacher_catchment_synced_to_ecf" => false, + "training_status" => "active", "ukprn" => nil, "primary_establishment" => false, "number_of_pupils" => 0, diff --git a/spec/features/journeys/sad_paths/works_in_childcare_but_not_in_england_spec.rb b/spec/features/journeys/sad_paths/works_in_childcare_but_not_in_england_spec.rb index 4cde497205..35eaf4eaae 100644 --- a/spec/features/journeys/sad_paths/works_in_childcare_but_not_in_england_spec.rb +++ b/spec/features/journeys/sad_paths/works_in_childcare_but_not_in_england_spec.rb @@ -139,6 +139,7 @@ def run_scenario "teacher_catchment_country" => nil, "teacher_catchment_iso_country_code" => nil, "teacher_catchment_synced_to_ecf" => false, + "training_status" => "active", "ukprn" => nil, "primary_establishment" => false, "number_of_pupils" => 0, diff --git a/spec/lib/services/handle_submission_for_store_spec.rb b/spec/lib/services/handle_submission_for_store_spec.rb index 79cf089e1f..1cbaaaba6d 100644 --- a/spec/lib/services/handle_submission_for_store_spec.rb +++ b/spec/lib/services/handle_submission_for_store_spec.rb @@ -124,6 +124,7 @@ def stable_as_json(record) "teacher_catchment_country" => nil, "teacher_catchment_iso_country_code" => nil, "teacher_catchment_synced_to_ecf" => false, + "training_status" => "active", "ukprn" => school.ukprn, "number_of_pupils" => nil, "primary_establishment" => false, @@ -227,6 +228,7 @@ def stable_as_json(record) "teacher_catchment_country" => nil, "teacher_catchment_iso_country_code" => nil, "teacher_catchment_synced_to_ecf" => false, + "training_status" => "active", "ukprn" => nil, "number_of_pupils" => 0, "primary_establishment" => false, diff --git a/spec/models/application_spec.rb b/spec/models/application_spec.rb index 3a97409524..f0f1195fb5 100644 --- a/spec/models/application_spec.rb +++ b/spec/models/application_spec.rb @@ -11,6 +11,7 @@ it { is_expected.to belong_to(:cohort).optional } it { is_expected.to have_many(:ecf_sync_request_logs).dependent(:destroy) } it { is_expected.to have_many(:participant_id_changes).through(:user) } + it { is_expected.to have_many(:application_states) } end describe "enums" do @@ -51,6 +52,14 @@ rejected: "rejected", ).backed_by_column_of_type(:enum) } + + it { + expect(subject).to define_enum_for(:training_status).with_values( + active: "active", + deferred: "deferred", + withdrawn: "withdrawn", + ).backed_by_column_of_type(:enum) + } end describe "scopes" do diff --git a/spec/models/application_state_spec.rb b/spec/models/application_state_spec.rb new file mode 100644 index 0000000000..fd4c00e7f7 --- /dev/null +++ b/spec/models/application_state_spec.rb @@ -0,0 +1,18 @@ +require "rails_helper" + +RSpec.describe ApplicationState do + describe "relationships" do + it { is_expected.to belong_to(:application) } + it { is_expected.to belong_to(:lead_provider).optional } + end + + describe "enums" do + it { + expect(subject).to define_enum_for(:state).with_values( + active: "active", + deferred: "deferred", + withdrawn: "withdrawn", + ).backed_by_column_of_type(:enum) + } + end +end