Skip to content

Commit

Permalink
Merge pull request #2927 from DFE-Digital/fe-teaching-hours-per-week
Browse files Browse the repository at this point in the history
[LUPEYALPHA-549] Add teaching hours per week to FE journey
  • Loading branch information
asmega authored Jul 2, 2024
2 parents db317ae + 1a378d8 commit 594526f
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module Journeys
module FurtherEducationPayments
class TeachingHoursPerWeekForm < Form
attribute :teaching_hours_per_week, :string

validates :teaching_hours_per_week,
inclusion: {in: ->(form) { form.radio_options.map(&:id) }, message: i18n_error_message(:inclusion)}

def radio_options
@radio_options ||= [
OpenStruct.new(
id: "more-than-12",
name: "More than 12 hours per week"
),
OpenStruct.new(
id: "between-2.5-and-12",
name: "Between 2.5 and 12 hours per week"
),
OpenStruct.new(
id: "less-than-2.5",
name: "Less than 2.5 hours per week"
)
]
end

def save
return false unless valid?

journey_session.answers.assign_attributes(teaching_hours_per_week:)
journey_session.save!
end
end
end
end
1 change: 1 addition & 0 deletions app/models/journeys/further_education_payments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module FurtherEducationPayments
"further-education-provision-search" => FurtherEducationProvisionSearchForm,
"select-provision" => SelectProvisionForm,
"contract-type" => ContractTypeForm,
"teaching-hours-per-week" => TeachingHoursPerWeekForm,
"further-education-teaching-start-year" => FurtherEducationTeachingStartYearForm,
"subjects-taught" => SubjectsTaughtForm
}
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 :contract_type, :string
attribute :teaching_hours_per_week, :string
attribute :further_education_teaching_start_year, :string
attribute :subjects_taught, default: []

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
<p class="govuk-body">
FE teaching hours per week 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 %>
<%= f.govuk_collection_radio_buttons :teaching_hours_per_week, @form.radio_options, :id, :name,
legend: {
text: @form.t(:question, school_name: journey_session.answers.school.name),
tag: "h1",
size: "l"
},
hint: { text: @form.t(:hint) } %>

<%= f.govuk_submit %>
<% end %>
</div>
</div>
5 changes: 5 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,11 @@ en:
question: What type of contract do you have with %{school_name}?
errors:
inclusion: Select the contract type you have
teaching_hours_per_week:
question: On average, how many hours per week are you timetabled to teach at %{school_name} during the current term?
hint: ‘Teaching’ refers to the direct contact time you spend in lessons with students of all ages.
errors:
inclusion: Select how many hours per week you are timetabled to teach during the current term
further_education_teaching_start_year:
errors:
blank: Select which academic year you started teaching in further education in England
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
choose("Permanent contract")
click_button "Continue"

expect(page).to have_content("FE teaching hours per week goes here")
expect(page).to have_content("On average, how many hours per week are you timetabled to teach at #{college.name} during the current term?")
choose("More than 12 hours per week")
click_button "Continue"

expect(page).to have_content("Which academic year did you start teaching in further education (FE) in England?")
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 @@ -27,7 +27,8 @@
choose("Permanent contract")
click_button "Continue"

expect(page).to have_content("FE teaching hours per week goes here")
expect(page).to have_content("On average, how many hours per week are you timetabled to teach at #{college.name} during the current term?")
choose("More than 12 hours per week")
click_button "Continue"

expect(page).to have_content("Which academic year did you start teaching in further education (FE) in England?")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
require "rails_helper"

RSpec.describe Journeys::FurtherEducationPayments::TeachingHoursPerWeekForm, type: :model do
let(:journey) { Journeys::FurtherEducationPayments }
let(:journey_session) { create(:further_education_payments_session, answers:) }
let(:answers) { build(:further_education_payments_answers, answers_hash) }
let(:college) { create(:school) }
let(:answers_hash) do
{school_id: college.id}
end
let(:teaching_hours_per_week) { nil }

let(:params) do
ActionController::Parameters.new(
claim: {
teaching_hours_per_week:
}
)
end

subject do
described_class.new(
journey_session:,
journey:,
params:
)
end

describe "validations" do
let(:teaching_hours_per_week) { nil }

it do
is_expected.not_to(
allow_value(nil)
.for(:teaching_hours_per_week)
.with_message("Select how many hours per week you are timetabled to teach during the current term")
)
end
end

describe "#save" do
let(:teaching_hours_per_week) { "more-than-12" }

it "updates the journey session" do
expect { expect(subject.save).to be(true) }.to(
change { journey_session.reload.answers.teaching_hours_per_week }.to(teaching_hours_per_week)
)
end
end
end

0 comments on commit 594526f

Please sign in to comment.