From 20cf947dfac2b766f593903af7cbda261be0d5c4 Mon Sep 17 00:00:00 2001 From: Kenneth Lee Date: Thu, 27 Jun 2024 18:52:47 +0100 Subject: [PATCH] LUPEYALPHA-553 - add half-teaching-hours page/form to FE journey --- .../half_teaching_hours_form.rb | 27 +++++++++ .../journeys/further_education_payments.rb | 3 +- .../session_answers.rb | 1 + .../claims/half_teaching_hours.html.erb | 29 ++++++++-- .../claims/teaching_responsibilities.html.erb | 4 +- config/locales/en.yml | 3 + .../happy_js_path_spec.rb | 3 +- .../happy_path_spec.rb | 3 +- .../half_teaching_hours_form_spec.rb | 58 +++++++++++++++++++ 9 files changed, 120 insertions(+), 11 deletions(-) create mode 100644 app/forms/journeys/further_education_payments/half_teaching_hours_form.rb create mode 100644 spec/forms/journeys/further_education_payments/half_teaching_hours_form_spec.rb diff --git a/app/forms/journeys/further_education_payments/half_teaching_hours_form.rb b/app/forms/journeys/further_education_payments/half_teaching_hours_form.rb new file mode 100644 index 0000000000..8d540e34b5 --- /dev/null +++ b/app/forms/journeys/further_education_payments/half_teaching_hours_form.rb @@ -0,0 +1,27 @@ +module Journeys + module FurtherEducationPayments + class HalfTeachingHoursForm < Form + attribute :half_teaching_hours, :boolean + + validates :half_teaching_hours, + inclusion: { + in: [true, false], + message: i18n_error_message(:inclusion) + } + + def radio_options + [ + OpenStruct.new(id: true, name: "Yes"), + OpenStruct.new(id: false, name: "No") + ] + end + + def save + return false unless valid? + + journey_session.answers.assign_attributes(half_teaching_hours:) + 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 0a417d8184..dce4f4a286 100644 --- a/app/models/journeys/further_education_payments.rb +++ b/app/models/journeys/further_education_payments.rb @@ -19,7 +19,8 @@ module FurtherEducationPayments "teaching-qualification" => TeachingQualificationForm, "poor-performance" => PoorPerformanceForm, "check-your-answers" => CheckYourAnswersForm, - "ineligible" => IneligibleForm + "ineligible" => IneligibleForm, + "half-teaching-hours" => HalfTeachingHoursForm } } end diff --git a/app/models/journeys/further_education_payments/session_answers.rb b/app/models/journeys/further_education_payments/session_answers.rb index 3ef62aa669..5655f7d3f4 100644 --- a/app/models/journeys/further_education_payments/session_answers.rb +++ b/app/models/journeys/further_education_payments/session_answers.rb @@ -11,6 +11,7 @@ class SessionAnswers < Journeys::SessionAnswers attribute :teaching_qualification, :string attribute :subject_to_formal_performance_action, :boolean attribute :subject_to_disciplinary_action, :boolean + attribute :half_teaching_hours, :boolean def school @school ||= School.find(school_id) diff --git a/app/views/further_education_payments/claims/half_teaching_hours.html.erb b/app/views/further_education_payments/claims/half_teaching_hours.html.erb index fba0dba654..5a56a778e6 100644 --- a/app/views/further_education_payments/claims/half_teaching_hours.html.erb +++ b/app/views/further_education_payments/claims/half_teaching_hours.html.erb @@ -1,7 +1,24 @@ -

- FE half teaching hours 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 %> +

+ Are at least half of your timetabled teaching hours spent teaching 16 to 19-year-olds, including those up to age 25 with an Education, Health and Care Plan (EHCP)? +

+ +

+ To apply, at least 50% of your timetabled teaching hours must include either: +

