From 14492d22be5fe2a2451fbe10d7402c78d78a8f43 Mon Sep 17 00:00:00 2001 From: Phil Lee Date: Thu, 27 Jun 2024 17:45:40 +0100 Subject: [PATCH] add poor performance form to FE journey --- .../poor_performance_form.rb | 34 +++++++++++ .../journeys/further_education_payments.rb | 3 +- .../session_answers.rb | 2 + .../claims/poor_performance.html.erb | 34 +++++++++-- config/locales/en.yml | 14 +++++ .../happy_js_path_spec.rb | 9 ++- .../happy_path_spec.rb | 9 ++- .../poor_performance_form_spec.rb | 57 +++++++++++++++++++ 8 files changed, 153 insertions(+), 9 deletions(-) create mode 100644 app/forms/journeys/further_education_payments/poor_performance_form.rb create mode 100644 spec/forms/journeys/further_education_payments/poor_performance_form_spec.rb diff --git a/app/forms/journeys/further_education_payments/poor_performance_form.rb b/app/forms/journeys/further_education_payments/poor_performance_form.rb new file mode 100644 index 0000000000..15fb1c728f --- /dev/null +++ b/app/forms/journeys/further_education_payments/poor_performance_form.rb @@ -0,0 +1,34 @@ +module Journeys + module FurtherEducationPayments + class PoorPerformanceForm < Form + attribute :subject_to_formal_performance_action, :boolean + attribute :subject_to_disciplinary_action, :boolean + + validates :subject_to_formal_performance_action, inclusion: {in: [true, false], message: i18n_error_message("performance.inclusion")} + validates :subject_to_disciplinary_action, inclusion: {in: [true, false], message: i18n_error_message("disciplinary.inclusion")} + + def radio_options + [ + OpenStruct.new( + id: true, + name: "Yes" + ), + OpenStruct.new( + id: false, + name: "No" + ) + ] + end + + def save + return false if invalid? + + journey_session.answers.assign_attributes( + subject_to_formal_performance_action:, + subject_to_disciplinary_action: + ) + journey_session.save! + end + end + end +end diff --git a/app/models/journeys/further_education_payments.rb b/app/models/journeys/further_education_payments.rb index 831bde3558..237b70294a 100644 --- a/app/models/journeys/further_education_payments.rb +++ b/app/models/journeys/further_education_payments.rb @@ -12,7 +12,8 @@ module FurtherEducationPayments "teaching-responsibilities" => TeachingResponsibilitiesForm, "further-education-provision-search" => FurtherEducationProvisionSearchForm, "select-provision" => SelectProvisionForm, - "subjects-taught" => SubjectsTaughtForm + "subjects-taught" => SubjectsTaughtForm, + "poor-performance" => PoorPerformanceForm } } end diff --git a/app/models/journeys/further_education_payments/session_answers.rb b/app/models/journeys/further_education_payments/session_answers.rb index 07cedd8d3d..e52e4afc26 100644 --- a/app/models/journeys/further_education_payments/session_answers.rb +++ b/app/models/journeys/further_education_payments/session_answers.rb @@ -5,6 +5,8 @@ class SessionAnswers < Journeys::SessionAnswers attribute :provision_search, :string attribute :school_id, :string # GUID attribute :subjects_taught, default: [] + attribute :subject_to_formal_performance_action, :boolean + attribute :subject_to_disciplinary_action, :boolean end end end diff --git a/app/views/further_education_payments/claims/poor_performance.html.erb b/app/views/further_education_payments/claims/poor_performance.html.erb index f346f2a49f..48323259eb 100644 --- a/app/views/further_education_payments/claims/poor_performance.html.erb +++ b/app/views/further_education_payments/claims/poor_performance.html.erb @@ -1,7 +1,29 @@ -

- FE poor performance goes here -

+
+
+ <%= form_with model: @form, url: claim_path(current_journey_routing_name), method: :patch, builder: GOVUKDesignSystemFormBuilder::FormBuilder, html: { novalidate: false } do |f| %> + <%= f.govuk_error_summary %> -<%= form_with model: @form, url: claim_path(current_journey_routing_name), method: :patch, builder: GOVUKDesignSystemFormBuilder::FormBuilder, html: { novalidate: false } do |f| %> - <%= f.govuk_submit %> -<% end %> +

+ <%= @form.t(:heading) %> +

