From 1380d7fc641a2ced5bbab2829a3d1d569ef03c4d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 07:34:25 +0000 Subject: [PATCH 01/27] Bump brakeman from 6.2.2 to 7.0.0 Bumps [brakeman](https://github.com/presidentbeef/brakeman) from 6.2.2 to 7.0.0. - [Release notes](https://github.com/presidentbeef/brakeman/releases) - [Changelog](https://github.com/presidentbeef/brakeman/blob/main/CHANGES.md) - [Commits](https://github.com/presidentbeef/brakeman/compare/v6.2.2...v7.0.0) --- updated-dependencies: - dependency-name: brakeman dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index ae722a50b0..48d256a69f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -146,7 +146,7 @@ GEM bindex (0.8.1) binding_of_caller (1.0.1) debug_inspector (>= 1.2.0) - brakeman (6.2.2) + brakeman (7.0.0) racc breasal (0.0.1) builder (3.3.0) From 0304d2a2f22381bed8170bff1930fbedba1c12ca Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 07:35:26 +0000 Subject: [PATCH 02/27] Bump database_consistency from 1.7.26 to 2.0.3 Bumps [database_consistency](https://github.com/djezzzl/database_consistency) from 1.7.26 to 2.0.3. - [Changelog](https://github.com/djezzzl/database_consistency/blob/master/CHANGELOG.md) - [Commits](https://github.com/djezzzl/database_consistency/compare/v1.7.26...v2.0.3) --- updated-dependencies: - dependency-name: database_consistency dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index ae722a50b0..75cb99f60b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -165,7 +165,7 @@ GEM climate_control (1.2.0) coderay (1.1.3) concurrent-ruby (1.3.4) - connection_pool (2.4.1) + connection_pool (2.5.0) crack (1.0.0) bigdecimal rexml @@ -176,7 +176,7 @@ GEM cssbundling-rails (1.4.1) railties (>= 6.0.0) csv (3.3.2) - database_consistency (1.7.26) + database_consistency (2.0.3) activerecord (>= 3.2) date (3.4.1) debug (1.10.0) @@ -329,7 +329,7 @@ GEM rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) lockbox (2.0.1) - logger (1.6.4) + logger (1.6.5) loofah (2.24.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) From b4646a19e65d6107d0bf9487037109b66c0ca483 Mon Sep 17 00:00:00 2001 From: vipin-dfe Date: Mon, 13 Jan 2025 12:52:56 +0000 Subject: [PATCH 03/27] Enable federated auth for big query in production --- terraform/workspace-variables/production.tfvars.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/workspace-variables/production.tfvars.json b/terraform/workspace-variables/production.tfvars.json index 83fb19df4b..728c36ff01 100644 --- a/terraform/workspace-variables/production.tfvars.json +++ b/terraform/workspace-variables/production.tfvars.json @@ -80,6 +80,6 @@ "start_minute": 0 }, "enable_logit": true, - "enable_dfe_analytics_federated_auth": false, + "enable_dfe_analytics_federated_auth": true, "dataset_name": "production_dataset" } From 95e2c1de99e0e19971de92e25803ce375b8092da Mon Sep 17 00:00:00 2001 From: Marc Sardon Date: Mon, 13 Jan 2025 13:32:38 +0000 Subject: [PATCH 04/27] Add missing index to AlertRuns There is a query counting on the AlertRuns for today and, given the size of the table, it takes long time due to the lack of an index for the date field. --- db/schema.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/schema.rb b/db/schema.rb index 9d109aaa15..f986265c8f 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.2].define(version: 2025_01_07_110428) do +ActiveRecord::Schema[7.2].define(version: 2025_01_13_131902) do # These are extensions that must be enabled in order to support this database enable_extension "btree_gist" enable_extension "citext" @@ -56,6 +56,7 @@ t.datetime "created_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false t.integer "status", default: 0 + t.index ["run_on"], name: "index_alert_runs_on_run_on" t.index ["subscription_id"], name: "index_alert_runs_on_subscription_id" end From 8e5e9183df6c09715ee530948b38a932345ea1ba Mon Sep 17 00:00:00 2001 From: Stephen Dicks Date: Mon, 13 Jan 2025 14:22:34 +0000 Subject: [PATCH 05/27] convert todays subscription alert run list to a set for performance (#7402) --- app/jobs/alert_email/base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/jobs/alert_email/base.rb b/app/jobs/alert_email/base.rb index ed4214de6a..6a524214ac 100644 --- a/app/jobs/alert_email/base.rb +++ b/app/jobs/alert_email/base.rb @@ -8,7 +8,7 @@ def perform # really fast (1 week's worth of vacancies is around 2000, so not worth leaving on disk for each of 100k daily subscriptions default_scope = Vacancy.includes(:organisations).live.order(publish_on: :desc).search_by_filter(from_date: from_date, to_date: Date.current) - already_run_ids = AlertRun.for_today.pluck(:subscription_id) + already_run_ids = Set.new AlertRun.for_today.pluck(:subscription_id) subscriptions.find_each.reject { |sub| already_run_ids.include?(sub.id) }.each do |subscription| vacancies = subscription.vacancies_matching(default_scope).first(MAXIMUM_RESULTS_PER_RUN) From 859c004c0b29d07ca98418e591e01a4ab3c71cc5 Mon Sep 17 00:00:00 2001 From: Marc Sardon Date: Mon, 13 Jan 2025 15:17:27 +0000 Subject: [PATCH 06/27] Fix: Add missing migration file Forgot to include this file in the commit modifying the DB schema. --- .../20250113131902_add_index_to_alert_runs_run_on.rb | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 db/migrate/20250113131902_add_index_to_alert_runs_run_on.rb diff --git a/db/migrate/20250113131902_add_index_to_alert_runs_run_on.rb b/db/migrate/20250113131902_add_index_to_alert_runs_run_on.rb new file mode 100644 index 0000000000..299f05fa88 --- /dev/null +++ b/db/migrate/20250113131902_add_index_to_alert_runs_run_on.rb @@ -0,0 +1,7 @@ +class AddIndexToAlertRunsRunOn < ActiveRecord::Migration[7.2] + disable_ddl_transaction! + + def change + add_index :alert_runs, :run_on, algorithm: :concurrently + end +end From 13c0a838f80581b848cc1f00ee237f9fb46cda92 Mon Sep 17 00:00:00 2001 From: Kyle MacPherson Date: Tue, 7 Jan 2025 16:06:36 +0000 Subject: [PATCH 07/27] Add body text to cpd new and edit page on jobseeker profiles --- .../jobseekers/profiles/training_and_cpds/edit.html.slim | 8 ++++++++ .../jobseekers/profiles/training_and_cpds/new.html.slim | 8 ++++++++ config/locales/jobseekers.yml | 9 +++++++++ 3 files changed, 25 insertions(+) diff --git a/app/views/jobseekers/profiles/training_and_cpds/edit.html.slim b/app/views/jobseekers/profiles/training_and_cpds/edit.html.slim index 846f369e07..e5a52381bf 100644 --- a/app/views/jobseekers/profiles/training_and_cpds/edit.html.slim +++ b/app/views/jobseekers/profiles/training_and_cpds/edit.html.slim @@ -6,6 +6,14 @@ h1.govuk-heading-xl = "Edit training and continuing professional development (CPD)" = form_for form, url: jobseekers_profile_training_and_cpd_path, method: :put do |f| + p.govuk-body = t(".description") + p.govuk-body = t(".example_intro") + ul.govuk-list.govuk-list--bullet + li = t(".example1") + li = t(".example2") + li = t(".example3") + li = t(".example4") + = f.govuk_error_summary = f.govuk_text_field :name, label: { size: "s" }, aria: { required: true } diff --git a/app/views/jobseekers/profiles/training_and_cpds/new.html.slim b/app/views/jobseekers/profiles/training_and_cpds/new.html.slim index 42b84846ca..c04fcead4c 100644 --- a/app/views/jobseekers/profiles/training_and_cpds/new.html.slim +++ b/app/views/jobseekers/profiles/training_and_cpds/new.html.slim @@ -6,6 +6,14 @@ h1.govuk-heading-xl = "Add training and continuing professional development (CPD)" = form_for form, url: jobseekers_profile_training_and_cpds_path(profile), method: :post do |f| + p.govuk-body = t(".description") + p.govuk-body = t(".example_intro") + ul.govuk-list.govuk-list--bullet + li = t(".example1") + li = t(".example2") + li = t(".example3") + li = t(".example4") + = f.govuk_error_summary = f.govuk_text_field :name, label: { size: "s" }, aria: { required: true } diff --git a/config/locales/jobseekers.yml b/config/locales/jobseekers.yml index 7c1c09053e..f92af0d9dd 100644 --- a/config/locales/jobseekers.yml +++ b/config/locales/jobseekers.yml @@ -766,9 +766,18 @@ en: summary: about_you_title: About You training_and_cpds: + training_shared: &training_shared + description: Include any training you've completed within the last 3 years relevant to the role you're applying for. + example_intro: "For example you could include:" + example1: safeguarding training + example2: Prevent duty training + example3: first aid courses + example4: Team Teach new: + <<: *training_shared hint: For example, 1998 edit: + <<: *training_shared hint: For example, 1998 destroy: success: Training deleted From d1317d0647cd044bddb52075bd04167803902b4f Mon Sep 17 00:00:00 2001 From: Kyle MacPherson Date: Wed, 8 Jan 2025 12:02:24 +0000 Subject: [PATCH 08/27] Add course length column to training_and_cpds table --- .../20250108105814_add_course_length_to_training_and_cpds.rb | 5 +++++ db/schema.rb | 1 + 2 files changed, 6 insertions(+) create mode 100644 db/migrate/20250108105814_add_course_length_to_training_and_cpds.rb diff --git a/db/migrate/20250108105814_add_course_length_to_training_and_cpds.rb b/db/migrate/20250108105814_add_course_length_to_training_and_cpds.rb new file mode 100644 index 0000000000..66954ae0fb --- /dev/null +++ b/db/migrate/20250108105814_add_course_length_to_training_and_cpds.rb @@ -0,0 +1,5 @@ +class AddCourseLengthToTrainingAndCpds < ActiveRecord::Migration[7.2] + def change + add_column :training_and_cpds, :course_length, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index f986265c8f..abe02ee18a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -607,6 +607,7 @@ t.datetime "updated_at", null: false t.uuid "jobseeker_profile_id" t.uuid "job_application_id" + t.string "course_length" t.index ["job_application_id"], name: "index_training_and_cpds_on_job_application_id" t.index ["jobseeker_profile_id"], name: "index_training_and_cpds_on_jobseeker_profile_id" end From e0f47cef23573525bd520e8580bb2c5a4fb20949 Mon Sep 17 00:00:00 2001 From: Kyle MacPherson Date: Wed, 8 Jan 2025 12:04:05 +0000 Subject: [PATCH 09/27] Add course length question to jobseeker profile flow --- .../job_applications/training_and_cpds_controller.rb | 4 ++-- .../jobseekers/profiles/training_and_cpds_controller.rb | 4 ++-- app/form_models/jobseekers/training_and_cpd_form.rb | 4 ++-- .../profiles/training_and_cpds/confirm_destroy.html.slim | 4 ++++ .../jobseekers/profiles/training_and_cpds/edit.html.slim | 3 ++- .../jobseekers/profiles/training_and_cpds/new.html.slim | 1 + .../training_and_cpds/_training_and_cpds.html.slim | 5 +++++ config/locales/forms.yml | 1 + 8 files changed, 19 insertions(+), 7 deletions(-) diff --git a/app/controllers/jobseekers/job_applications/training_and_cpds_controller.rb b/app/controllers/jobseekers/job_applications/training_and_cpds_controller.rb index 159a4e9a73..93f20c084c 100644 --- a/app/controllers/jobseekers/job_applications/training_and_cpds_controller.rb +++ b/app/controllers/jobseekers/job_applications/training_and_cpds_controller.rb @@ -41,13 +41,13 @@ def form_attributes when "create", "update" training_and_cpd_form_params when "edit" - training_and_cpd.slice(:name, :provider, :grade, :year_awarded) + training_and_cpd.slice(:name, :provider, :grade, :year_awarded, :course_length) end end def training_and_cpd_form_params params.require(:jobseekers_training_and_cpd_form) - .permit(:name, :provider, :grade, :year_awarded) + .permit(:name, :provider, :grade, :year_awarded, :course_length) end def training_and_cpd diff --git a/app/controllers/jobseekers/profiles/training_and_cpds_controller.rb b/app/controllers/jobseekers/profiles/training_and_cpds_controller.rb index 6e89ff7c11..27eae654d3 100644 --- a/app/controllers/jobseekers/profiles/training_and_cpds_controller.rb +++ b/app/controllers/jobseekers/profiles/training_and_cpds_controller.rb @@ -41,13 +41,13 @@ def form_attributes when "create", "update" training_and_cpd_form_params when "edit" - training_and_cpd.slice(:name, :provider, :grade, :year_awarded) + training_and_cpd.slice(:name, :provider, :grade, :year_awarded, :course_length) end end def training_and_cpd_form_params params.require(:jobseekers_training_and_cpd_form) - .permit(:name, :provider, :grade, :year_awarded) + .permit(:name, :provider, :grade, :year_awarded, :course_length) end def training_and_cpd diff --git a/app/form_models/jobseekers/training_and_cpd_form.rb b/app/form_models/jobseekers/training_and_cpd_form.rb index 21329ac407..20aff7082c 100644 --- a/app/form_models/jobseekers/training_and_cpd_form.rb +++ b/app/form_models/jobseekers/training_and_cpd_form.rb @@ -1,7 +1,7 @@ class Jobseekers::TrainingAndCpdForm include ActiveModel::Model - attr_accessor :name, :provider, :grade, :year_awarded + attr_accessor :name, :provider, :grade, :year_awarded, :course_length - validates :name, :provider, :year_awarded, presence: true + validates :name, :provider, :year_awarded, :course_length, presence: true end diff --git a/app/views/jobseekers/profiles/training_and_cpds/confirm_destroy.html.slim b/app/views/jobseekers/profiles/training_and_cpds/confirm_destroy.html.slim index 5978d403c1..0b812107b3 100644 --- a/app/views/jobseekers/profiles/training_and_cpds/confirm_destroy.html.slim +++ b/app/views/jobseekers/profiles/training_and_cpds/confirm_destroy.html.slim @@ -16,6 +16,10 @@ - summary_list.with_row do |row| - row.with_key text: t("helpers.label.jobseekers_training_and_cpd_form.provider") - row.with_value text: training_and_cpd.provider + + - summary_list.with_row do |row| + - row.with_key text: t("helpers.label.jobseekers_training_and_cpd_form.course_length") + - row.with_value text: training.course_length - summary_list.with_row do |row| - row.with_key text: t("helpers.label.jobseekers_training_and_cpd_form.grade") diff --git a/app/views/jobseekers/profiles/training_and_cpds/edit.html.slim b/app/views/jobseekers/profiles/training_and_cpds/edit.html.slim index e5a52381bf..ec481f15b8 100644 --- a/app/views/jobseekers/profiles/training_and_cpds/edit.html.slim +++ b/app/views/jobseekers/profiles/training_and_cpds/edit.html.slim @@ -13,11 +13,12 @@ li = t(".example2") li = t(".example3") li = t(".example4") - + = f.govuk_error_summary = f.govuk_text_field :name, label: { size: "s" }, aria: { required: true } = f.govuk_text_field :provider, label: { size: "s" }, aria: { required: true } + = f.govuk_text_field :course_length, label: { size: "s" }, aria: { required: true } = f.govuk_text_field :grade, label: { size: "s" } = f.govuk_text_field :year_awarded, label: { size: "s" }, type: "number", width: 4, hint: { text: t(".hint") } = f.govuk_submit t("buttons.save_and_continue") diff --git a/app/views/jobseekers/profiles/training_and_cpds/new.html.slim b/app/views/jobseekers/profiles/training_and_cpds/new.html.slim index c04fcead4c..984045ecf7 100644 --- a/app/views/jobseekers/profiles/training_and_cpds/new.html.slim +++ b/app/views/jobseekers/profiles/training_and_cpds/new.html.slim @@ -18,6 +18,7 @@ = f.govuk_text_field :name, label: { size: "s" }, aria: { required: true } = f.govuk_text_field :provider, label: { size: "s" }, aria: { required: true } + = f.govuk_text_field :course_length, label: { size: "s" }, aria: { required: true } = f.govuk_text_field :grade, label: { size: "s" } = f.govuk_text_field :year_awarded, label: { size: "s" }, type: "number", width: 4, hint: { text: t(".hint") } = f.govuk_submit t("buttons.save_and_continue") diff --git a/app/views/jobseekers/training_and_cpds/_training_and_cpds.html.slim b/app/views/jobseekers/training_and_cpds/_training_and_cpds.html.slim index 5e7364b2b6..543eca1ef8 100644 --- a/app/views/jobseekers/training_and_cpds/_training_and_cpds.html.slim +++ b/app/views/jobseekers/training_and_cpds/_training_and_cpds.html.slim @@ -10,6 +10,11 @@ - row.with_key text: t("helpers.label.jobseekers_training_and_cpd_form.provider") - row.with_value text: training.provider + - if training.course_length.present? + - summary_list.with_row do |row| + - row.with_key text: t("helpers.label.jobseekers_training_and_cpd_form.course_length") + - row.with_value text: training.course_length + - summary_list.with_row do |row| - row.with_key text: t("helpers.label.jobseekers_training_and_cpd_form.grade") - row.with_value text: training.grade diff --git a/config/locales/forms.yml b/config/locales/forms.yml index 6ae7a4e49e..a9f50a0c5e 100644 --- a/config/locales/forms.yml +++ b/config/locales/forms.yml @@ -618,6 +618,7 @@ en: grade: Grade (optional) year_awarded: Year awarded year_completed_hint: For example, 1998 + course_length: Course length personal_details_form: From 598af07f359ee7c3ef13d6e1a3e795b536513a98 Mon Sep 17 00:00:00 2001 From: Kyle MacPherson Date: Wed, 8 Jan 2025 12:16:04 +0000 Subject: [PATCH 10/27] Move training_shared so it's in scope for both jobseeker_profile and job_applications --- config/locales/jobseekers.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/config/locales/jobseekers.yml b/config/locales/jobseekers.yml index f92af0d9dd..20ff449363 100644 --- a/config/locales/jobseekers.yml +++ b/config/locales/jobseekers.yml @@ -88,6 +88,14 @@ en: success: Thank you for your feedback on your job alert update: success: Thank you for providing additional feedback on your job alert + shared: + training_shared: &training_shared + description: Include any training you've completed within the last 3 years relevant to the role you're applying for. + example_intro: "For example you could include:" + example1: safeguarding training + example2: Prevent duty training + example3: first aid courses + example4: Team Teach job_applications: apply: Apply for this job applying_for_the_job_heading: Applying for the job @@ -251,10 +259,12 @@ en: step_title: Training and continuing professional development (CPD) title: Add training and continuing professional development (CPD) new: + <<: *training_shared hint: For example, 1998 caption: Training and continuing professional development (CPD) heading: Add training and continuing professional development (CPD) edit: + <<: *training_shared hint: For example, 1998 caption: Training and continuing professional development (CPD) heading: Edit training and continuing professional development (CPD) @@ -766,13 +776,6 @@ en: summary: about_you_title: About You training_and_cpds: - training_shared: &training_shared - description: Include any training you've completed within the last 3 years relevant to the role you're applying for. - example_intro: "For example you could include:" - example1: safeguarding training - example2: Prevent duty training - example3: first aid courses - example4: Team Teach new: <<: *training_shared hint: For example, 1998 From 921d1d9226ac79d29f8766855c6197e2d9de13e4 Mon Sep 17 00:00:00 2001 From: Kyle MacPherson Date: Wed, 8 Jan 2025 14:15:29 +0000 Subject: [PATCH 11/27] Add course_length to job application flow --- app/helpers/pdf_helper.rb | 2 +- .../job_applications/build/training_and_cpds.html.slim | 2 +- .../job_applications/training_and_cpds/edit.html.slim | 8 ++++++++ .../job_applications/training_and_cpds/new.html.slim | 9 +++++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/helpers/pdf_helper.rb b/app/helpers/pdf_helper.rb index cf3f59b837..d44ac0b8dd 100644 --- a/app/helpers/pdf_helper.rb +++ b/app/helpers/pdf_helper.rb @@ -119,7 +119,7 @@ def add_general_qualification_details(pdf, qualification) ["Qualification Name:", qualification.name], ["Institution:", qualification.institution], ["Grade:", qualification.grade], - ["Year Awarded:", qualification.year], + ["Date completed:", qualification.year], ].reject { |row| row[1].blank? } render_table(pdf, general_qualification_data) diff --git a/app/views/jobseekers/job_applications/build/training_and_cpds.html.slim b/app/views/jobseekers/job_applications/build/training_and_cpds.html.slim index 88390da99e..f5b301ad82 100644 --- a/app/views/jobseekers/job_applications/build/training_and_cpds.html.slim +++ b/app/views/jobseekers/job_applications/build/training_and_cpds.html.slim @@ -12,7 +12,7 @@ = render DetailComponent.new title: training.name do |detail| - detail.with_body do = govuk_summary_list classes: "govuk-!-margin-bottom-0" do |summary_list| - - attributes = %w[name provider grade year_awarded] + - attributes = %w[name provider grade year_awarded course_length] - attributes.each do |attribute| - if training[attribute].present? - summary_list.with_row do |row| diff --git a/app/views/jobseekers/job_applications/training_and_cpds/edit.html.slim b/app/views/jobseekers/job_applications/training_and_cpds/edit.html.slim index c0694273c5..44d29cf713 100644 --- a/app/views/jobseekers/job_applications/training_and_cpds/edit.html.slim +++ b/app/views/jobseekers/job_applications/training_and_cpds/edit.html.slim @@ -6,12 +6,20 @@ h1.govuk-heading-xl = t(".heading") = form_for form, url: jobseekers_job_application_training_and_cpd_path, method: :put do |f| + p.govuk-body = t(".description") + p.govuk-body = t(".example_intro") + ul.govuk-list.govuk-list--bullet + li = t(".example1") + li = t(".example2") + li = t(".example3") + li = t(".example4") = f.govuk_error_summary = f.govuk_text_field :name, label: { size: "s" }, aria: { required: true } = f.govuk_text_field :provider, label: { size: "s" }, aria: { required: true } = f.govuk_text_field :grade, label: { size: "s" } = f.govuk_text_field :year_awarded, label: { size: "s" }, type: "number", width: 4, hint: { text: t(".hint") } + = f.govuk_text_field :course_length, label: { size: "s" }, aria: { required: true } = f.govuk_submit t("buttons.save_and_continue") .govuk-button-group diff --git a/app/views/jobseekers/job_applications/training_and_cpds/new.html.slim b/app/views/jobseekers/job_applications/training_and_cpds/new.html.slim index 7169723804..13a05614ac 100644 --- a/app/views/jobseekers/job_applications/training_and_cpds/new.html.slim +++ b/app/views/jobseekers/job_applications/training_and_cpds/new.html.slim @@ -6,10 +6,19 @@ h1.govuk-heading-xl = t(".heading") = form_for form, url: jobseekers_job_application_training_and_cpds_path(job_application), method: :post do |f| + p.govuk-body = t(".description") + p.govuk-body = t(".example_intro") + ul.govuk-list.govuk-list--bullet + li = t(".example1") + li = t(".example2") + li = t(".example3") + li = t(".example4") + = f.govuk_error_summary = f.govuk_text_field :name, label: { size: "s" }, aria: { required: true } = f.govuk_text_field :provider, label: { size: "s" }, aria: { required: true } + = f.govuk_text_field :course_length, label: { size: "s" }, aria: { required: true } = f.govuk_text_field :grade, label: { size: "s" } = f.govuk_text_field :year_awarded, label: { size: "s" }, type: "number", width: 4, hint: { text: t(".hint") } = f.govuk_submit t("buttons.save_and_continue") From 552ae6830f6792d099dc7637c5ccf46b25d01afe Mon Sep 17 00:00:00 2001 From: Kyle MacPherson Date: Thu, 9 Jan 2025 15:55:58 +0000 Subject: [PATCH 12/27] Add tests for new course length question on training and cpds forms --- .../confirm_destroy.html.slim | 2 +- config/locales/activerecord.yml | 2 ++ spec/factories/training_and_cpds.rb | 1 + .../jobseekers/training_and_cpd_form_spec.rb | 1 + ..._and_cpds_to_their_job_application_spec.rb | 28 +++++++++++-------- ..._can_add_training_to_their_profile_spec.rb | 26 ++++++++++------- 6 files changed, 38 insertions(+), 22 deletions(-) diff --git a/app/views/jobseekers/profiles/training_and_cpds/confirm_destroy.html.slim b/app/views/jobseekers/profiles/training_and_cpds/confirm_destroy.html.slim index 0b812107b3..0e8b7d8186 100644 --- a/app/views/jobseekers/profiles/training_and_cpds/confirm_destroy.html.slim +++ b/app/views/jobseekers/profiles/training_and_cpds/confirm_destroy.html.slim @@ -19,7 +19,7 @@ - summary_list.with_row do |row| - row.with_key text: t("helpers.label.jobseekers_training_and_cpd_form.course_length") - - row.with_value text: training.course_length + - row.with_value text: training_and_cpd.course_length - summary_list.with_row do |row| - row.with_key text: t("helpers.label.jobseekers_training_and_cpd_form.grade") diff --git a/config/locales/activerecord.yml b/config/locales/activerecord.yml index 2769526984..b6c7635c98 100644 --- a/config/locales/activerecord.yml +++ b/config/locales/activerecord.yml @@ -734,6 +734,8 @@ en: blank: Enter the name of the provider of the training year_awarded: blank: Enter the year the course or training was awarded + course_length: + blank: Enter the length of the course jobseekers/account_transfer_form: attributes: email: diff --git a/spec/factories/training_and_cpds.rb b/spec/factories/training_and_cpds.rb index 957930e973..958c4c7e4d 100644 --- a/spec/factories/training_and_cpds.rb +++ b/spec/factories/training_and_cpds.rb @@ -4,6 +4,7 @@ provider { "TeachTrainLtd" } grade { "Pass" } year_awarded { "2020" } + course_length { "1 year" } jobseeker_profile { nil } job_application { nil } diff --git a/spec/form_models/jobseekers/training_and_cpd_form_spec.rb b/spec/form_models/jobseekers/training_and_cpd_form_spec.rb index 1f572ceb5f..c12c52770f 100644 --- a/spec/form_models/jobseekers/training_and_cpd_form_spec.rb +++ b/spec/form_models/jobseekers/training_and_cpd_form_spec.rb @@ -4,4 +4,5 @@ it { is_expected.to validate_presence_of(:name) } it { is_expected.to validate_presence_of(:provider) } it { is_expected.to validate_presence_of(:year_awarded) } + it { is_expected.to validate_presence_of(:course_length) } end diff --git a/spec/system/jobseekers/jobseeker_can_add_training_and_cpds_to_their_job_application_spec.rb b/spec/system/jobseekers/jobseeker_can_add_training_and_cpds_to_their_job_application_spec.rb index 0f0b23f14f..f3f094362e 100644 --- a/spec/system/jobseekers/jobseeker_can_add_training_and_cpds_to_their_job_application_spec.rb +++ b/spec/system/jobseekers/jobseeker_can_add_training_and_cpds_to_their_job_application_spec.rb @@ -21,13 +21,14 @@ expect(page).to have_link("Enter the name of the course or training", href: "#jobseekers-training-and-cpd-form-name-field-error") expect(page).to have_link("Enter the name of the provider of the training", href: "#jobseekers-training-and-cpd-form-provider-field-error") expect(page).to have_link("Enter the year the course or training was awarded", href: "#jobseekers-training-and-cpd-form-year-awarded-field-error") + expect(page).to have_link("Enter the length of the course", href: "#jobseekers-training-and-cpd-form-course-length-field-error") end - fill_in_and_submit_training_form("Rock climbing instructional course", "Training org", "A", "2024") + fill_in_and_submit_training_form("Rock climbing instructional course", "Training org", "A", "2024", "6 months") expect(current_path).to eq("/jobseekers/job_applications/#{job_application.id}/build/training_and_cpds") - expect_page_to_have_values("Rock climbing instructional course", "Training org", "A", "2024") + expect_page_to_have_values("Rock climbing instructional course", "Training org", "A", "2024", "6 months") end end @@ -36,16 +37,16 @@ it "allows jobseeker to edit existing training" do visit jobseekers_job_application_build_path(job_application, :training_and_cpds) - expect_page_to_have_values("Rock climbing", "TeachTrainLtd", "Pass", "2020") + expect_page_to_have_values("Rock climbing", "TeachTrainLtd", "Pass", "2020", "1 year") click_link "Change" - fill_in_and_submit_training_form("Choir singing instructional course", "Training org", "A", "2024") + fill_in_and_submit_training_form("Choir singing instructional course", "Training org", "A", "2024", "6 months") expect(current_path).to eq("/jobseekers/job_applications/#{job_application.id}/build/training_and_cpds") - expect_page_to_have_values("Choir singing instructional course", "Training org", "A", "2024") - expect_page_not_to_have_values("Rock climbing", "TeachTrainLtd", "Pass", "2020") + expect_page_to_have_values("Choir singing instructional course", "Training org", "A", "2024", "6 months") + expect_page_not_to_have_values("Rock climbing", "TeachTrainLtd", "Pass", "2020", "1 year") end end @@ -54,7 +55,7 @@ it "allows jobseeker to edit existing training" do visit jobseekers_job_application_build_path(job_application, :training_and_cpds) - expect_page_to_have_values("Rock climbing", "TeachTrainLtd", "Pass", "2020") + expect_page_to_have_values("Rock climbing", "TeachTrainLtd", "Pass", "2020", "1 year") click_link "Delete" @@ -62,19 +63,20 @@ expect(current_path).to eq("/jobseekers/job_applications/#{job_application.id}/build/training_and_cpds") - expect_page_not_to_have_values("Rock climbing", "TeachTrainLtd", "Pass", "2020") + expect_page_not_to_have_values("Rock climbing", "TeachTrainLtd", "Pass", "2020", "1 year") end end - def fill_in_and_submit_training_form(name, provider, grade, year) + def fill_in_and_submit_training_form(name, provider, grade, year, course_length) fill_in "Name", with: name fill_in "Training provider", with: provider fill_in "Grade", with: grade fill_in "Year awarded", with: year + fill_in "Course length", with: course_length click_on "Save and continue" end - def expect_page_to_have_values(name, provider, grade, year) + def expect_page_to_have_values(name, provider, grade, year, course_length) expect(page).to have_css(".govuk-summary-list__key", text: "Name of course or training") expect(page).to have_css(".govuk-summary-list__value", text: name) @@ -86,12 +88,16 @@ def expect_page_to_have_values(name, provider, grade, year) expect(page).to have_css(".govuk-summary-list__key", text: "Year awarded") expect(page).to have_css(".govuk-summary-list__value", text: year) + + expect(page).to have_css(".govuk-summary-list__key", text: "Course length") + expect(page).to have_css(".govuk-summary-list__value", text: course_length) end - def expect_page_not_to_have_values(name, provider, grade, year) + def expect_page_not_to_have_values(name, provider, grade, year, course_length) expect(page).not_to have_css(".govuk-summary-list__value", text: name) expect(page).not_to have_css(".govuk-summary-list__value", text: provider) expect(page).not_to have_css(".govuk-summary-list__value", text: grade) expect(page).not_to have_css(".govuk-summary-list__value", text: year) + expect(page).not_to have_css(".govuk-summary-list__value", text: course_length) end end diff --git a/spec/system/jobseekers/jobseekers_can_add_training_to_their_profile_spec.rb b/spec/system/jobseekers/jobseekers_can_add_training_to_their_profile_spec.rb index 0e59c511ab..5a7f270c1e 100644 --- a/spec/system/jobseekers/jobseekers_can_add_training_to_their_profile_spec.rb +++ b/spec/system/jobseekers/jobseekers_can_add_training_to_their_profile_spec.rb @@ -23,17 +23,18 @@ expect(page).to have_link("Enter the name of the course or training", href: "#jobseekers-training-and-cpd-form-name-field-error") expect(page).to have_link("Enter the name of the provider of the training", href: "#jobseekers-training-and-cpd-form-provider-field-error") expect(page).to have_link("Enter the year the course or training was awarded", href: "#jobseekers-training-and-cpd-form-year-awarded-field-error") + expect(page).to have_link("Enter the length of the course", href: "#jobseekers-training-and-cpd-form-course-length-field-error") end - fill_in_and_submit_training_form("Rock climbing instructional course", "TeachTrain ltd", "A", "2024") + fill_in_and_submit_training_form("Rock climbing instructional course", "TeachTrain ltd", "A", "2024", "6 months") - expect_page_to_have_values("Rock climbing instructional course", "TeachTrain ltd", "A", "2024") + expect_page_to_have_values("Rock climbing instructional course", "TeachTrain ltd", "A", "2024", "6 months") click_link "Return to profile" expect(page).to have_current_path(jobseekers_profile_path) - expect_page_to_have_values("Rock climbing instructional course", "TeachTrain ltd", "A", "2024") + expect_page_to_have_values("Rock climbing instructional course", "TeachTrain ltd", "A", "2024", "6 months") end end @@ -44,21 +45,21 @@ end it "allows jobseeker to edit training" do - expect_page_to_have_values("Rock climbing", "TeachTrainLtd", "Pass", "2020") + expect_page_to_have_values("Rock climbing", "TeachTrainLtd", "Pass", "2020", "1 year") within(".govuk-summary-card__title-wrapper", text: "Rock climbing") do click_link("Change") end - fill_in_and_submit_training_form("Teaching piano to young adults", "PianoWorx", "A", "2021") + fill_in_and_submit_training_form("Teaching piano to young adults", "PianoWorx", "A", "2021", "1 year") - expect_page_to_have_values("Teaching piano to young adults", "PianoWorx", "A", "2021") + expect_page_to_have_values("Teaching piano to young adults", "PianoWorx", "A", "2021", "1 year") click_link "Return to profile" expect(page).to have_current_path(jobseekers_profile_path) - expect_page_to_have_values("Teaching piano to young adults", "PianoWorx", "A", "2021") + expect_page_to_have_values("Teaching piano to young adults", "PianoWorx", "A", "2021", "1 year") end end @@ -69,7 +70,7 @@ end it "allows users to delete training" do - expect_page_to_have_values("Rock climbing", "TeachTrainLtd", "Pass", "2020") + expect_page_to_have_values("Rock climbing", "TeachTrainLtd", "Pass", "2020", "1 year") within(".govuk-summary-card__title-wrapper", text: "Rock climbing") do click_link("Delete") @@ -88,19 +89,21 @@ expect(page).to_not have_css(".govuk-summary-list__value", text: "TeachTrainLtd") expect(page).to_not have_css(".govuk-summary-list__value", text: "Pass") expect(page).to_not have_css(".govuk-summary-list__value", text: "2020") + expect(page).to_not have_css(".govuk-summary-list__value", text: "1 year") end end end - def fill_in_and_submit_training_form(name, provider, grade, year) + def fill_in_and_submit_training_form(name, provider, grade, year, course_length) fill_in "Name", with: name fill_in "Training provider", with: provider fill_in "Grade", with: grade fill_in "Year awarded", with: year + fill_in "Course length", with: course_length click_on "Save and continue" end - def expect_page_to_have_values(name, provider, grade, year) + def expect_page_to_have_values(name, provider, grade, year, course_length) expect(page).to have_css(".govuk-summary-list__key", text: "Name of course or training") expect(page).to have_css(".govuk-summary-list__value", text: name) @@ -112,5 +115,8 @@ def expect_page_to_have_values(name, provider, grade, year) expect(page).to have_css(".govuk-summary-list__key", text: "Year awarded") expect(page).to have_css(".govuk-summary-list__value", text: year) + + expect(page).to have_css(".govuk-summary-list__key", text: "Course length") + expect(page).to have_css(".govuk-summary-list__value", text: course_length) end end From 81056944fab219d48f8eaed7be830da7e9002d47 Mon Sep 17 00:00:00 2001 From: Kyle MacPherson Date: Thu, 9 Jan 2025 16:20:15 +0000 Subject: [PATCH 13/27] Add course length to hiring staff view of job applications --- .../job_applications/review/_training_and_cpds.html.slim | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/jobseekers/job_applications/review/_training_and_cpds.html.slim b/app/views/jobseekers/job_applications/review/_training_and_cpds.html.slim index 53bef0a72b..b0580b2d95 100644 --- a/app/views/jobseekers/job_applications/review/_training_and_cpds.html.slim +++ b/app/views/jobseekers/job_applications/review/_training_and_cpds.html.slim @@ -11,5 +11,6 @@ - if training.grade.present? span class="govuk-!-display-inline-block govuk-!-margin-left-1" = "(#{training.grade})" + p class="govuk-!-margin-bottom-1" = training.course_length p.govuk-caption-m = "#{training.provider}, #{training.year_awarded}" From 44573c5c7c66ff3076d1db76bc8b0b0e70677ffa Mon Sep 17 00:00:00 2001 From: Kyle MacPherson Date: Thu, 9 Jan 2025 16:28:02 +0000 Subject: [PATCH 14/27] Add course_length to analytics.yml --- config/analytics.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/analytics.yml b/config/analytics.yml index 419fee7511..3464b4c639 100644 --- a/config/analytics.yml +++ b/config/analytics.yml @@ -439,6 +439,7 @@ shared: - updated_at - jobseeker_profile_id - job_application_id + - course_length :noticed_notifications: - id - type From 0d15a2697616da8d34fe32ee6c491285a8ecd3ec Mon Sep 17 00:00:00 2001 From: Kyle MacPherson Date: Thu, 9 Jan 2025 16:39:42 +0000 Subject: [PATCH 15/27] Remove whitespace --- .../profiles/training_and_cpds/confirm_destroy.html.slim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/jobseekers/profiles/training_and_cpds/confirm_destroy.html.slim b/app/views/jobseekers/profiles/training_and_cpds/confirm_destroy.html.slim index 0e8b7d8186..35bf205af1 100644 --- a/app/views/jobseekers/profiles/training_and_cpds/confirm_destroy.html.slim +++ b/app/views/jobseekers/profiles/training_and_cpds/confirm_destroy.html.slim @@ -16,7 +16,7 @@ - summary_list.with_row do |row| - row.with_key text: t("helpers.label.jobseekers_training_and_cpd_form.provider") - row.with_value text: training_and_cpd.provider - + - summary_list.with_row do |row| - row.with_key text: t("helpers.label.jobseekers_training_and_cpd_form.course_length") - row.with_value text: training_and_cpd.course_length From 0fd06b7695d97c58288d53d1948098371686aa7e Mon Sep 17 00:00:00 2001 From: Kyle MacPherson Date: Thu, 9 Jan 2025 16:51:16 +0000 Subject: [PATCH 16/27] Add course_length to fill_in_training_and_cpds helper method --- spec/support/jobseeker_helpers.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/support/jobseeker_helpers.rb b/spec/support/jobseeker_helpers.rb index 81a1bcd7a5..6911cc8891 100644 --- a/spec/support/jobseeker_helpers.rb +++ b/spec/support/jobseeker_helpers.rb @@ -44,11 +44,12 @@ def fill_in_employment_history(job_title: "The Best Teacher", start_month: "09", fill_in "jobseekers_job_application_details_employment_form[ended_on(2i)]", with: end_month end - def fill_in_training_and_cpds(name: "Fire safety", provider: "TrainingProvider ltd", grade: "Pass", year_awarded: "2020") + def fill_in_training_and_cpds(name: "Fire safety", provider: "TrainingProvider ltd", grade: "Pass", year_awarded: "2020", course_length: "1 year") fill_in "Name of course or training", with: name fill_in "Training provider", with: provider fill_in "Grade", with: grade fill_in "Year awarded", with: year_awarded + fill_in "Course length", with: course_length end def fill_in_break_in_employment(start_year: "2020", start_month: "08", end_year: "2020", end_month: "12") From 97edf7e28fc15046be411cc351669e51e6c9efa9 Mon Sep 17 00:00:00 2001 From: Kyle MacPherson Date: Thu, 9 Jan 2025 16:59:56 +0000 Subject: [PATCH 17/27] Change hint text for date completed question --- config/locales/jobseekers.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/locales/jobseekers.yml b/config/locales/jobseekers.yml index 20ff449363..21c93f1e1f 100644 --- a/config/locales/jobseekers.yml +++ b/config/locales/jobseekers.yml @@ -260,12 +260,12 @@ en: title: Add training and continuing professional development (CPD) new: <<: *training_shared - hint: For example, 1998 + hint: For example, 2024. caption: Training and continuing professional development (CPD) heading: Add training and continuing professional development (CPD) edit: <<: *training_shared - hint: For example, 1998 + hint: For example, 2024. caption: Training and continuing professional development (CPD) heading: Edit training and continuing professional development (CPD) destroy: @@ -778,10 +778,10 @@ en: training_and_cpds: new: <<: *training_shared - hint: For example, 1998 + hint: For example, 2024. edit: <<: *training_shared - hint: For example, 1998 + hint: For example, 2024. destroy: success: Training deleted qualifications: From 787a4a1dd568fecaf3b5f88a4e86e45b28d626bf Mon Sep 17 00:00:00 2001 From: Kyle MacPherson Date: Thu, 9 Jan 2025 17:00:29 +0000 Subject: [PATCH 18/27] Move grade question to the bottom of all training forms --- .../job_applications/training_and_cpds/edit.html.slim | 2 +- .../job_applications/training_and_cpds/new.html.slim | 2 +- .../profiles/training_and_cpds/confirm_destroy.html.slim | 8 ++++---- .../jobseekers/profiles/training_and_cpds/edit.html.slim | 2 +- .../jobseekers/profiles/training_and_cpds/new.html.slim | 2 +- .../training_and_cpds/_training_and_cpds.html.slim | 8 ++++---- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/views/jobseekers/job_applications/training_and_cpds/edit.html.slim b/app/views/jobseekers/job_applications/training_and_cpds/edit.html.slim index 44d29cf713..eb50b5f764 100644 --- a/app/views/jobseekers/job_applications/training_and_cpds/edit.html.slim +++ b/app/views/jobseekers/job_applications/training_and_cpds/edit.html.slim @@ -17,9 +17,9 @@ = f.govuk_text_field :name, label: { size: "s" }, aria: { required: true } = f.govuk_text_field :provider, label: { size: "s" }, aria: { required: true } - = f.govuk_text_field :grade, label: { size: "s" } = f.govuk_text_field :year_awarded, label: { size: "s" }, type: "number", width: 4, hint: { text: t(".hint") } = f.govuk_text_field :course_length, label: { size: "s" }, aria: { required: true } + = f.govuk_text_field :grade, label: { size: "s" } = f.govuk_submit t("buttons.save_and_continue") .govuk-button-group diff --git a/app/views/jobseekers/job_applications/training_and_cpds/new.html.slim b/app/views/jobseekers/job_applications/training_and_cpds/new.html.slim index 13a05614ac..bc5705f7db 100644 --- a/app/views/jobseekers/job_applications/training_and_cpds/new.html.slim +++ b/app/views/jobseekers/job_applications/training_and_cpds/new.html.slim @@ -19,8 +19,8 @@ = f.govuk_text_field :name, label: { size: "s" }, aria: { required: true } = f.govuk_text_field :provider, label: { size: "s" }, aria: { required: true } = f.govuk_text_field :course_length, label: { size: "s" }, aria: { required: true } - = f.govuk_text_field :grade, label: { size: "s" } = f.govuk_text_field :year_awarded, label: { size: "s" }, type: "number", width: 4, hint: { text: t(".hint") } + = f.govuk_text_field :grade, label: { size: "s" } = f.govuk_submit t("buttons.save_and_continue") .govuk-button-group diff --git a/app/views/jobseekers/profiles/training_and_cpds/confirm_destroy.html.slim b/app/views/jobseekers/profiles/training_and_cpds/confirm_destroy.html.slim index 35bf205af1..c465b8afb9 100644 --- a/app/views/jobseekers/profiles/training_and_cpds/confirm_destroy.html.slim +++ b/app/views/jobseekers/profiles/training_and_cpds/confirm_destroy.html.slim @@ -21,14 +21,14 @@ - row.with_key text: t("helpers.label.jobseekers_training_and_cpd_form.course_length") - row.with_value text: training_and_cpd.course_length - - summary_list.with_row do |row| - - row.with_key text: t("helpers.label.jobseekers_training_and_cpd_form.grade") - - row.with_value text: training_and_cpd.grade - - summary_list.with_row do |row| - row.with_key text: t("helpers.label.jobseekers_training_and_cpd_form.year_awarded") - row.with_value text: training_and_cpd.year_awarded + - summary_list.with_row do |row| + - row.with_key text: t("helpers.label.jobseekers_training_and_cpd_form.grade") + - row.with_value text: training_and_cpd.grade + = f.govuk_submit "Delete training" .govuk-button-group diff --git a/app/views/jobseekers/profiles/training_and_cpds/edit.html.slim b/app/views/jobseekers/profiles/training_and_cpds/edit.html.slim index ec481f15b8..c9678ead2d 100644 --- a/app/views/jobseekers/profiles/training_and_cpds/edit.html.slim +++ b/app/views/jobseekers/profiles/training_and_cpds/edit.html.slim @@ -19,8 +19,8 @@ = f.govuk_text_field :name, label: { size: "s" }, aria: { required: true } = f.govuk_text_field :provider, label: { size: "s" }, aria: { required: true } = f.govuk_text_field :course_length, label: { size: "s" }, aria: { required: true } - = f.govuk_text_field :grade, label: { size: "s" } = f.govuk_text_field :year_awarded, label: { size: "s" }, type: "number", width: 4, hint: { text: t(".hint") } + = f.govuk_text_field :grade, label: { size: "s" } = f.govuk_submit t("buttons.save_and_continue") .govuk-button-group diff --git a/app/views/jobseekers/profiles/training_and_cpds/new.html.slim b/app/views/jobseekers/profiles/training_and_cpds/new.html.slim index 984045ecf7..634b97c9c5 100644 --- a/app/views/jobseekers/profiles/training_and_cpds/new.html.slim +++ b/app/views/jobseekers/profiles/training_and_cpds/new.html.slim @@ -19,8 +19,8 @@ = f.govuk_text_field :name, label: { size: "s" }, aria: { required: true } = f.govuk_text_field :provider, label: { size: "s" }, aria: { required: true } = f.govuk_text_field :course_length, label: { size: "s" }, aria: { required: true } - = f.govuk_text_field :grade, label: { size: "s" } = f.govuk_text_field :year_awarded, label: { size: "s" }, type: "number", width: 4, hint: { text: t(".hint") } + = f.govuk_text_field :grade, label: { size: "s" } = f.govuk_submit t("buttons.save_and_continue") .govuk-button-group diff --git a/app/views/jobseekers/training_and_cpds/_training_and_cpds.html.slim b/app/views/jobseekers/training_and_cpds/_training_and_cpds.html.slim index 543eca1ef8..16bf916ff9 100644 --- a/app/views/jobseekers/training_and_cpds/_training_and_cpds.html.slim +++ b/app/views/jobseekers/training_and_cpds/_training_and_cpds.html.slim @@ -15,13 +15,13 @@ - row.with_key text: t("helpers.label.jobseekers_training_and_cpd_form.course_length") - row.with_value text: training.course_length - - summary_list.with_row do |row| - - row.with_key text: t("helpers.label.jobseekers_training_and_cpd_form.grade") - - row.with_value text: training.grade - - summary_list.with_row do |row| - row.with_key text: t("helpers.label.jobseekers_training_and_cpd_form.year_awarded") - row.with_value text: training.year_awarded + - summary_list.with_row do |row| + - row.with_key text: t("helpers.label.jobseekers_training_and_cpd_form.grade") + - row.with_value text: training.grade + - detail.with_action govuk_link_to(safe_join([t("buttons.change"), tag.span(training.name, class: "govuk-visually-hidden")]), edit_jobseekers_profile_training_and_cpd_path(training), class: "govuk-link--no-visited-state") - detail.with_action govuk_link_to(safe_join([t("buttons.delete"), tag.span(training.name, class: "govuk-visually-hidden")]), jobseekers_profile_training_and_cpd_confirm_destroy_path(training)) From 30fd40d8717d5797d98970988185529d9fde4638 Mon Sep 17 00:00:00 2001 From: Kyle MacPherson Date: Fri, 10 Jan 2025 09:39:47 +0000 Subject: [PATCH 19/27] Change "Year awarded" to "Date completed" --- app/helpers/pdf_helper.rb | 2 +- .../profiles/qualifications/confirm_destroy.html.slim | 2 +- config/locales/forms.yml | 2 +- spec/support/jobseeker_helpers.rb | 2 +- ...can_add_training_and_cpds_to_their_job_application_spec.rb | 4 ++-- .../jobseekers_can_add_training_to_their_profile_spec.rb | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/helpers/pdf_helper.rb b/app/helpers/pdf_helper.rb index d44ac0b8dd..05a1c9ec21 100644 --- a/app/helpers/pdf_helper.rb +++ b/app/helpers/pdf_helper.rb @@ -106,7 +106,7 @@ def add_secondary_qualification_details(pdf, qualification) secondary_qualification_data = [ ["Name:", qualification.name], ["Grade:", qualification.grade], - ["Year Awarded:", qualification.year], + ["Date completed:", qualification.year], ].reject { |row| row[1].blank? } render_table(pdf, secondary_qualification_data) diff --git a/app/views/jobseekers/profiles/qualifications/confirm_destroy.html.slim b/app/views/jobseekers/profiles/qualifications/confirm_destroy.html.slim index ea3320811d..07e7fed15a 100644 --- a/app/views/jobseekers/profiles/qualifications/confirm_destroy.html.slim +++ b/app/views/jobseekers/profiles/qualifications/confirm_destroy.html.slim @@ -24,7 +24,7 @@ - row.with_key text: "Institution" - row.with_value text: qualification.institution - summary_list.with_row do |row| - - row.with_key text: "Year awarded" + - row.with_key text: "Date completed" - row.with_value text: qualification.year - summary_list.with_row do |row| - row.with_key text: t("jobseekers.qualifications.subjects_and_grades") diff --git a/config/locales/forms.yml b/config/locales/forms.yml index a9f50a0c5e..cd2e59a051 100644 --- a/config/locales/forms.yml +++ b/config/locales/forms.yml @@ -616,7 +616,7 @@ en: name: Name of course or training provider: Training provider grade: Grade (optional) - year_awarded: Year awarded + year_awarded: Date completed year_completed_hint: For example, 1998 course_length: Course length diff --git a/spec/support/jobseeker_helpers.rb b/spec/support/jobseeker_helpers.rb index 6911cc8891..555630b4f0 100644 --- a/spec/support/jobseeker_helpers.rb +++ b/spec/support/jobseeker_helpers.rb @@ -48,7 +48,7 @@ def fill_in_training_and_cpds(name: "Fire safety", provider: "TrainingProvider l fill_in "Name of course or training", with: name fill_in "Training provider", with: provider fill_in "Grade", with: grade - fill_in "Year awarded", with: year_awarded + fill_in "Date completed", with: year_awarded fill_in "Course length", with: course_length end diff --git a/spec/system/jobseekers/jobseeker_can_add_training_and_cpds_to_their_job_application_spec.rb b/spec/system/jobseekers/jobseeker_can_add_training_and_cpds_to_their_job_application_spec.rb index f3f094362e..585d168822 100644 --- a/spec/system/jobseekers/jobseeker_can_add_training_and_cpds_to_their_job_application_spec.rb +++ b/spec/system/jobseekers/jobseeker_can_add_training_and_cpds_to_their_job_application_spec.rb @@ -71,7 +71,7 @@ def fill_in_and_submit_training_form(name, provider, grade, year, course_length) fill_in "Name", with: name fill_in "Training provider", with: provider fill_in "Grade", with: grade - fill_in "Year awarded", with: year + fill_in "Date completed", with: year fill_in "Course length", with: course_length click_on "Save and continue" end @@ -86,7 +86,7 @@ def expect_page_to_have_values(name, provider, grade, year, course_length) expect(page).to have_css(".govuk-summary-list__key", text: "Grade (optional)") expect(page).to have_css(".govuk-summary-list__value", text: grade) - expect(page).to have_css(".govuk-summary-list__key", text: "Year awarded") + expect(page).to have_css(".govuk-summary-list__key", text: "Date completed") expect(page).to have_css(".govuk-summary-list__value", text: year) expect(page).to have_css(".govuk-summary-list__key", text: "Course length") diff --git a/spec/system/jobseekers/jobseekers_can_add_training_to_their_profile_spec.rb b/spec/system/jobseekers/jobseekers_can_add_training_to_their_profile_spec.rb index 5a7f270c1e..35652ec793 100644 --- a/spec/system/jobseekers/jobseekers_can_add_training_to_their_profile_spec.rb +++ b/spec/system/jobseekers/jobseekers_can_add_training_to_their_profile_spec.rb @@ -98,7 +98,7 @@ def fill_in_and_submit_training_form(name, provider, grade, year, course_length) fill_in "Name", with: name fill_in "Training provider", with: provider fill_in "Grade", with: grade - fill_in "Year awarded", with: year + fill_in "Date completed", with: year fill_in "Course length", with: course_length click_on "Save and continue" end @@ -113,7 +113,7 @@ def expect_page_to_have_values(name, provider, grade, year, course_length) expect(page).to have_css(".govuk-summary-list__key", text: "Grade (optional)") expect(page).to have_css(".govuk-summary-list__value", text: grade) - expect(page).to have_css(".govuk-summary-list__key", text: "Year awarded") + expect(page).to have_css(".govuk-summary-list__key", text: "Date completed") expect(page).to have_css(".govuk-summary-list__value", text: year) expect(page).to have_css(".govuk-summary-list__key", text: "Course length") From 36dc234a2614a9c21ba5096820c802d8bf17fda3 Mon Sep 17 00:00:00 2001 From: Kyle MacPherson Date: Mon, 13 Jan 2025 10:54:19 +0000 Subject: [PATCH 20/27] Change description on jobseeker profile but not applications --- config/locales/jobseekers.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config/locales/jobseekers.yml b/config/locales/jobseekers.yml index 21c93f1e1f..9b0000d376 100644 --- a/config/locales/jobseekers.yml +++ b/config/locales/jobseekers.yml @@ -90,7 +90,6 @@ en: success: Thank you for providing additional feedback on your job alert shared: training_shared: &training_shared - description: Include any training you've completed within the last 3 years relevant to the role you're applying for. example_intro: "For example you could include:" example1: safeguarding training example2: Prevent duty training @@ -263,11 +262,13 @@ en: hint: For example, 2024. caption: Training and continuing professional development (CPD) heading: Add training and continuing professional development (CPD) + description: Include any training you've completed within the last 3 years relevant to the role you're applying for. edit: <<: *training_shared hint: For example, 2024. caption: Training and continuing professional development (CPD) heading: Edit training and continuing professional development (CPD) + description: Include any training you've completed within the last 3 years relevant to the role you're applying for. destroy: success: Training deleted review: @@ -779,9 +780,11 @@ en: new: <<: *training_shared hint: For example, 2024. + description: Include any training you've completed within the last 3 years relevant to the role. edit: <<: *training_shared hint: For example, 2024. + description: Include any training you've completed within the last 3 years relevant to the role. destroy: success: Training deleted qualifications: From b220e49072d7337df2d180014f488f09d2306053 Mon Sep 17 00:00:00 2001 From: Kyle MacPherson Date: Mon, 13 Jan 2025 11:34:23 +0000 Subject: [PATCH 21/27] Fix copy to remove reference to any role on the jobseeker profile. --- config/locales/jobseekers.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/locales/jobseekers.yml b/config/locales/jobseekers.yml index 9b0000d376..b063e37098 100644 --- a/config/locales/jobseekers.yml +++ b/config/locales/jobseekers.yml @@ -780,11 +780,11 @@ en: new: <<: *training_shared hint: For example, 2024. - description: Include any training you've completed within the last 3 years relevant to the role. + description: Include any training you've completed within the last 3 years. edit: <<: *training_shared hint: For example, 2024. - description: Include any training you've completed within the last 3 years relevant to the role. + description: Include any training you've completed within the last 3 years. destroy: success: Training deleted qualifications: From 3ecbdffd7b5f963487451a59c31bd312813b8a15 Mon Sep 17 00:00:00 2001 From: Marc Sardon Date: Mon, 13 Jan 2025 15:49:03 +0000 Subject: [PATCH 22/27] Refactor: Group and order Cron jobs schedule Trying to improve the visibility of our scheduled jobs. Split them into sections (Monthly, Weekly, Daily, Hourly) and by time. So any developer should be able to find what is scheduled to run at any time without much headache. --- config/schedule.yml | 190 +++++++++++++++++++++++--------------------- 1 file changed, 101 insertions(+), 89 deletions(-) diff --git a/config/schedule.yml b/config/schedule.yml index 9b866d368f..bd28b6adb7 100644 --- a/config/schedule.yml +++ b/config/schedule.yml @@ -1,141 +1,153 @@ +# +# MONTHLY CRON JOBS +# clear_emergency_login_keys: - cron: '30 0 1 * *' + cron: '30 0 1 * *' # "At 00:30 on day-of-month 1." class: 'ClearEmergencyLoginKeysJob' queue: low -destroy_inactive_accounts: - cron: '10 8 * * *' - class: 'DestroyInactiveAccountsJob' - queue: low +# +# WEEKLY CRON JOBS +# +queue_weekly_alerts: + cron: '0 18 * * 5' # "At 18:00 on Friday." + class: 'SendWeeklyAlertEmailJob' + queue: default -email_feedback_prompt: - cron: '0 09 * * *' - class: 'SendExpiredVacancyFeedbackPromptJob' +import_polygon_data: + cron: '0 23 * * 0' # "At 23:00 on Sunday." + class: 'ImportPolygonDataJob' queue: low -export_users: - cron: '0 01 * * *' - class: 'ExportDSIUsersToBigQueryJob' +# +# DAILY CRON JOBS +# +remove_stale_vacancies: + cron: '0 00 * * *' # "At 00:00." + class: 'RemoveStaleVacanciesJob' queue: low -# Internal querying & parsing of Find a Job export data depends on this running time. -# Be careful if changing this time as you will need to adapt the code. -export_vacancies_published_and_updated_to_dwp_find_a_job_service: - cron: '30 23 * * *' - class: 'ExportVacanciesPublishedAndUpdatedSinceYesterdayToDwpFindAJobServiceJob' +update_dsi_users_in_db: + cron: '0 0 * * *' # "At 00:00." + class: 'UpdateDSIUsersInDbJob' queue: low -export_vacancies_closed_early_to_dwp_find_a_job_service: - cron: '30 21 * * *' - class: 'ExportVacanciesClosedEarlySinceYesterdayToDwpFindAJobServiceJob' +export_users: + cron: '0 01 * * *' # "At 01:00." + class: 'ExportDSIUsersToBigQueryJob' queue: low -import_organisation_data: - cron: '0 22 * * *' - class: 'ImportOrganisationDataJob' +stream_equal_opportunities_report_publication_job: + cron: '30 01 * * *' # "At 01:30." + class: 'StreamEqualOpportunitiesReportPublicationJob' queue: low -import_polygon_data: - cron: '0 23 * * 0' - class: 'ImportPolygonDataJob' +send_entity_table_checks_to_bigquery: + cron: "30 1 * * *" # "At 01:30." + class: "DfE::Analytics::EntityTableCheckJob" queue: low -import_from_vacancy_sources: - cron: '55 6-21 * * *' - class: 'ImportFromVacancySourcesJob' - queue: default +reset_sessions: + cron: '0 02 * * *' # "At 02:00." + class: 'ResetSessionsJob' + queue: low -queue_applications_received: - cron: '0 6 * * *' - class: 'SendApplicationsReceivedYesterdayJob' +send_unapplied_saved_vacancies_email: + cron: '05 2 * * *' # "At 02:05." + class: 'SendEmailForUnappliedSavedVacanciesJob' queue: default -queue_daily_alerts: - cron: '0 15 * * *' - class: 'SendDailyAlertEmailJob' +send_draft_applications_email: + cron: '20 2 * * *' # "At 02:20." + class: 'SendEmailForDraftJobApplicationsJob' queue: default -queue_weekly_alerts: - cron: '0 18 * * 5' - class: 'SendWeeklyAlertEmailJob' +delete_old_feedback: + cron: '0 3 * * *' # "At 03:00." + class: 'DeleteOldFeedbackJob' queue: default -refresh_markers: - cron: '0 6 * * *' - class: 'RefreshMarkersJob' - queue: low - -refresh_organisations_gias_data_hash: - cron: '0 23 * * *' - class: 'RefreshOrganisationsGiasDataHashJob' +remove_vacancies_that_expired_yesterday_from_google_index: + cron: '0 04 * * *' # "At 04:00." + class: 'RemoveVacanciesThatExpiredYesterdayFromGoogleIndexJob' queue: low remove_invalid_subscriptions: - cron: '0 05 * * *' + cron: '0 05 * * *' # "At 05:00." class: 'RemoveInvalidSubscriptionsJob' queue: low -remove_stale_vacancies: - cron: '0 00 * * *' - class: 'RemoveStaleVacanciesJob' - queue: low - delete_old_applications: - cron: '0 05 * * *' + cron: '0 05 * * *' # "At 05:00." class: 'DeleteOldNonDraftJobApplicationsJob' queue: low -withdraw_stale_drafts: - cron: '0 10 * * *' - class: 'DeleteOldDraftApplicationsForExpiredVacanciesJob' +refresh_markers: + cron: '0 6 * * *' # "At 06:00." + class: 'RefreshMarkersJob' queue: low -remove_vacancies_that_expired_yesterday_from_google_index: - cron: '0 04 * * *' - class: 'RemoveVacanciesThatExpiredYesterdayFromGoogleIndexJob' - queue: low +send_job_application_data_expiry_notification: + cron: '0 6 * * *' # "At 06:00." + class: 'SendJobApplicationDataExpiryNotifierJob' + queue: default -reset_sessions: - cron: '0 02 * * *' - class: 'ResetSessionsJob' - queue: low +queue_applications_received: + cron: '0 6 * * *' # "At 06:00." + class: 'SendApplicationsReceivedYesterdayJob' + queue: default send_inactive_account_email: - cron: '0 8 * * *' + cron: '0 8 * * *' # "At 08:00." class: 'SendInactiveAccountEmailJob' queue: low -send_draft_applications_email: - cron: '20 2 * * *' - class: 'SendEmailForDraftJobApplicationsJob' - queue: default +destroy_inactive_accounts: + cron: '10 8 * * *' # "At 08:10." + class: 'DestroyInactiveAccountsJob' + queue: low -send_unapplied_saved_vacancies_email: - cron: '05 2 * * *' - class: 'SendEmailForUnappliedSavedVacanciesJob' - queue: default +email_feedback_prompt: + cron: '0 09 * * *' # "At 09:00." + class: 'SendExpiredVacancyFeedbackPromptJob' + queue: low -send_job_application_data_expiry_notification: - cron: '0 6 * * *' - class: 'SendJobApplicationDataExpiryNotifierJob' +withdraw_stale_drafts: + cron: '0 10 * * *' # At 10:00. + class: 'DeleteOldDraftApplicationsForExpiredVacanciesJob' + queue: low + +queue_daily_alerts: + cron: '0 15 * * *' # "At 15:00." + class: 'SendDailyAlertEmailJob' queue: default -stream_equal_opportunities_report_publication_job: - cron: '30 01 * * *' - class: 'StreamEqualOpportunitiesReportPublicationJob' +export_vacancies_closed_early_to_dwp_find_a_job_service: + cron: '30 21 * * *' # "At 21:30." + class: 'ExportVacanciesClosedEarlySinceYesterdayToDwpFindAJobServiceJob' queue: low -update_dsi_users_in_db: - cron: '0 0 * * *' - class: 'UpdateDSIUsersInDbJob' +import_organisation_data: + cron: '0 22 * * *' # "At 22:00." + class: 'ImportOrganisationDataJob' queue: low -delete_old_feedback: - cron: '0 3 * * *' - class: 'DeleteOldFeedbackJob' - queue: default +refresh_organisations_gias_data_hash: + cron: '0 23 * * *' # "At 23:00." + class: 'RefreshOrganisationsGiasDataHashJob' + queue: low -send_entity_table_checks_to_bigquery: - cron: "30 1 * * *" - class: "DfE::Analytics::EntityTableCheckJob" +# Internal querying & parsing of Find a Job export data depends on this running time. +# Be careful if changing this time as you will need to adapt the code. +export_vacancies_published_and_updated_to_dwp_find_a_job_service: + cron: '30 23 * * *' # "At 23:30." + class: 'ExportVacanciesPublishedAndUpdatedSinceYesterdayToDwpFindAJobServiceJob' queue: low + +# +# HOURLY CRON JOBS +# +import_from_vacancy_sources: + cron: '55 6-21 * * *' # "Every hour between 06:55 and 21:55." + class: 'ImportFromVacancySourcesJob' + queue: default From 9725f54c270ee9a2ceff7ecfb2331aba48cbbd0b Mon Sep 17 00:00:00 2001 From: Marc Sardon Date: Mon, 13 Jan 2025 16:53:42 +0000 Subject: [PATCH 23/27] Create and schedule job to delete old alert runs Daily job to delete any Subscription Alert Run created longer than 7 days ago. We only need the alert runs to check if the alert was already triggered for the current date. At the moment, the table contains 16M records for over 100k subscriptions. We do not need that data at all. Reducing it to only keeping the latest week will greatly reduce the table size without compromising the recent runs check. --- app/jobs/delete_old_alert_runs_job.rb | 7 +++++++ config/schedule.yml | 5 +++++ spec/jobs/delete_old_alert_runs_job_spec.rb | 21 +++++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 app/jobs/delete_old_alert_runs_job.rb create mode 100644 spec/jobs/delete_old_alert_runs_job_spec.rb diff --git a/app/jobs/delete_old_alert_runs_job.rb b/app/jobs/delete_old_alert_runs_job.rb new file mode 100644 index 0000000000..738685955f --- /dev/null +++ b/app/jobs/delete_old_alert_runs_job.rb @@ -0,0 +1,7 @@ +class DeleteOldAlertRunsJob < ApplicationJob + queue_as :low + + def perform + AlertRun.where(run_on: ...1.week.ago).destroy_all + end +end diff --git a/config/schedule.yml b/config/schedule.yml index bd28b6adb7..32baa60382 100644 --- a/config/schedule.yml +++ b/config/schedule.yml @@ -82,6 +82,11 @@ delete_old_applications: class: 'DeleteOldNonDraftJobApplicationsJob' queue: low +delete_old_alert_runs: + cron: '10 5 * * *' # "At 05:10." + class: 'DeleteOldAlertRunsJob' + queue: low + refresh_markers: cron: '0 6 * * *' # "At 06:00." class: 'RefreshMarkersJob' diff --git a/spec/jobs/delete_old_alert_runs_job_spec.rb b/spec/jobs/delete_old_alert_runs_job_spec.rb new file mode 100644 index 0000000000..76c28ce687 --- /dev/null +++ b/spec/jobs/delete_old_alert_runs_job_spec.rb @@ -0,0 +1,21 @@ +require "rails_helper" + +RSpec.describe DeleteOldAlertRunsJob do + it "deletes alert runs older than a week" do + alert_run = create(:alert_run, run_on: 8.days.ago) + described_class.perform_now + expect(AlertRun).not_to exist(alert_run.id) + end + + it "does not delete alert runs from exactly a week ago" do + alert_run = create(:alert_run, run_on: 7.days.ago) + described_class.perform_now + expect(AlertRun).to exist(alert_run.id) + end + + it "does not delete alert runs newer than a week" do + alert_run = create(:alert_run, run_on: 6.days.ago) + described_class.perform_now + expect(AlertRun).to exist(alert_run.id) + end +end From e4e56149ba818d0ecd827e1eab8dd909865c4aa3 Mon Sep 17 00:00:00 2001 From: vipin-dfe Date: Mon, 13 Jan 2025 17:36:48 +0000 Subject: [PATCH 24/27] Revert "Enable federated auth for big query in production" This reverts commit b4646a19e65d6107d0bf9487037109b66c0ca483. Disable federated auth. GoogleIndexing job seems to be broken. --- terraform/workspace-variables/production.tfvars.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/workspace-variables/production.tfvars.json b/terraform/workspace-variables/production.tfvars.json index 728c36ff01..83fb19df4b 100644 --- a/terraform/workspace-variables/production.tfvars.json +++ b/terraform/workspace-variables/production.tfvars.json @@ -80,6 +80,6 @@ "start_minute": 0 }, "enable_logit": true, - "enable_dfe_analytics_federated_auth": true, + "enable_dfe_analytics_federated_auth": false, "dataset_name": "production_dataset" } From 9b0ff3955e73afdc5ac21ef9ac116d5924d702df Mon Sep 17 00:00:00 2001 From: Stephen Dicks Date: Tue, 14 Jan 2025 08:07:18 +0000 Subject: [PATCH 25/27] Add Awarding Body to qualification result (#7352) --- .../jobseekers/qualification_form_concerns.rb | 24 ++--- .../qualifications_controller.rb | 90 ++++++++++--------- .../profiles/qualifications_controller.rb | 62 +++++++------ .../qualifications/qualification_form.rb | 4 + .../qualifications/secondary/common_form.rb | 4 + .../secondary/qualification_result_form.rb | 2 +- app/helpers/pdf_helper.rb | 16 ++-- app/helpers/qualifications_helper.rb | 8 ++ app/models/qualification_result.rb | 1 + .../build/qualifications.html.slim | 2 +- .../qualifications/edit.html.slim | 10 +-- .../qualifications/new.html.slim | 10 +-- .../qualifications/select_category.html.slim | 4 +- .../_secondary_qualification.html.slim | 2 +- .../qualifications/confirm_destroy.html.slim | 2 +- .../profiles/qualifications/edit.html.slim | 4 +- .../profiles/qualifications/new.html.slim | 10 +-- .../qualifications/select_category.html.slim | 4 +- .../qualifications/_fields.html.slim | 2 +- .../qualifications/_qualifications.html.slim | 2 +- .../fields/_secondary_school.html.slim | 11 +-- .../review/_secondary_qualification.html.slim | 2 +- config/analytics.yml | 1 + config/locales/forms.yml | 2 +- ...d_awarding_body_to_qualification_result.rb | 5 ++ db/schema.rb | 3 +- spec/support/jobseeker_helpers.rb | 6 +- ...fications_to_their_job_application_spec.rb | 2 +- 28 files changed, 164 insertions(+), 131 deletions(-) create mode 100644 db/migrate/20250113144018_add_awarding_body_to_qualification_result.rb diff --git a/app/controllers/concerns/jobseekers/qualification_form_concerns.rb b/app/controllers/concerns/jobseekers/qualification_form_concerns.rb index 3eeace9ede..c79315b40a 100644 --- a/app/controllers/concerns/jobseekers/qualification_form_concerns.rb +++ b/app/controllers/concerns/jobseekers/qualification_form_concerns.rb @@ -6,21 +6,15 @@ def qualification_form_param_key(category) end def category_form_class(category) - name = if %w[select_category submit_category].include?(action_name) - "CategoryForm" - elsif %w[confirm_destroy].include?(action_name) - "DeleteForm" - else - case category - when "gcse", "a_level", "as_level" - "Secondary::CommonForm" - when "other_secondary" - "Secondary::OtherForm" - when "undergraduate", "postgraduate" - "DegreeForm" - when "other" - "OtherForm" - end + name = case category + when "gcse", "a_level", "as_level" + "Secondary::CommonForm" + when "other_secondary" + "Secondary::OtherForm" + when "undergraduate", "postgraduate" + "DegreeForm" + when "other" + "OtherForm" end "Jobseekers::Qualifications::#{name}".constantize end diff --git a/app/controllers/jobseekers/job_applications/qualifications_controller.rb b/app/controllers/jobseekers/job_applications/qualifications_controller.rb index 4752f69906..e648dbaba4 100644 --- a/app/controllers/jobseekers/job_applications/qualifications_controller.rb +++ b/app/controllers/jobseekers/job_applications/qualifications_controller.rb @@ -1,72 +1,78 @@ class Jobseekers::JobApplications::QualificationsController < Jobseekers::BaseController include Jobseekers::QualificationFormConcerns - helper_method :back_path, :category, :form, :job_application, :qualification, :secondary?, :qualification_form_param_key + helper_method :back_path, :job_application, :qualification_form_param_key + + before_action :set_qualification, only: %i[edit update destroy] + + def select_category + @form = Jobseekers::Qualifications::CategoryForm.new + end def submit_category - if form.valid? - redirect_to new_jobseekers_job_application_qualification_path(qualification_params) + @category = category_param + @form = Jobseekers::Qualifications::CategoryForm.new(submit_category_params) + + if @form.valid? + redirect_to new_jobseekers_job_application_qualification_path(submit_category_params) else - render :select_category + render :select_category, status: :unprocessable_entity end end + def new + @category = category_param + @form = category_form_class(@category).new(category: @category) + end + + def edit + @category = @qualification.category + edit_attributes = @qualification + .slice(:category, :finished_studying, :finished_studying_details, :grade, :institution, :name, :subject, :year, :qualification_results) + .reject { |_, v| v.blank? && v != false } + + @form = category_form_class(@category).new(edit_attributes) + end + def create - if form.valid? + @category = category_param + @form = category_form_class(@category).new(qualification_params) + + if @form.valid? job_application.qualifications.create(qualification_params) redirect_to back_path else - render :new + render :new, status: :unprocessable_entity end end def update - if form.valid? - qualification.update(qualification_params) + @category = @qualification.category + @form = category_form_class(@category).new(qualification_params) + + if @form.valid? + @qualification.update(qualification_params) redirect_to back_path else - render :edit + render :edit, status: :unprocessable_entity end end def destroy - qualification.destroy + @qualification.destroy redirect_to back_path, success: t(".success") end private - def form - @form ||= category_form_class(category).new(form_attributes) - end - - def form_attributes - case action_name - when "new" - { category: category } - when "select_category" - {} - when "edit" - qualification - .slice(:category, :finished_studying, :finished_studying_details, :grade, :institution, :name, :subject, :year, :qualification_results) - .reject { |_, v| v.blank? && v != false } - when "create", "update", "submit_category" - qualification_params - end + def submit_category_params + key = ActiveModel::Naming.param_key(Jobseekers::Qualifications::CategoryForm) + (params[key] || params).permit(:category) end def qualification_params - case action_name - when "new", "select_category", "submit_category" - (params[qualification_form_param_key(category)] || params).permit(:category) - when "create", "edit", "update" - params.require(qualification_form_param_key(category)) - .permit(:category, :finished_studying, :finished_studying_details, :grade, :institution, :name, :subject, :year, qualification_results_attributes: %i[id subject grade]) - end - end - - def category - @category ||= action_name.in?(%w[edit update]) ? qualification.category : category_param + params.require(qualification_form_param_key(@category)) + .permit(:category, :finished_studying, :finished_studying_details, :grade, :institution, :name, :subject, :year, qualification_results_attributes: %i[id subject grade awarding_body]) end def category_param @@ -81,11 +87,7 @@ def job_application @job_application ||= current_jobseeker.job_applications.draft.find(params[:job_application_id]) end - def qualification - @qualification ||= job_application.qualifications.find(params[:id]) - end - - def secondary? - category.in?(Qualification::SECONDARY_QUALIFICATIONS) + def set_qualification + @qualification = job_application.qualifications.find(params[:id]) end end diff --git a/app/controllers/jobseekers/profiles/qualifications_controller.rb b/app/controllers/jobseekers/profiles/qualifications_controller.rb index 5c8b5e7cc4..683cd24831 100644 --- a/app/controllers/jobseekers/profiles/qualifications_controller.rb +++ b/app/controllers/jobseekers/profiles/qualifications_controller.rb @@ -1,24 +1,33 @@ class Jobseekers::Profiles::QualificationsController < Jobseekers::ProfilesController include Jobseekers::QualificationFormConcerns - helper_method :category, :form, :jobseeker_profile, :qualification, :secondary?, :qualification_form_param_key + helper_method :jobseeker_profile, :qualification, :qualification_form_param_key + + before_action :set_form_and_category, only: %i[new create edit update] + + def select_category + @form = Jobseekers::Qualifications::CategoryForm.new + end def submit_category - if form.valid? - redirect_to new_jobseekers_profile_qualification_path(qualification_params) + @category = category_param + @form = Jobseekers::Qualifications::CategoryForm.new(submit_category_params) + + if @form.valid? + redirect_to new_jobseekers_profile_qualification_path(submit_category_params) else - render :select_category + render :select_category, status: :unprocessable_entity end end def new; end def create - if form.valid? + if @form.valid? profile.qualifications.create(qualification_params) redirect_to review_jobseekers_profile_qualifications_path else - render :new + render :new, status: :unprocessable_entity end end @@ -27,11 +36,11 @@ def edit; end def review; end def update - if form.valid? + if @form.valid? qualification.update(qualification_params) redirect_to review_jobseekers_profile_qualifications_path else - render :edit + render :edit, status: :unprocessable_entity end end @@ -40,41 +49,44 @@ def destroy redirect_to review_jobseekers_profile_qualifications_path, success: t(".success") end - def confirm_destroy; end + def confirm_destroy + @category = qualification.category + @form = Jobseekers::Qualifications::DeleteForm.new + end private - def form - @form ||= category_form_class(category).new(form_attributes) - end - def form_attributes case action_name when "new" - { category: category } - when "select_category", "confirm_destroy" - {} + { category: @category } when "edit" qualification .slice(:category, :finished_studying, :finished_studying_details, :grade, :institution, :name, :subject, :year, :qualification_results) .reject { |_, v| v.blank? && v != false } - when "create", "update", "submit_category" + when "create", "update" qualification_params end end + def submit_category_params + key = ActiveModel::Naming.param_key(Jobseekers::Qualifications::CategoryForm) + (params[key] || params).permit(:category) + end + def qualification_params case action_name - when "new", "select_category", "submit_category", "confirm_destroy" - (params[qualification_form_param_key(category)] || params).permit(:category) + when "new", "confirm_destroy" + (params[qualification_form_param_key(@category)] || params).permit(:category) when "create", "edit", "update" - params.require(qualification_form_param_key(category)) - .permit(:category, :finished_studying, :finished_studying_details, :grade, :institution, :name, :subject, :year, qualification_results_attributes: %i[id subject grade]) + params.require(qualification_form_param_key(@category)) + .permit(:category, :finished_studying, :finished_studying_details, :grade, :institution, :name, :subject, :year, qualification_results_attributes: %i[id subject grade awarding_body]) end end - def category - @category ||= action_name.in?(%w[edit update confirm_destroy]) ? qualification.category : category_param + def set_form_and_category + @category = action_name.in?(%w[edit update]) ? qualification.category : category_param + @form = category_form_class(@category).new(form_attributes) end def category_param @@ -84,8 +96,4 @@ def category_param def qualification @qualification ||= profile.qualifications.find(params[:id] || params[:qualification_id]) end - - def secondary? - category.in?(Qualification::SECONDARY_QUALIFICATIONS) - end end diff --git a/app/form_models/jobseekers/qualifications/qualification_form.rb b/app/form_models/jobseekers/qualifications/qualification_form.rb index 996060a40e..4efe5eca43 100644 --- a/app/form_models/jobseekers/qualifications/qualification_form.rb +++ b/app/form_models/jobseekers/qualifications/qualification_form.rb @@ -7,4 +7,8 @@ class Jobseekers::Qualifications::QualificationForm validates :finished_studying_details, presence: true, if: -> { finished_studying == "false" } validates :year, numericality: { less_than_or_equal_to: proc { Time.current.year } }, if: -> { finished_studying == "true" } + + def secondary? + false + end end diff --git a/app/form_models/jobseekers/qualifications/secondary/common_form.rb b/app/form_models/jobseekers/qualifications/secondary/common_form.rb index fa45964a4d..1780329661 100644 --- a/app/form_models/jobseekers/qualifications/secondary/common_form.rb +++ b/app/form_models/jobseekers/qualifications/secondary/common_form.rb @@ -14,6 +14,10 @@ def initialize(attributes = nil) pad_qualification_results end + def secondary? + true + end + def qualification_results_attributes=(attrs) @qualification_results = attrs.map { |_, params| QualificationResultForm.new(params) } end diff --git a/app/form_models/jobseekers/qualifications/secondary/qualification_result_form.rb b/app/form_models/jobseekers/qualifications/secondary/qualification_result_form.rb index 825c1808b7..b9bd1000a9 100644 --- a/app/form_models/jobseekers/qualifications/secondary/qualification_result_form.rb +++ b/app/form_models/jobseekers/qualifications/secondary/qualification_result_form.rb @@ -1,7 +1,7 @@ class Jobseekers::Qualifications::Secondary::QualificationResultForm include ActiveModel::Model - attr_accessor :id, :subject, :grade + attr_accessor :id, :subject, :grade, :awarding_body validates :subject, presence: true validates :grade, presence: true diff --git a/app/helpers/pdf_helper.rb b/app/helpers/pdf_helper.rb index 05a1c9ec21..136343d4a7 100644 --- a/app/helpers/pdf_helper.rb +++ b/app/helpers/pdf_helper.rb @@ -103,13 +103,15 @@ def add_secondary_qualification_details(pdf, qualification) pdf.move_down 5 pdf.text "Secondary Qualification", size: 12, style: :italic - secondary_qualification_data = [ - ["Name:", qualification.name], - ["Grade:", qualification.grade], - ["Date completed:", qualification.year], - ].reject { |row| row[1].blank? } - - render_table(pdf, secondary_qualification_data) + qualification.qualification_results.each do |result| + secondary_qualification_data = [ + ["Subject:", result.subject], + ["Grade:", result.grade], + (["Awarding Body:", result.awarding_body] if result.awarding_body.present?), + ["Date completed:", qualification.year], + ].compact + render_table(pdf, secondary_qualification_data) + end end def add_general_qualification_details(pdf, qualification) diff --git a/app/helpers/qualifications_helper.rb b/app/helpers/qualifications_helper.rb index 8b1eb2f7ba..b2f3dfc9f4 100644 --- a/app/helpers/qualifications_helper.rb +++ b/app/helpers/qualifications_helper.rb @@ -16,4 +16,12 @@ def qualifications_sort_and_group(qualifications) def qualifications_group_category_other?(qualifications) qualifications.all? { |qualification| qualification.category == "other" } end + + def display_secondary_qualification(res) + if res.awarding_body.blank? + "#{res.subject} – #{res.grade}" + else + "#{res.subject} – #{res.grade} (#{res.awarding_body})" + end + end end diff --git a/app/models/qualification_result.rb b/app/models/qualification_result.rb index f5a2922270..fb8a87cbd5 100644 --- a/app/models/qualification_result.rb +++ b/app/models/qualification_result.rb @@ -8,6 +8,7 @@ def duplicate self.class.new( grade:, subject:, + awarding_body:, ) end diff --git a/app/views/jobseekers/job_applications/build/qualifications.html.slim b/app/views/jobseekers/job_applications/build/qualifications.html.slim index 126ba7a6d5..065e4e57fb 100644 --- a/app/views/jobseekers/job_applications/build/qualifications.html.slim +++ b/app/views/jobseekers/job_applications/build/qualifications.html.slim @@ -17,7 +17,7 @@ - if qualification.secondary? - summary_list.with_row do |row| - row.with_key text: t("jobseekers.job_applications.qualifications.subjects_and_grades") - - row.with_value text: safe_join(qualification.qualification_results.map { |res| tag.div("#{res.subject} – #{res.grade}", class: "govuk-body govuk-!-margin-bottom-1") }) + - row.with_value text: safe_join(qualification.qualification_results.map { |res| tag.div(display_secondary_qualification(res), class: "govuk-body govuk-!-margin-bottom-1") }) - qualification.display_attributes.each do |attribute| - summary_list.with_row do |row| diff --git a/app/views/jobseekers/job_applications/qualifications/edit.html.slim b/app/views/jobseekers/job_applications/qualifications/edit.html.slim index fa3502dc1c..c8fc982962 100644 --- a/app/views/jobseekers/job_applications/qualifications/edit.html.slim +++ b/app/views/jobseekers/job_applications/qualifications/edit.html.slim @@ -1,14 +1,14 @@ -- content_for :page_title_prefix, job_application_page_title_prefix(form, t(".title")) +- content_for :page_title_prefix, job_application_page_title_prefix(@form, t(".title")) .govuk-grid-row .govuk-grid-column-two-thirds span.govuk-caption-l = t(".caption") - h1.govuk-heading-xl = t(".heading.#{category}") + h1.govuk-heading-xl = t(".heading.#{@category}") - = form_for form, url: jobseekers_job_application_qualification_path(job_application, qualification), method: :patch do |f| + = form_for @form, url: jobseekers_job_application_qualification_path(job_application, @qualification), method: :patch do |f| = f.govuk_error_summary link_base_errors_to: :subject - = render "jobseekers/qualifications/fields", f: f + = render "jobseekers/qualifications/fields", f: f, category: @category - = f.govuk_submit t("buttons.save_qualification.#{secondary? ? 'other' : 'one'}") + = f.govuk_submit t("buttons.save_qualification.#{f.object.secondary? ? 'other' : 'one'}") = govuk_button_link_to t("buttons.cancel"), jobseekers_job_application_build_path(job_application, :qualifications), class: "govuk-button--secondary govuk-!-margin-left-3" diff --git a/app/views/jobseekers/job_applications/qualifications/new.html.slim b/app/views/jobseekers/job_applications/qualifications/new.html.slim index d5a03cbc57..a1ce47e765 100644 --- a/app/views/jobseekers/job_applications/qualifications/new.html.slim +++ b/app/views/jobseekers/job_applications/qualifications/new.html.slim @@ -1,15 +1,15 @@ -- content_for :page_title_prefix, job_application_page_title_prefix(form, t(".title")) +- content_for :page_title_prefix, job_application_page_title_prefix(@form, t(".title")) .govuk-grid-row .govuk-grid-column-two-thirds span.govuk-caption-l = t(".caption") - h1.govuk-heading-xl = t(".heading.#{category}") + h1.govuk-heading-xl = t(".heading.#{@category}") p = t(".hint") - = form_for form, url: jobseekers_job_application_qualifications_path(job_application, category: category), method: :post do |f| + = form_for @form, url: jobseekers_job_application_qualifications_path(job_application, category: @category), method: :post do |f| = f.govuk_error_summary link_base_errors_to: :subject - = render "jobseekers/qualifications/fields", f: f + = render "jobseekers/qualifications/fields", category: @category, f: f - = f.govuk_submit t("buttons.save_qualification.#{secondary? ? 'other' : 'one'}") + = f.govuk_submit t("buttons.save_qualification.#{f.object.secondary? ? 'other' : 'one'}") = govuk_button_link_to t("buttons.cancel"), select_category_jobseekers_job_application_qualifications_path(job_application), class: "govuk-button--secondary govuk-!-margin-left-3" diff --git a/app/views/jobseekers/job_applications/qualifications/select_category.html.slim b/app/views/jobseekers/job_applications/qualifications/select_category.html.slim index cfbc624521..d238491e31 100644 --- a/app/views/jobseekers/job_applications/qualifications/select_category.html.slim +++ b/app/views/jobseekers/job_applications/qualifications/select_category.html.slim @@ -1,11 +1,11 @@ -- content_for :page_title_prefix, job_application_page_title_prefix(form, t(".title")) +- content_for :page_title_prefix, job_application_page_title_prefix(@form, t(".title")) .govuk-grid-row .govuk-grid-column-two-thirds span.govuk-caption-l = t(".caption") h1.govuk-heading-xl = t(".heading") - = form_for form, url: submit_category_jobseekers_job_application_qualifications_path(job_application), method: :post do |f| + = form_for @form, url: submit_category_jobseekers_job_application_qualifications_path(job_application), method: :post do |f| = f.govuk_error_summary = render "shared/category_fieldset", form: f diff --git a/app/views/jobseekers/job_applications/review/qualifications/_secondary_qualification.html.slim b/app/views/jobseekers/job_applications/review/qualifications/_secondary_qualification.html.slim index 65fd38161f..4e27b6d9d8 100644 --- a/app/views/jobseekers/job_applications/review/qualifications/_secondary_qualification.html.slim +++ b/app/views/jobseekers/job_applications/review/qualifications/_secondary_qualification.html.slim @@ -1,5 +1,5 @@ p class="govuk-!-margin-bottom-1" - = qualification.qualification_results.map { |result| "#{result.subject} (#{result.grade.upcase})" }.join(", ") + = qualification.qualification_results.map { |result| display_secondary_qualification(result) }.join(", ") p.govuk-caption-m - if qualification.display_attributes.include?("institution") diff --git a/app/views/jobseekers/profiles/qualifications/confirm_destroy.html.slim b/app/views/jobseekers/profiles/qualifications/confirm_destroy.html.slim index 07e7fed15a..0121612f7d 100644 --- a/app/views/jobseekers/profiles/qualifications/confirm_destroy.html.slim +++ b/app/views/jobseekers/profiles/qualifications/confirm_destroy.html.slim @@ -28,7 +28,7 @@ - row.with_value text: qualification.year - summary_list.with_row do |row| - row.with_key text: t("jobseekers.qualifications.subjects_and_grades") - - row.with_value text: safe_join(qualification.qualification_results.map { |res| tag.div("#{res.subject} – #{res.grade}", class: "govuk-body govuk-!-margin-bottom-1") }) + - row.with_value text: safe_join(qualification.qualification_results.map { |res| tag.div(display_secondary_qualification(res), class: "govuk-body govuk-!-margin-bottom-1") }) - else - summary_list.with_row do |row| - row.with_key text: "Type" diff --git a/app/views/jobseekers/profiles/qualifications/edit.html.slim b/app/views/jobseekers/profiles/qualifications/edit.html.slim index b2eb4f367c..a7a3ecbfc5 100644 --- a/app/views/jobseekers/profiles/qualifications/edit.html.slim +++ b/app/views/jobseekers/profiles/qualifications/edit.html.slim @@ -6,12 +6,12 @@ .govuk-grid-row .govuk-grid-column-two-thirds - = form_for form, url: jobseekers_profile_qualification_path(params[:id]), method: :patch do |f| + = form_for @form, url: jobseekers_profile_qualification_path(params[:id]), method: :patch do |f| = f.govuk_error_summary = f.govuk_fieldset legend: { text: t(".page_title"), tag: "h1", size: "l" } do - = render "jobseekers/qualifications/fields", f: f + = render "jobseekers/qualifications/fields", f: f, category: @category = f.govuk_submit t("buttons.save_and_continue") diff --git a/app/views/jobseekers/profiles/qualifications/new.html.slim b/app/views/jobseekers/profiles/qualifications/new.html.slim index a77db4b2cc..61e611f356 100644 --- a/app/views/jobseekers/profiles/qualifications/new.html.slim +++ b/app/views/jobseekers/profiles/qualifications/new.html.slim @@ -1,16 +1,16 @@ -- content_for :page_title_prefix, job_application_page_title_prefix(form, t(".title")) +- content_for :page_title_prefix, job_application_page_title_prefix(@form, t(".title")) .govuk-grid-row .govuk-grid-column-two-thirds span.govuk-caption-l = t(".caption") - h1.govuk-heading-xl = t(".heading.#{category}") + h1.govuk-heading-xl = t(".heading.#{@category}") p = t(".hint") - = form_for form, url: jobseekers_profile_qualifications_path(profile, category: category), method: :post do |f| + = form_for @form, url: jobseekers_profile_qualifications_path(profile, category: @category), method: :post do |f| = f.govuk_error_summary link_base_errors_to: :subject - = render "jobseekers/qualifications/fields", f: f + = render "jobseekers/qualifications/fields", f: f, category: @category - = f.govuk_submit t("buttons.save_qualification.#{secondary? ? 'other' : 'one'}") + = f.govuk_submit t("buttons.save_qualification.#{f.object.secondary? ? 'other' : 'one'}") = govuk_link_to t("buttons.cancel"), jobseekers_profile_path diff --git a/app/views/jobseekers/profiles/qualifications/select_category.html.slim b/app/views/jobseekers/profiles/qualifications/select_category.html.slim index 6b6fb615ae..8bb62ac9da 100644 --- a/app/views/jobseekers/profiles/qualifications/select_category.html.slim +++ b/app/views/jobseekers/profiles/qualifications/select_category.html.slim @@ -1,4 +1,4 @@ -- content_for :page_title_prefix, job_application_page_title_prefix(form, t(".page_title")) +- content_for :page_title_prefix, job_application_page_title_prefix(@form, t(".page_title")) - content_for :breadcrumbs do nav.govuk-breadcrumbs aria-label="Breadcrumbs" @@ -8,7 +8,7 @@ .govuk-grid-column-two-thirds span.govuk-caption-l = t(".caption") - = form_for form, url: submit_category_jobseekers_profile_qualifications_path, method: :post do |f| + = form_for @form, url: submit_category_jobseekers_profile_qualifications_path, method: :post do |f| = f.govuk_error_summary = render "shared/category_fieldset", form: f diff --git a/app/views/jobseekers/qualifications/_fields.html.slim b/app/views/jobseekers/qualifications/_fields.html.slim index 711be35513..6a613f90a1 100644 --- a/app/views/jobseekers/qualifications/_fields.html.slim +++ b/app/views/jobseekers/qualifications/_fields.html.slim @@ -2,7 +2,7 @@ - case category - when "gcse", "as_level", "a_level", "other_secondary" - = render "jobseekers/qualifications/fields/secondary_school", f: f + = render "jobseekers/qualifications/fields/secondary_school", f: f, category: category - when "undergraduate", "postgraduate", "degree" = render "jobseekers/qualifications/fields/degree", f: f - when "other" diff --git a/app/views/jobseekers/qualifications/_qualifications.html.slim b/app/views/jobseekers/qualifications/_qualifications.html.slim index f17b4dd0ee..c863bbd8f6 100644 --- a/app/views/jobseekers/qualifications/_qualifications.html.slim +++ b/app/views/jobseekers/qualifications/_qualifications.html.slim @@ -6,7 +6,7 @@ - if qualification.secondary? - summary_list.with_row do |row| - row.with_key text: t("jobseekers.profiles.qualifications.subjects_and_grades") - - row.with_value text: safe_join(qualification.qualification_results.map { |res| tag.div("#{res.subject} – #{res.grade}", class: "govuk-body govuk-!-margin-bottom-1") }) + - row.with_value text: safe_join(qualification.qualification_results.map { |res| tag.div(display_secondary_qualification(res), class: "govuk-body govuk-!-margin-bottom-1") }) - qualification.display_attributes.each do |attribute| - summary_list.with_row do |row| diff --git a/app/views/jobseekers/qualifications/fields/_secondary_school.html.slim b/app/views/jobseekers/qualifications/fields/_secondary_school.html.slim index 4993905ab5..71bd88266f 100644 --- a/app/views/jobseekers/qualifications/fields/_secondary_school.html.slim +++ b/app/views/jobseekers/qualifications/fields/_secondary_school.html.slim @@ -3,12 +3,15 @@ - if category == "other_secondary" = f.govuk_text_field :name, label: { size: "s" }, aria: { required: true }, width: "two-thirds" += f.govuk_number_field :year, label: { size: "s" }, aria: { required: true }, width: 4 + = f.govuk_fieldset legend: { text: t("helpers.legend.jobseekers_qualifications_shared_legends.subjects") }, class: "subjects-and-grades", data: { controller: "manage-qualifications" } do - - form.qualification_results.each_with_index do |result, idx| + - f.object.qualification_results.each_with_index do |result, idx| = f.fields_for :qualification_results, result do |result_form| - .inline-fields-container.subject-row class="#{idx > form.highest_present_result_index ? "js-hidden" : ""}" data-manage-qualifications-target="row" + .inline-fields-container.subject-row class="#{idx > f.object.highest_present_result_index ? "js-hidden" : ""}" data-manage-qualifications-target="row" = result_form.govuk_text_field :subject, label: { text: "Subject #{idx + 1}" }, aria: { required: idx.zero? }, form_group: { classes: "govuk-!-width-two-thirds" } - = result_form.govuk_text_field :grade, aria: { required: idx.zero? }, form_group: { classes: "govuk-!-width-one-third" }, label: { text: "Subject #{idx + 1} Grade" } + = result_form.govuk_text_field :grade, aria: { required: idx.zero? }, form_group: { classes: "govuk-!-width-one-third" }, label: { text: "Grade" } + = result_form.govuk_text_field :awarding_body, aria: { required: false }, form_group: { classes: "govuk-!-width-one-third" }, label: { text: "Awarding Body (optional)" } .govuk-form-group.button_to button.govuk-button.js-action.govuk-button--secondary class="govuk-!-margin-bottom-0" data-action="manage-qualifications#deleteRow" type="button" = "#{t('buttons.delete_subject')} #{idx + 1}" @@ -16,5 +19,3 @@ span class="govuk-!-margin-bottom-6 govuk-!-margin-top-0 js-action button_to" button.govuk-button.govuk-button--secondary id="add_subject" data-action="manage-qualifications#addRow" type="button" = t("buttons.add_another_subject") - -= f.govuk_number_field :year, label: { size: "s" }, aria: { required: true }, width: 4 diff --git a/app/views/jobseekers/qualifications/review/_secondary_qualification.html.slim b/app/views/jobseekers/qualifications/review/_secondary_qualification.html.slim index 65fd38161f..4e27b6d9d8 100644 --- a/app/views/jobseekers/qualifications/review/_secondary_qualification.html.slim +++ b/app/views/jobseekers/qualifications/review/_secondary_qualification.html.slim @@ -1,5 +1,5 @@ p class="govuk-!-margin-bottom-1" - = qualification.qualification_results.map { |result| "#{result.subject} (#{result.grade.upcase})" }.join(", ") + = qualification.qualification_results.map { |result| display_secondary_qualification(result) }.join(", ") p.govuk-caption-m - if qualification.display_attributes.include?("institution") diff --git a/config/analytics.yml b/config/analytics.yml index 3464b4c639..8a09a37546 100644 --- a/config/analytics.yml +++ b/config/analytics.yml @@ -303,6 +303,7 @@ shared: - qualification_id - subject - grade + - awarding_body - created_at - updated_at references: diff --git a/config/locales/forms.yml b/config/locales/forms.yml index cd2e59a051..e742692d17 100644 --- a/config/locales/forms.yml +++ b/config/locales/forms.yml @@ -437,7 +437,7 @@ en: true: "Yes" grade: Grade subject: Subject - year: Year qualification(s) was/were awarded + year: Year awarded jobseekers_job_application_details_reference_form: email: Email address job_title: Job title diff --git a/db/migrate/20250113144018_add_awarding_body_to_qualification_result.rb b/db/migrate/20250113144018_add_awarding_body_to_qualification_result.rb new file mode 100644 index 0000000000..7b7b5b4f9d --- /dev/null +++ b/db/migrate/20250113144018_add_awarding_body_to_qualification_result.rb @@ -0,0 +1,5 @@ +class AddAwardingBodyToQualificationResult < ActiveRecord::Migration[7.2] + def change + add_column :qualification_results, :awarding_body, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index abe02ee18a..83dbe867a8 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.2].define(version: 2025_01_13_131902) do +ActiveRecord::Schema[7.2].define(version: 2025_01_13_144018) do # These are extensions that must be enabled in order to support this database enable_extension "btree_gist" enable_extension "citext" @@ -514,6 +514,7 @@ t.string "grade", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.string "awarding_body" t.index ["qualification_id"], name: "index_qualification_results_on_qualification_id" end diff --git a/spec/support/jobseeker_helpers.rb b/spec/support/jobseeker_helpers.rb index 555630b4f0..9c7d26820f 100644 --- a/spec/support/jobseeker_helpers.rb +++ b/spec/support/jobseeker_helpers.rb @@ -109,10 +109,12 @@ def fill_in_reference def fill_in_gcses fill_in "jobseekers_qualifications_secondary_common_form[qualification_results_attributes][0][subject]", with: "Maths" fill_in "jobseekers_qualifications_secondary_common_form[qualification_results_attributes][0][grade]", with: "110%" + fill_in "jobseekers_qualifications_secondary_common_form[qualification_results_attributes][0][awarding_body]", with: "Cambridge Board" + find_by_id("add_subject").click fill_in "jobseekers_qualifications_secondary_common_form[qualification_results_attributes][1][subject]", with: "PE" fill_in "jobseekers_qualifications_secondary_common_form[qualification_results_attributes][1][grade]", with: "90%" fill_in "School, college, or other organisation", with: "Churchill School for Gifted Macaques" - fill_in "Year qualification(s) was/were awarded", with: "2020" + fill_in I18n.t("helpers.label.jobseekers_qualifications_shared_labels.year"), with: "2020" end def fill_in_custom_secondary_qualifications @@ -122,7 +124,7 @@ def fill_in_custom_secondary_qualifications fill_in "jobseekers_qualifications_secondary_other_form[qualification_results_attributes][1][subject]", with: "German" fill_in "jobseekers_qualifications_secondary_other_form[qualification_results_attributes][1][grade]", with: "4" fill_in "School, college, or other organisation", with: "Happy Rainbows School for High Achievers" - fill_in "Year qualification(s) was/were awarded", with: "2020" + fill_in I18n.t("helpers.label.jobseekers_qualifications_shared_labels.year"), with: "2020" end def fill_in_undergraduate_degree diff --git a/spec/system/jobseekers/jobseekers_can_add_qualifications_to_their_job_application_spec.rb b/spec/system/jobseekers/jobseekers_can_add_qualifications_to_their_job_application_spec.rb index 2ba6301fc3..ecfec05ff2 100644 --- a/spec/system/jobseekers/jobseekers_can_add_qualifications_to_their_job_application_spec.rb +++ b/spec/system/jobseekers/jobseekers_can_add_qualifications_to_their_job_application_spec.rb @@ -55,7 +55,7 @@ expect(current_path).to eq(jobseekers_job_application_build_path(job_application, :qualifications)) expect(page).to have_content("GCSEs") expect(page).to have_content("Churchill School for Gifted Macaques") - expect(page).to have_content("Maths – 110%") + expect(page).to have_content("Maths – 110% (Cambridge Board)") expect(page).to have_content("PE – 90%") expect(page).to have_content("2020") end From 0a321623abe9e9fc120a5eb5437900b5dc770edf Mon Sep 17 00:00:00 2001 From: Stephen Dicks Date: Tue, 14 Jan 2025 12:12:42 +0000 Subject: [PATCH 26/27] fix flakey test - need to freeze time to use Time.current (otherwise 1 second could elapse) (#7408) --- .../service_data/jobseeker_profiles_spec.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/spec/requests/support_users/service_data/jobseeker_profiles_spec.rb b/spec/requests/support_users/service_data/jobseeker_profiles_spec.rb index a06720b4ca..f02c8c9078 100644 --- a/spec/requests/support_users/service_data/jobseeker_profiles_spec.rb +++ b/spec/requests/support_users/service_data/jobseeker_profiles_spec.rb @@ -28,11 +28,13 @@ end it "gets their access to a Jobseeker Profile logged" do - allow(Rails.logger).to receive(:info).with(anything) - expect(Rails.logger).to receive(:info) - .with("[Service Data] #{support_user.email} accessed Profile ID #{jobseeker_profile.id} at #{Time.current}") + freeze_time do + allow(Rails.logger).to receive(:info).with(anything) + expect(Rails.logger).to receive(:info) + .with("[Service Data] #{support_user.email} accessed Profile ID #{jobseeker_profile.id} at #{Time.current}") - get support_users_service_data_jobseeker_profile_path(jobseeker_profile) + get support_users_service_data_jobseeker_profile_path(jobseeker_profile) + end end end From 9af5aeb777a65ece5623f9ef537142868c72cd32 Mon Sep 17 00:00:00 2001 From: Marc Sardon Date: Tue, 14 Jan 2025 13:42:37 +0000 Subject: [PATCH 27/27] Clean Alerts with "delete_all" The destroy_all call was not adequate for the high volume of data, as instantiates each record in memory. Delete all executes everything with a single SQL query (what I originally intended and missed). --- app/jobs/delete_old_alert_runs_job.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/jobs/delete_old_alert_runs_job.rb b/app/jobs/delete_old_alert_runs_job.rb index 738685955f..bbb218ae75 100644 --- a/app/jobs/delete_old_alert_runs_job.rb +++ b/app/jobs/delete_old_alert_runs_job.rb @@ -2,6 +2,6 @@ class DeleteOldAlertRunsJob < ApplicationJob queue_as :low def perform - AlertRun.where(run_on: ...1.week.ago).destroy_all + AlertRun.where(run_on: ...1.week.ago).delete_all end end