+ + <%= govuk_list [ + "a student aged 16 to 19", + "a person up to age 25 with an #{govuk_link_to("Education, Health and Care Plan (EHCP)", "https://www.gov.uk/children-with-special-educational-needs/extra-SEN-help", target: "_blank")}".html_safe + ], type: :bullet %> + + <%= f.govuk_collection_radio_buttons :half_teaching_hours, @form.radio_options, :id, :name, legend: { hidden: true } %> + + <%= f.govuk_submit %> + <% end %> +
+
diff --git a/app/views/further_education_payments/claims/teaching_responsibilities.html.erb b/app/views/further_education_payments/claims/teaching_responsibilities.html.erb index 335934096b..31b343b3f5 100644 --- a/app/views/further_education_payments/claims/teaching_responsibilities.html.erb +++ b/app/views/further_education_payments/claims/teaching_responsibilities.html.erb @@ -23,8 +23,8 @@ "tutor" ], type: :bullet %> - <%= f.govuk_collection_radio_buttons :teaching_responsibilities, @form.radio_options, :id, :name, - legend: { text: "Are you a member of staff with teaching responsibilities?" } %> + <%= f.govuk_collection_radio_buttons :teaching_responsibilities, @form.radio_options, :id, :name, + legend: { text: "Are you a member of staff with teaching responsibilities?" } %> <%= f.govuk_submit %> <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 98f52827ee..5a793f3aef 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -841,6 +841,9 @@ en: 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 + half_teaching_hours: + errors: + inclusion: Select yes if at least half your timetabled teaching hours are spent teaching 16-19-year-olds, including those up to 25 with an Education, Health and Care Plan 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 31f3c45586..ded799408f 100644 --- a/spec/features/further_education_payments/happy_js_path_spec.rb +++ b/spec/features/further_education_payments/happy_js_path_spec.rb @@ -48,7 +48,8 @@ expect(page).to have_content("FE teaching courses goes here") click_button "Continue" - expect(page).to have_content("FE half teaching hours goes here") + expect(page).to have_content("Are at least half of your timetabled teaching hours spent teaching 16 to 19-year-olds, including those up to age 25 with an Education, Health and Care Plan (EHCP)?") + choose "Yes" click_button "Continue" expect(page).to have_content("Do you have a teaching qualification?") diff --git a/spec/features/further_education_payments/happy_path_spec.rb b/spec/features/further_education_payments/happy_path_spec.rb index 66d673dbe8..06a9feb9f6 100644 --- a/spec/features/further_education_payments/happy_path_spec.rb +++ b/spec/features/further_education_payments/happy_path_spec.rb @@ -45,7 +45,8 @@ expect(page).to have_content("FE teaching courses goes here") click_button "Continue" - expect(page).to have_content("FE half teaching hours goes here") + expect(page).to have_content("Are at least half of your timetabled teaching hours spent teaching 16 to 19-year-olds, including those up to age 25 with an Education, Health and Care Plan (EHCP)?") + choose "Yes" click_button "Continue" expect(page).to have_content("Do you have a teaching qualification?") diff --git a/spec/forms/journeys/further_education_payments/half_teaching_hours_form_spec.rb b/spec/forms/journeys/further_education_payments/half_teaching_hours_form_spec.rb new file mode 100644 index 0000000000..e23d1c1be6 --- /dev/null +++ b/spec/forms/journeys/further_education_payments/half_teaching_hours_form_spec.rb @@ -0,0 +1,58 @@ +require "rails_helper" + +RSpec.describe Journeys::FurtherEducationPayments::HalfTeachingHoursForm, type: :model do + let(:journey) { Journeys::FurtherEducationPayments } + let(:journey_session) { create(:further_education_payments_session) } + + let(:params) do + ActionController::Parameters.new( + claim: { + half_teaching_hours: + } + ) + end + + subject do + described_class.new( + journey_session:, + journey:, + params: + ) + end + + describe "validations" do + let(:half_teaching_hours) { nil } + + it do + is_expected.not_to( + allow_value(nil) + .for(:half_teaching_hours) + .with_message("Select yes if at least half your timetabled teaching hours are spent teaching 16-19-year-olds, including those up to 25 with an Education, Health and Care Plan") + ) + end + end + + describe "#save" do + context "Yes" do + let(:half_teaching_hours) { true } + + it "updates the journey session" do + expect { expect(subject.save).to be(true) }.to( + change { journey_session.reload.answers.half_teaching_hours } + .to(true) + ) + end + end + + context "No" do + let(:half_teaching_hours) { false } + + it "updates the journey session" do + expect { expect(subject.save).to be(true) }.to( + change { journey_session.reload.answers.half_teaching_hours } + .to(false) + ) + end + end + end +end