Skip to content

Commit

Permalink
LUPEYALPHA-553 - add half-teaching-hours page/form to FE journey
Browse files Browse the repository at this point in the history
  • Loading branch information
kenfodder committed Jun 28, 2024
1 parent 2653b1a commit dfb3bc6
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion app/models/journeys/further_education_payments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ module FurtherEducationPayments
"teaching-responsibilities" => TeachingResponsibilitiesForm,
"further-education-provision-search" => FurtherEducationProvisionSearchForm,
"select-provision" => SelectProvisionForm,
"subjects-taught" => SubjectsTaughtForm
"subjects-taught" => SubjectsTaughtForm,
"half-teaching-hours" => HalfTeachingHoursForm
}
}
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class SessionAnswers < Journeys::SessionAnswers
attribute :provision_search, :string
attribute :school_id, :string # GUID
attribute :subjects_taught, default: []
attribute :half_teaching_hours, :boolean
end
end
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
<p class="govuk-body">
FE half teaching hours goes here
</p>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= 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 %>
<h1 class="govuk-heading-l">
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)?
</h1>

<p class="govuk-body">
To apply, at least 50% of your timetabled teaching hours must include either:
</p>

<%= 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 %>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
Expand Down
3 changes: 3 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,9 @@ 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
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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("FE qualification goes here")
Expand Down
3 changes: 2 additions & 1 deletion spec/features/further_education_payments/happy_path_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,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("FE qualification goes here")
Expand Down
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit dfb3bc6

Please sign in to comment.