+ + <%= f.govuk_collection_radio_buttons :subject_to_formal_performance_action, @form.radio_options, :id, :name, + legend: { + text: @form.t("questions.performance.question"), + tag: "h2", + size: "m" + }, + hint: { text: @form.t("questions.performance.hint") } %> + + <%= f.govuk_collection_radio_buttons :subject_to_disciplinary_action, @form.radio_options, :id, :name, + legend: { + text: @form.t("questions.disciplinary.question"), + tag: "h2", + size: "m" + }, + hint: { text: @form.t("questions.disciplinary.hint") } %> + + <%= f.govuk_submit %> + <% end %> +
+
diff --git a/config/locales/en.yml b/config/locales/en.yml index 1c9fb284fc..1b5ced18e9 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -800,6 +800,20 @@ en: hint: Select all that apply errors: inclusion: Select the subject areas you teach in or select you do not teach any of the listed subject areas + poor_performance: + heading: Tell us if you are currently under any performance measures or disciplinary action + questions: + performance: + question: Have any performance measures been started against you? + hint: This will be as a result of your underperformance as a teacher over a period of time. It could put your employment at the further education (FE) provider at risk and is something we may check with them as it will affect your eligibility. + disciplinary: + question: Are you currently subject to disciplinary action? + hint: This is more serious than performance measures and could be because of misconduct. It is something we may check with your FE provider as it will affect your eligibility. + errors: + performance: + inclusion: Select yes if you are subject to formal action for poor performance at work + disciplinary: + inclusion: Select yes if you are subject to disciplinary action activerecord: errors: models: diff --git a/spec/features/further_education_payments/happy_js_path_spec.rb b/spec/features/further_education_payments/happy_js_path_spec.rb index f3eb04fc25..e65628c8de 100644 --- a/spec/features/further_education_payments/happy_js_path_spec.rb +++ b/spec/features/further_education_payments/happy_js_path_spec.rb @@ -51,7 +51,14 @@ expect(page).to have_content("FE qualification goes here") click_button "Continue" - expect(page).to have_content("FE poor performance goes here") + expect(page).to have_content("Have any performance measures been started against you?") + within all(".govuk-fieldset")[0] do + choose("No") + end + expect(page).to have_content("Are you currently subject to disciplinary action?") + within all(".govuk-fieldset")[1] do + choose("No") + end click_button "Continue" expect(page).to have_content("FE check your answers goes here") diff --git a/spec/features/further_education_payments/happy_path_spec.rb b/spec/features/further_education_payments/happy_path_spec.rb index 03bd448a56..2f932a585b 100644 --- a/spec/features/further_education_payments/happy_path_spec.rb +++ b/spec/features/further_education_payments/happy_path_spec.rb @@ -48,7 +48,14 @@ expect(page).to have_content("FE qualification goes here") click_button "Continue" - expect(page).to have_content("FE poor performance goes here") + expect(page).to have_content("Have any performance measures been started against you?") + within all(".govuk-fieldset")[0] do + choose("No") + end + expect(page).to have_content("Are you currently subject to disciplinary action?") + within all(".govuk-fieldset")[1] do + choose("No") + end click_button "Continue" expect(page).to have_content("FE check your answers goes here") diff --git a/spec/forms/journeys/further_education_payments/poor_performance_form_spec.rb b/spec/forms/journeys/further_education_payments/poor_performance_form_spec.rb new file mode 100644 index 0000000000..c294d5e4ff --- /dev/null +++ b/spec/forms/journeys/further_education_payments/poor_performance_form_spec.rb @@ -0,0 +1,57 @@ +require "rails_helper" + +RSpec.describe Journeys::FurtherEducationPayments::PoorPerformanceForm, type: :model do + let(:journey) { Journeys::FurtherEducationPayments } + let(:journey_session) { create(:further_education_payments_session) } + let(:subject_to_formal_performance_action) { nil } + let(:subject_to_disciplinary_action) { nil } + + let(:params) do + ActionController::Parameters.new( + claim: { + subject_to_formal_performance_action:, + subject_to_disciplinary_action: + } + ) + end + + subject do + described_class.new( + journey_session:, + journey:, + params: + ) + end + + describe "validations" do + context "when no options selected" do + it do + is_expected.not_to( + allow_value(nil) + .for(:subject_to_formal_performance_action) + .with_message("Select yes if you are subject to formal action for poor performance at work") + ) + end + + it do + is_expected.not_to( + allow_value(nil) + .for(:subject_to_disciplinary_action) + .with_message("Select yes if you are subject to disciplinary action") + ) + end + end + end + + describe "#save" do + let(:subject_to_formal_performance_action) { "true" } + let(:subject_to_disciplinary_action) { "false" } + + it "updates the journey session" do + expect { expect(subject.save).to be(true) }.to( + change { journey_session.reload.answers.subject_to_formal_performance_action }.to(true) + .and change { journey_session.reload.answers.subject_to_disciplinary_action }.to(false) + ) + end + end +end