From d8294c97f2611ef1733c68c2ec2ee49df847cc7b Mon Sep 17 00:00:00 2001 From: "Leandro C." Date: Wed, 7 Aug 2024 18:27:53 +0100 Subject: [PATCH] [CPDLP-3349] Add accepted at date field to applications (#1558) * [CPDLP-3349] Add accepted at date field to applications * [CPDLP-3349] Fix features specs * [CPDLP-3349] Address PR comments --- app/serializers/api/participant_serializer.rb | 2 +- app/services/applications/accept.rb | 1 + app/services/participants/query.rb | 2 +- ...20240725102353_add_accepted_at_to_applications.rb | 5 +++++ db/schema.rb | 3 ++- spec/factories/applications.rb | 1 + ...able_to_receive_targeted_delivery_funding_spec.rb | 1 + .../happy_paths/basic_registration_journey_spec.rb | 1 + ...ng_do_you_work_in_a_school_from_no_to_yes_spec.rb | 1 + ...g_do_you_work_in_childcare_from_yes_to_no_spec.rb | 1 + ..._from_outside_of_catchment_area_to_inside_spec.rb | 1 + ...pq_to_one_leadprovider_no_longer_supports_spec.rb | 1 + .../funded_ehco_registration_journey_spec.rb | 1 + .../international_teacher_npqh_journey_spec.rb | 1 + .../other_funded_ehco_registration_journey_spec.rb | 1 + ...iously_received_targeted_delivery_funding_spec.rb | 1 + .../via_using_old_name_and_not_headship_spec.rb | 1 + .../journeys/happy_paths/via_using_same_name_spec.rb | 1 + .../when_choose_lead_mentor_course_spec.rb | 1 + .../happy_paths/when_choose_maths_course_spec.rb | 1 + .../when_get_an_identity_returns_no_trn_spec.rb | 1 + ...side_of_catchment_area_crown_dependencies_spec.rb | 1 + .../when_outside_of_catchment_area_spec.rb | 1 + .../happy_paths/when_previously_funded_spec.rb | 1 + ...hen_working_at_an_eligible_primary_school_spec.rb | 1 + .../while_not_currently_working_at_school_spec.rb | 1 + ...vate_childcare_provider_but_not_a_nursery_spec.rb | 1 + .../while_working_at_private_nursery_spec.rb | 1 + .../while_working_at_public_nursery_spec.rb | 1 + ...working_in_neither_a_school_nor_childcare_spec.rb | 1 + ...applying_for_ehco_but_not_new_headteacher_spec.rb | 1 + ...lead_mentor_journey_with_incorrect_course_spec.rb | 1 + .../works_in_childcare_but_not_in_england_spec.rb | 1 + .../lib/services/handle_submission_for_store_spec.rb | 2 ++ .../api/applications_csv_serializer_spec.rb | 6 +++++- spec/serializers/api/participant_serializer_spec.rb | 6 +++--- spec/services/applications/accept_spec.rb | 3 +++ spec/services/participants/query_spec.rb | 12 ++++++++++-- 38 files changed, 61 insertions(+), 9 deletions(-) create mode 100644 db/migrate/20240725102353_add_accepted_at_to_applications.rb diff --git a/app/serializers/api/participant_serializer.rb b/app/serializers/api/participant_serializer.rb index f42dc95a04..53a377e3b8 100644 --- a/app/serializers/api/participant_serializer.rb +++ b/app/serializers/api/participant_serializer.rb @@ -71,7 +71,7 @@ class AttributesSerializer < Blueprinter::Base targeted_delivery_funding_eligibility: application.targeted_delivery_funding_eligibility, withdrawal: withdrawal(application:, lead_provider: options[:lead_provider]), deferral: deferral(application:, lead_provider: options[:lead_provider]), - created_at: application.created_at.rfc3339, + created_at: application.accepted_at.rfc3339, funded_place: application.funded_place, } end diff --git a/app/services/applications/accept.rb b/app/services/applications/accept.rb index 5939a68c39..b1466be685 100644 --- a/app/services/applications/accept.rb +++ b/app/services/applications/accept.rb @@ -54,6 +54,7 @@ def accept_application! opts = { lead_provider_approval_status: "accepted", schedule:, + accepted_at: Time.zone.now, } if cohort&.funding_cap? diff --git a/app/services/participants/query.rb b/app/services/participants/query.rb index dff1aec0af..f31d331ce1 100644 --- a/app/services/participants/query.rb +++ b/app/services/participants/query.rb @@ -57,7 +57,7 @@ def where_from_participant_id_is(from_participant_id) end def order_by - sort_order(sort:, model: User, default: { created_at: :asc }) + sort_order(sort:, model: User, default: { accepted_at: :asc }) end def all_participants diff --git a/db/migrate/20240725102353_add_accepted_at_to_applications.rb b/db/migrate/20240725102353_add_accepted_at_to_applications.rb new file mode 100644 index 0000000000..bf18566f65 --- /dev/null +++ b/db/migrate/20240725102353_add_accepted_at_to_applications.rb @@ -0,0 +1,5 @@ +class AddAcceptedAtToApplications < ActiveRecord::Migration[7.1] + def change + add_column :applications, :accepted_at, :datetime + end +end diff --git a/db/schema.rb b/db/schema.rb index 62924d6a50..e4562e2962 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_07_18_091502) do +ActiveRecord::Schema[7.1].define(version: 2024_07_25_102353) do # These are extensions that must be enabled in order to support this database enable_extension "btree_gin" enable_extension "citext" @@ -109,6 +109,7 @@ t.enum "training_status", default: "active", null: false, enum_type: "application_statuses" t.bigint "schedule_id" t.string "referred_by_return_to_teaching_adviser" + t.datetime "accepted_at" 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" diff --git a/spec/factories/applications.rb b/spec/factories/applications.rb index fccebb80b0..47a1fe8523 100644 --- a/spec/factories/applications.rb +++ b/spec/factories/applications.rb @@ -58,6 +58,7 @@ lead_provider_approval_status { :accepted } schedule { Schedule.find_by(cohort:, course_group: course.course_group) || create(:schedule, course_group: course.course_group, cohort:) } funded_place { !!eligible_for_funding } + accepted_at { Time.zone.now } end trait :rejected do 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 e4815965f2..6d38911581 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 @@ -135,6 +135,7 @@ def run_scenario(js:) ) deep_compare_application_data( + "accepted_at" => nil, "cohort_id" => nil, "course_id" => Course.find_by(identifier: "npq-senior-leadership").id, "schedule_id" => nil, 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 3eaac78a1c..0e91572786 100644 --- a/spec/features/journeys/happy_paths/basic_registration_journey_spec.rb +++ b/spec/features/journeys/happy_paths/basic_registration_journey_spec.rb @@ -153,6 +153,7 @@ def run_scenario(js:) ) deep_compare_application_data( + "accepted_at" => nil, "cohort_id" => nil, "course_id" => Course.find_by(identifier: "npq-headship").id, "schedule_id" => 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 f5b9fef2ca..b30166efb2 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 @@ -176,6 +176,7 @@ def run_scenario(js:) ) deep_compare_application_data( + "accepted_at" => nil, "cohort_id" => nil, "course_id" => Course.find_by(identifier: "npq-senior-leadership").id, "schedule_id" => 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 c1c3902973..ab62cc1bd3 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 @@ -186,6 +186,7 @@ def run_scenario(js:) ) deep_compare_application_data( + "accepted_at" => nil, "cohort_id" => nil, "course_id" => Course.find_by(identifier: "npq-senior-leadership").id, "schedule_id" => nil, 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 07c65ffa97..433e070980 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 @@ -172,6 +172,7 @@ def run_scenario(js:) ) deep_compare_application_data( + "accepted_at" => nil, "cohort_id" => nil, "course_id" => Course.find_by(identifier: "npq-senior-leadership").id, "schedule_id" => 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 932cfd73fe..0a684f23fc 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 @@ -187,6 +187,7 @@ def run_scenario(js:) ) deep_compare_application_data( + "accepted_at" => nil, "cohort_id" => nil, "course_id" => Course.find_by(identifier: "npq-early-years-leadership").id, "schedule_id" => 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 3ea8a9bb8a..e5dfe786a3 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 @@ -157,6 +157,7 @@ def run_scenario(js:) ) deep_compare_application_data( + "accepted_at" => nil, "cohort_id" => nil, "course_id" => Course.find_by(identifier: "npq-early-headship-coaching-offer").id, "schedule_id" => 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 612d938507..b80f7ace22 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 @@ -119,6 +119,7 @@ def run_scenario(*) "uid" => user_uid, ) deep_compare_application_data( + "accepted_at" => nil, "cohort_id" => nil, "course_id" => Course.find_by(identifier: "npq-headship").id, "schedule_id" => nil, 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 4b2f77346b..66cd74bffe 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 @@ -156,6 +156,7 @@ def run_scenario(js:) ) deep_compare_application_data( + "accepted_at" => nil, "cohort_id" => nil, "course_id" => Course.find_by(identifier: "npq-early-headship-coaching-offer").id, "schedule_id" => 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 933690c89b..b53673516b 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 @@ -130,6 +130,7 @@ def run_scenario(js:) ) deep_compare_application_data( + "accepted_at" => nil, "cohort_id" => nil, "course_id" => Course.find_by(identifier: "npq-senior-leadership").id, "schedule_id" => nil, 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 5e002b5758..fab8c6a6b7 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 @@ -120,6 +120,7 @@ def run_scenario(js:) ) deep_compare_application_data( + "accepted_at" => nil, "cohort_id" => nil, "course_id" => Course.find_by(identifier: "npq-senior-leadership").id, "schedule_id" => 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 3f4488c019..34085c5aff 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 @@ -142,6 +142,7 @@ def run_scenario(js:) ) deep_compare_application_data( + "accepted_at" => nil, "cohort_id" => nil, "course_id" => Course.find_by(identifier: "npq-headship").id, "schedule_id" => 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 6a6f449430..ae3c19d719 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 @@ -156,6 +156,7 @@ def run_scenario(js:) ) deep_compare_application_data( + "accepted_at" => nil, "cohort_id" => nil, "course_id" => Course.find_by(identifier: "npq-leading-teaching-development").id, "schedule_id" => nil, 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 d42f5d9c7a..6747577ff9 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 @@ -173,6 +173,7 @@ def run_scenario(*) ) deep_compare_application_data( + "accepted_at" => nil, "cohort_id" => nil, "course_id" => Course.find_by(identifier: "npq-leading-primary-mathematics").id, "schedule_id" => nil, 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 faaaaa92a5..e0bc3f4bba 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 @@ -188,6 +188,7 @@ def run_scenario(js:) ) deep_compare_application_data( + "accepted_at" => nil, "cohort_id" => nil, "course_id" => Course.find_by(identifier: "npq-headship").id, "schedule_id" => 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 8301d642c4..64a2dcb584 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 @@ -111,6 +111,7 @@ def run_scenario(js:) # rubocop:disable Lint/UnusedMethodArgument ) deep_compare_application_data( + "accepted_at" => nil, "cohort_id" => nil, "course_id" => Course.find_by(identifier: "npq-senior-leadership").id, "schedule_id" => nil, 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 132b136c0a..a59df97007 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 @@ -106,6 +106,7 @@ def run_scenario(js:) ) deep_compare_application_data( + "accepted_at" => nil, "cohort_id" => nil, "course_id" => Course.find_by(identifier: "npq-senior-leadership").id, "ecf_id" => nil, 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 146f512284..5934292b7c 100644 --- a/spec/features/journeys/happy_paths/when_previously_funded_spec.rb +++ b/spec/features/journeys/happy_paths/when_previously_funded_spec.rb @@ -170,6 +170,7 @@ def run_scenario(js:) ) deep_compare_application_data( + "accepted_at" => nil, "cohort_id" => nil, "course_id" => Course.find_by(identifier: "npq-early-headship-coaching-offer").id, "schedule_id" => nil, 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 53f363d1e9..8e97cca4fb 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 @@ -157,6 +157,7 @@ def run_scenario(js:) ) deep_compare_application_data( + "accepted_at" => nil, "cohort_id" => nil, "course_id" => Course.find_by(identifier: "npq-headship").id, "schedule_id" => nil, 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 09b08b87ff..cb41d9714f 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 @@ -114,6 +114,7 @@ def run_scenario(*) ) deep_compare_application_data( + "accepted_at" => nil, "cohort_id" => nil, "course_id" => Course.find_by(identifier: "npq-senior-leadership").id, "schedule_id" => nil, 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 24a77ab7f9..7bd47f7cd7 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 @@ -148,6 +148,7 @@ def run_scenario(js:) ) deep_compare_application_data( + "accepted_at" => nil, "cohort_id" => nil, "course_id" => Course.find_by(identifier: "npq-early-years-leadership").id, "schedule_id" => nil, 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 44b6ccc5a9..6229c2d842 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 @@ -146,6 +146,7 @@ def run_scenario(js:) ) deep_compare_application_data( + "accepted_at" => nil, "cohort_id" => nil, "course_id" => Course.find_by(identifier: "npq-early-years-leadership").id, "schedule_id" => nil, 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 99ab4bc12f..ff47716d96 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 @@ -141,6 +141,7 @@ def run_scenario(js:) ) deep_compare_application_data( + "accepted_at" => nil, "cohort_id" => nil, "course_id" => Course.find_by(identifier: "npq-senior-leadership").id, "schedule_id" => 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 daef214518..c4c1e4796b 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 @@ -113,6 +113,7 @@ def run_scenario(*) ) deep_compare_application_data( + "accepted_at" => nil, "cohort_id" => nil, "course_id" => Course.find_by(identifier: "npq-early-years-leadership").id, "schedule_id" => nil, 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 4236c57a6d..3d647ebcff 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 @@ -148,6 +148,7 @@ def run_scenario(js:) ) deep_compare_application_data( + "accepted_at" => nil, "cohort_id" => nil, "course_id" => Course.find_by(identifier: "npq-early-headship-coaching-offer").id, "schedule_id" => 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 252b81771b..64047a0ce1 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 @@ -168,6 +168,7 @@ def run_scenario(js:) ) deep_compare_application_data( + "accepted_at" => nil, "cohort_id" => nil, "course_id" => Course.find_by(identifier: "npq-senior-leadership").id, "schedule_id" => nil, 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 6cea5c408f..5f914f3f05 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 @@ -113,6 +113,7 @@ def run_scenario ) deep_compare_application_data( + "accepted_at" => nil, "cohort_id" => nil, "course_id" => Course.find_by(identifier: "npq-senior-leadership").id, "schedule_id" => nil, diff --git a/spec/lib/services/handle_submission_for_store_spec.rb b/spec/lib/services/handle_submission_for_store_spec.rb index 8d8a93bd57..1d37080ed7 100644 --- a/spec/lib/services/handle_submission_for_store_spec.rb +++ b/spec/lib/services/handle_submission_for_store_spec.rb @@ -139,6 +139,7 @@ def stable_as_json(record) "work_setting" => "a_school", "raw_application_data" => store.except("current_user"), "referred_by_return_to_teaching_adviser" => "no", + "accepted_at" => nil, }) end end @@ -246,6 +247,7 @@ def stable_as_json(record) "work_setting" => "early_years_or_childcare", "raw_application_data" => store.except("current_user"), "referred_by_return_to_teaching_adviser" => "no", + "accepted_at" => nil, }) end end diff --git a/spec/serializers/api/applications_csv_serializer_spec.rb b/spec/serializers/api/applications_csv_serializer_spec.rb index 0b1ceba95e..ce9219e057 100644 --- a/spec/serializers/api/applications_csv_serializer_spec.rb +++ b/spec/serializers/api/applications_csv_serializer_spec.rb @@ -24,7 +24,8 @@ it { expect(first_row.values).to all(be_present) } it "returns expected data", :aggregate_failures do - expect(first_row).to include({ + expect(first_row).to eq({ + id: first_application.ecf_id, course_identifier: first_application.course.identifier, email: first_application.user.email, email_validated: "true", @@ -50,6 +51,9 @@ teacher_catchment_iso_country_code: "GBR", itt_provider: first_application.itt_provider.legal_name, lead_mentor: first_application.lead_mentor.to_s, + cohort: first_application.cohort.start_year.to_s, + created_at: first_application.created_at.rfc3339, + updated_at: first_application.updated_at.rfc3339, }) end diff --git a/spec/serializers/api/participant_serializer_spec.rb b/spec/serializers/api/participant_serializer_spec.rb index 345c61d5e1..d20a15ae91 100644 --- a/spec/serializers/api/participant_serializer_spec.rb +++ b/spec/serializers/api/participant_serializer_spec.rb @@ -129,7 +129,7 @@ targeted_delivery_funding_eligibility: application.targeted_delivery_funding_eligibility, withdrawal: nil, deferral: nil, - created_at: application.created_at.rfc3339, + created_at: application.accepted_at.rfc3339, funded_place: application.funded_place, }.stringify_keys, ]) @@ -155,7 +155,7 @@ date: application.application_states.last.created_at.rfc3339, }, deferral: nil, - created_at: application.created_at.rfc3339, + created_at: application.accepted_at.rfc3339, funded_place: application.funded_place, }.deep_stringify_keys, ]) @@ -182,7 +182,7 @@ reason: application.application_states.last.reason, date: application.application_states.last.created_at.rfc3339, }, - created_at: application.created_at.rfc3339, + created_at: application.accepted_at.rfc3339, funded_place: application.funded_place, }.deep_stringify_keys, ]) diff --git a/spec/services/applications/accept_spec.rb b/spec/services/applications/accept_spec.rb index bca4486ac6..f360f7b7c5 100644 --- a/spec/services/applications/accept_spec.rb +++ b/spec/services/applications/accept_spec.rb @@ -102,6 +102,7 @@ it "rejects other_application" do service.accept expect(application.reload.lead_provider_approval_status).to eql("accepted") + expect(application.reload.accepted_at).to be_within(1.minute).of(Time.zone.now) expect(other_application.reload.lead_provider_approval_status).to eql("rejected") end end @@ -194,6 +195,7 @@ it "does not reject the other course" do service.accept expect(application.reload.lead_provider_approval_status).to eql("accepted") + expect(application.reload.accepted_at).to be_within(1.minute).of(Time.zone.now) expect(other_application.reload.lead_provider_approval_status).to eql("pending") end end @@ -357,6 +359,7 @@ expect(service.accept).to be_truthy expect(service.application.lead_provider_approval_status).to eql("accepted") expect(service.application.schedule).to eql(new_schedule) + expect(service.application.accepted_at).to be_within(1.minute).of(Time.zone.now) application_state = ApplicationState.first expect(application_state.lead_provider).to eql(lead_provider) diff --git a/spec/services/participants/query_spec.rb b/spec/services/participants/query_spec.rb index cc5beeaafc..cb0ad1ed06 100644 --- a/spec/services/participants/query_spec.rb +++ b/spec/services/participants/query_spec.rb @@ -15,7 +15,7 @@ expect(query.participants).to contain_exactly(participant1, participant2) end - it "orders participants by created_at in ascending order" do + it "orders participants by accepted_at in ascending order" do participant3 = travel_to(1.minute.ago) { create(:user, :with_application, lead_provider:) } expect(query.participants).to eq([participant3, participant1, participant2]) @@ -183,7 +183,15 @@ subject(:participants) { query.participants } - it { is_expected.to eq([participant1, participant2, participant3]) } + before do + participant1.applications.first.update!(accepted_at: 1.day.ago) + participant2.applications.first.update!(accepted_at: 10.days.ago) + participant3.applications.first.update!(accepted_at: 2.days.ago) + end + + it "orders applications by accepted_at in ascending order" do + expect(query.participants).to eq([participant2, participant3, participant1]) + end context "when sorting by created at, descending" do let(:sort) { "-created_at" }