Skip to content

Commit

Permalink
add poor performance form to FE journey
Browse files Browse the repository at this point in the history
  • Loading branch information
asmega committed Jun 27, 2024
1 parent 123eea5 commit 14492d2
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -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
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,
"poor-performance" => PoorPerformanceForm
}
}
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -1,7 +1,29 @@
<p class="govuk-body">
FE poor performance 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">
<%= @form.t(:heading) %>
</h1>

<%= 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 %>
</div>
</div>
14 changes: 14 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
9 changes: 8 additions & 1 deletion spec/features/further_education_payments/happy_path_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 14492d2

Please sign in to comment.