diff --git a/app/controllers/claims_controller.rb b/app/controllers/claims_controller.rb index a4c4310e77..b141367917 100644 --- a/app/controllers/claims_controller.rb +++ b/app/controllers/claims_controller.rb @@ -82,8 +82,6 @@ def update case params[:slug] when "select-claim-school" check_select_claim_school_params - when "still-teaching" - check_still_teaching_params else current_claim.attributes = claim_params end @@ -248,11 +246,6 @@ def check_select_claim_school_params current_claim.attributes = updated_claim_params end - def check_still_teaching_params - updated_claim_params = StillTeachingForm.extract_params(claim_params) - current_claim.attributes = updated_claim_params - end - def retrieve_student_loan_details # student loan details are currently retrieved for TSLR and ECP/LUPP journeys only return unless ["student-loans", "additional-payments"].include?(current_journey_routing_name) diff --git a/app/forms/form.rb b/app/forms/form.rb index c4801f7a59..5ca61d304e 100644 --- a/app/forms/form.rb +++ b/app/forms/form.rb @@ -45,9 +45,9 @@ def backlink_path .claim_path(params[:journey], page_sequence.previous_slug) end - def i18n_errors_path(msg) + def i18n_errors_path(msg, args = {}) base_key = :"forms.#{i18n_form_namespace}.errors.#{msg}" - I18n.t("#{i18n_namespace}.#{base_key}", default: base_key) + I18n.t("#{i18n_namespace}.#{base_key}", default: base_key, **args) end def permitted_params diff --git a/app/forms/journeys/teacher_student_loan_reimbursement/still_teaching_form.rb b/app/forms/journeys/teacher_student_loan_reimbursement/still_teaching_form.rb new file mode 100644 index 0000000000..4c21e076b5 --- /dev/null +++ b/app/forms/journeys/teacher_student_loan_reimbursement/still_teaching_form.rb @@ -0,0 +1,44 @@ +module Journeys + module TeacherStudentLoanReimbursement + class StillTeachingForm < Form + attribute :employment_status + attribute :current_school_id + + validates :employment_status, presence: {message: ->(form, _) { form.error_message }} + + def save + return false unless valid? + + update!( + eligibility_attributes: { + employment_status:, + current_school_id: currently_at_school? ? current_school_id : nil + } + ) + end + + def school + claim.logged_in_with_tid_and_has_recent_tps_school? ? claim.recent_tps_school : claim.eligibility.claim_school + end + + def error_message + if school.open? + i18n_errors_path("select_which_school_currently", school_name: school.name) + else + i18n_errors_path("select_are_you_still_employed") + end + end + + # Helper used in the view to choose partials and locale keys + def tps_or_claim_school + claim.logged_in_with_tid_and_has_recent_tps_school? ? "tps_school" : "claim_school" + end + + private + + def currently_at_school? + %w[claim_school recent_tps_school].include?(employment_status) + end + end + end +end diff --git a/app/forms/still_teaching_form.rb b/app/forms/still_teaching_form.rb deleted file mode 100644 index a1234f50c8..0000000000 --- a/app/forms/still_teaching_form.rb +++ /dev/null @@ -1,18 +0,0 @@ -class StillTeachingForm - def self.extract_params(claim_params) - new(claim_params).extract_params - end - - def initialize(claim_params) - @updated_claim_params = claim_params - end - - def extract_params - # current_school_id is in a hidden field, we only want this if the teacher selected the suggested school playback - unless %w[claim_school recent_tps_school].include?(@updated_claim_params.dig(:eligibility_attributes, :employment_status)) - @updated_claim_params[:eligibility_attributes][:current_school_id] = nil - end - - @updated_claim_params - end -end diff --git a/app/models/journeys/teacher_student_loan_reimbursement.rb b/app/models/journeys/teacher_student_loan_reimbursement.rb index 2766150552..0b65bef122 100644 --- a/app/models/journeys/teacher_student_loan_reimbursement.rb +++ b/app/models/journeys/teacher_student_loan_reimbursement.rb @@ -15,6 +15,7 @@ module TeacherStudentLoanReimbursement "qualification-details" => QualificationDetailsForm, "qts-year" => QtsYearForm, "subjects-taught" => SubjectsTaughtForm, + "still-teaching" => StillTeachingForm, "leadership-position" => LeadershipPositionForm, "mostly-performed-leadership-duties" => MostlyPerformedLeadershipDutiesForm, "reset-claim" => ResetClaimForm, diff --git a/app/models/journeys/teacher_student_loan_reimbursement/answers_presenter.rb b/app/models/journeys/teacher_student_loan_reimbursement/answers_presenter.rb index 9b29b5a389..e8de1c8c76 100644 --- a/app/models/journeys/teacher_student_loan_reimbursement/answers_presenter.rb +++ b/app/models/journeys/teacher_student_loan_reimbursement/answers_presenter.rb @@ -45,7 +45,7 @@ def claim_school def current_school [ - t("student_loans.forms.still_teaching.questions.which_school_currently"), + t("student_loans.forms.still_teaching.questions.tps_school"), eligibility.current_school_name, "still-teaching" ] diff --git a/app/models/policies/student_loans/eligibility.rb b/app/models/policies/student_loans/eligibility.rb index 9b9de515d2..79bdb0e620 100644 --- a/app/models/policies/student_loans/eligibility.rb +++ b/app/models/policies/student_loans/eligibility.rb @@ -49,7 +49,7 @@ class Eligibility < ApplicationRecord belongs_to :current_school, optional: true, class_name: "School" validates :claim_school, on: [:"select-claim-school"], presence: {message: ->(object, _data) { object.select_claim_school_presence_error_message }}, unless: :claim_school_somewhere_else? - validates :employment_status, on: [:"still-teaching", :submit], presence: {message: ->(object, _data) { "Select if you still work at #{object.claim_school_name}, another school or no longer teach in England" }} + validates :employment_status, on: [:submit], presence: {message: ->(object, _data) { "Select if you still work at #{object.claim_school_name}, another school or no longer teach in England" }} validates :had_leadership_position, on: [:submit], inclusion: {in: [true, false], message: "Select yes if you were employed in a leadership position"} validates :mostly_performed_leadership_duties, on: [:submit], inclusion: {in: [true, false], message: "Select yes if you spent more than half your working hours on leadership duties"}, if: :had_leadership_position? validates_numericality_of :student_loan_repayment_amount, message: "Enter a valid monetary amount", allow_nil: true, greater_than_or_equal_to: 0, less_than_or_equal_to: 99999 diff --git a/app/views/student_loans/claims/_still_teaching_with_claim_school.html.erb b/app/views/student_loans/claims/_still_teaching_with_claim_school.html.erb index 52c5025774..a8038540e4 100644 --- a/app/views/student_loans/claims/_still_teaching_with_claim_school.html.erb +++ b/app/views/student_loans/claims/_still_teaching_with_claim_school.html.erb @@ -1,23 +1,23 @@ -<% if claim_school.open? %> - <%= fields.hidden_field :current_school_id, value: claim_school.id %> +<% if school.open? %> + <%= form.hidden_field :current_school_id, value: school.id %>
- <%= fields.radio_button(:employment_status, :claim_school, class: "govuk-radios__input") %> - <%= fields.label :employment_status_claim_school, "Yes, at #{claim_school.name}", class: "govuk-label govuk-radios__label" %> + <%= form.radio_button(:employment_status, :claim_school, class: "govuk-radios__input") %> + <%= form.label :employment_status_claim_school, "Yes, at #{school.name}", class: "govuk-label govuk-radios__label" %>
- <%= fields.radio_button(:employment_status, :different_school, class: "govuk-radios__input") %> - <%= fields.label :employment_status_different_school, "Yes, at another school", class: "govuk-label govuk-radios__label" %> + <%= form.radio_button(:employment_status, :different_school, class: "govuk-radios__input") %> + <%= form.label :employment_status_different_school, "Yes, at another school", class: "govuk-label govuk-radios__label" %>
<% else %>
- <%= fields.radio_button(:employment_status, :different_school, class: "govuk-radios__input") %> - <%= fields.label :employment_status_different_school, "Yes", class: "govuk-label govuk-radios__label" %> + <%= form.radio_button(:employment_status, :different_school, class: "govuk-radios__input") %> + <%= form.label :employment_status_different_school, "Yes", class: "govuk-label govuk-radios__label" %>
<% end %>
- <%= fields.radio_button(:employment_status, :no_school, class: "govuk-radios__input") %> - <%= fields.label :employment_status_no_school, "No", class: "govuk-label govuk-radios__label" %> + <%= form.radio_button(:employment_status, :no_school, class: "govuk-radios__input") %> + <%= form.label :employment_status_no_school, "No", class: "govuk-label govuk-radios__label" %>
diff --git a/app/views/student_loans/claims/_still_teaching_with_tps_school.html.erb b/app/views/student_loans/claims/_still_teaching_with_tps_school.html.erb index 85cffa87be..64cf099c1c 100644 --- a/app/views/student_loans/claims/_still_teaching_with_tps_school.html.erb +++ b/app/views/student_loans/claims/_still_teaching_with_tps_school.html.erb @@ -1,21 +1,21 @@ -<%= fields.hidden_field :current_school_id, value: current_school.id %> +<%= form.hidden_field :current_school_id, value: school.id %>
- <%= fields.radio_button(:employment_status, :recent_tps_school, class: "govuk-radios__input") %> - <%= fields.label :employment_status_recent_tps_school, "Yes, at #{current_school.name}", class: "govuk-label govuk-radios__label" %> + <%= form.radio_button(:employment_status, :recent_tps_school, class: "govuk-radios__input") %> + <%= form.label :employment_status_recent_tps_school, "Yes, at #{school.name}", class: "govuk-label govuk-radios__label" %>
- <%= current_school.address %> + <%= school.address %>
- <%= fields.radio_button(:employment_status, :different_school, class: "govuk-radios__input") %> - <%= fields.label :employment_status_different_school, "Somewhere else", class: "govuk-label govuk-radios__label" %> + <%= form.radio_button(:employment_status, :different_school, class: "govuk-radios__input") %> + <%= form.label :employment_status_different_school, "Somewhere else", class: "govuk-label govuk-radios__label" %>
or
- <%= fields.radio_button(:employment_status, :no_school, class: "govuk-radios__input") %> - <%= fields.label :employment_status_no_school, "I'm no longer employed to teach at a state-funded secondary school in England", class: "govuk-label govuk-radios__label" %> + <%= form.radio_button(:employment_status, :no_school, class: "govuk-radios__input") %> + <%= form.label :employment_status_no_school, "I'm no longer employed to teach at a state-funded secondary school in England", class: "govuk-label govuk-radios__label" %>
diff --git a/app/views/student_loans/claims/still_teaching.html.erb b/app/views/student_loans/claims/still_teaching.html.erb index 13868d346f..ff6b232980 100644 --- a/app/views/student_loans/claims/still_teaching.html.erb +++ b/app/views/student_loans/claims/still_teaching.html.erb @@ -1,34 +1,24 @@ -<% content_for(:page_title, page_title(t("student_loans.questions.employment_status"), journey: current_journey_routing_name, show_error: current_claim.errors.any?)) %> +<% content_for(:page_title, page_title(t("student_loans.forms.still_teaching.questions.#{@form.tps_or_claim_school}"), journey: current_journey_routing_name, show_error: @form.errors.any?)) %>
- <%= render("shared/error_summary", instance: current_claim, errored_field_id_overrides: { "eligibility.employment_status": "claim_eligibility_attributes_employment_status_claim_school" }) if current_claim.errors.any? %> + <%= render("shared/error_summary", instance: @form, errored_field_id_overrides: { "employment_status": "claim_employment_status_claim_school" }) if @form.errors.any? %> - <%= form_for current_claim, url: claim_path(current_journey_routing_name) do |form| %> - <%= form_group_tag current_claim do %> - <%= form.fields_for :eligibility, include_id: false do |fields| %> -
- - <% if current_claim.logged_in_with_tid_and_has_recent_tps_school? %> -

<%= t("student_loans.forms.still_teaching.questions.which_school_currently") %>

- <% else %> -

<%= t("student_loans.questions.employment_status") %>

- <% end %> -
+ <%= form_for @form, url: claim_path(current_journey_routing_name) do |form| %> + <%= form_group_tag @form do %> +
+ +

<%= t("student_loans.forms.still_teaching.questions.#{@form.tps_or_claim_school}") %>

+
- <%= errors_tag current_claim.eligibility, :employment_status %> + <%= errors_tag @form, :employment_status %> -
- <%= fields.hidden_field :employment_status %> +
+ <%= form.hidden_field :employment_status %> - <% if current_claim.logged_in_with_tid_and_has_recent_tps_school? %> - <%= render partial: "still_teaching_with_tps_school", locals: { current_claim: current_claim, fields: fields, current_school: current_claim.recent_tps_school } %> - <% else %> - <%= render partial: "still_teaching_with_claim_school", locals: { current_claim: current_claim, fields: fields, claim_school: current_claim.eligibility.claim_school } %> - <% end %> -
-
- <% end %> + <%= render partial: "still_teaching_with_#{@form.tps_or_claim_school}", locals: { current_claim: @form.claim, form: form, school: @form.school } %> +
+ <% end %> <%= form.submit "Continue", class: "govuk-button" %> <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 12eb56cd04..fc485e70d9 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -325,7 +325,12 @@ en: select_subject: Select if you taught Biology, Chemistry, Physics, Computing, Languages or you did not teach any of these subjects still_teaching: questions: - which_school_currently: "Which school are you currently employed to teach at?" + tps_school: Which school are you currently employed to teach at? + claim_school: Are you still employed to teach at a school in England? + errors: + select_which_school_currently: + Select if you still work at %{school_name}, another school or no longer teach in England + select_are_you_still_employed: Select yes if you are still employed to teach at a school in England teacher_reference_number: questions: teacher_reference_number: "What is your teacher reference number (TRN)?" @@ -349,7 +354,6 @@ en: questions: academic_year: "Academic year you completed your Initial Teacher Training (ITT)" claim_school_select_error: "Select the school you taught at between %{financial_year}" - employment_status: "Are you still employed to teach at a school in England?" subjects_taught: "Which of the following subjects did you teach at %{school} between %{financial_year}?" eligible_subjects: biology_taught: "Biology" diff --git a/spec/features/dfe_identity_sign_in_for_student_loans_journey_spec.rb b/spec/features/dfe_identity_sign_in_for_student_loans_journey_spec.rb index 2e4735604b..e69adbd26f 100644 --- a/spec/features/dfe_identity_sign_in_for_student_loans_journey_spec.rb +++ b/spec/features/dfe_identity_sign_in_for_student_loans_journey_spec.rb @@ -44,7 +44,7 @@ check "Physics" click_on "Continue" - expect(page).to have_text(I18n.t("student_loans.questions.employment_status")) + expect(page).to have_text(I18n.t("student_loans.forms.still_teaching.questions.claim_school")) choose_still_teaching("Yes, at #{school.name}") expect(page).to have_text(leadership_position_question) diff --git a/spec/features/student_loans_claim_spec.rb b/spec/features/student_loans_claim_spec.rb index a5928128ee..b4549704b6 100644 --- a/spec/features/student_loans_claim_spec.rb +++ b/spec/features/student_loans_claim_spec.rb @@ -36,7 +36,7 @@ def answer_eligibility_questions_and_fill_in_personal_details check "Physics" click_on "Continue" - expect(page).to have_text(I18n.t("student_loans.questions.employment_status")) + expect(page).to have_text(I18n.t("student_loans.forms.still_teaching.questions.claim_school")) choose_still_teaching("Yes, at #{school.name}") expect(claim.eligibility.reload.employment_status).to eql("claim_school") @@ -274,7 +274,7 @@ def fill_in_remaining_personal_details_and_submit check "Physics" click_on "Continue" - expect(page).to have_text(I18n.t("student_loans.questions.employment_status")) + expect(page).to have_text(I18n.t("student_loans.forms.still_teaching.questions.claim_school")) choose_still_teaching("Yes, at #{school.name}") expect(claim.eligibility.reload.employment_status).to eql("claim_school") diff --git a/spec/features/tslr_claim_journey_with_teacher_id_check_email_spec.rb b/spec/features/tslr_claim_journey_with_teacher_id_check_email_spec.rb index 41271e1903..8647e7940e 100644 --- a/spec/features/tslr_claim_journey_with_teacher_id_check_email_spec.rb +++ b/spec/features/tslr_claim_journey_with_teacher_id_check_email_spec.rb @@ -139,7 +139,7 @@ def navigate_to_check_email_page(school:) click_on "Continue" # - Are you still employed to teach at - expect(page).to have_text(I18n.t("student_loans.questions.employment_status")) + expect(page).to have_text(I18n.t("student_loans.forms.still_teaching.questions.claim_school")) choose_still_teaching("Yes, at #{school.name}") # - leadership-position question diff --git a/spec/features/tslr_claim_journey_with_teacher_id_still_teaching_spec.rb b/spec/features/tslr_claim_journey_with_teacher_id_still_teaching_spec.rb index ebc911aade..03ecb5a427 100644 --- a/spec/features/tslr_claim_journey_with_teacher_id_still_teaching_spec.rb +++ b/spec/features/tslr_claim_journey_with_teacher_id_still_teaching_spec.rb @@ -36,9 +36,13 @@ end scenario "Selects school" do - # - "Selects suggested school retrieved from TPS" do navigate_to_still_teaching_page + # - Tries to continue without selecting option + click_on "Continue" + expect(page).to have_text("Select if you still work at #{eligible_school.name}, another school or no longer teach in England") + + # - Selects suggested school retrieved from TPS choose(eligible_school.name) click_on "Continue" diff --git a/spec/features/tslr_claim_journey_with_teacher_id_trn_spec.rb b/spec/features/tslr_claim_journey_with_teacher_id_trn_spec.rb index 3649c1af76..acb9ccaae7 100644 --- a/spec/features/tslr_claim_journey_with_teacher_id_trn_spec.rb +++ b/spec/features/tslr_claim_journey_with_teacher_id_trn_spec.rb @@ -58,7 +58,7 @@ def navigate_to_teacher_reference_number_page(school:) click_on "Continue" # - Are you still employed to teach at - expect(page).to have_text(I18n.t("student_loans.questions.employment_status")) + expect(page).to have_text(I18n.t("student_loans.forms.still_teaching.questions.claim_school")) choose_still_teaching("Yes, at #{school.name}") # - leadership-position question diff --git a/spec/forms/form_spec.rb b/spec/forms/form_spec.rb index acb86df6ca..567972262c 100644 --- a/spec/forms/form_spec.rb +++ b/spec/forms/form_spec.rb @@ -151,6 +151,17 @@ def initialize(claim) expect(I18n).to have_received(:t) .with("test_i18n_ns.forms.test_slug.errors.message", default: :"forms.test_slug.errors.message") end + + context "when more arguments are supplied" do + before do + form.i18n_errors_path("message", school_name: "Academy for Lizards") + end + + it do + expect(I18n).to have_received(:t) + .with("test_i18n_ns.forms.test_slug.errors.message", default: :"forms.test_slug.errors.message", school_name: "Academy for Lizards") + end + end end describe "#permitted_params" do diff --git a/spec/forms/journeys/teacher_student_loan_reimbursement/still_teaching_form_spec.rb b/spec/forms/journeys/teacher_student_loan_reimbursement/still_teaching_form_spec.rb new file mode 100644 index 0000000000..d4bbfcd46d --- /dev/null +++ b/spec/forms/journeys/teacher_student_loan_reimbursement/still_teaching_form_spec.rb @@ -0,0 +1,79 @@ +require "rails_helper" + +RSpec.describe Journeys::TeacherStudentLoanReimbursement::StillTeachingForm, type: :model do + before { create(:journey_configuration, :student_loans) } + + let(:claim_school) { build(:school, :student_loans_eligible) } + let(:eligibility) { create(:student_loans_eligibility, claim_school:, employment_status: nil) } + let(:claim) { create(:claim, policy: Policies::StudentLoans, eligibility:) } + let(:current_claim) { CurrentClaim.new(claims: [claim]) } + let(:claim_params) { {} } + + subject(:form) do + described_class.new( + journey: Journeys::TeacherStudentLoanReimbursement, + claim: current_claim, + params: ActionController::Parameters.new(claim: claim_params) + ) + end + + describe "validations" do + it do + should validate_presence_of(:employment_status).with_message( + "Select if you still work at #{claim_school.name}, another school or no longer teach in England" + ) + end + end + + describe "#error_message" do + context "when the school is closed" do + let(:claim_school) { build(:school, :student_loans_eligible, close_date: Date.yesterday) } + + it "does not contain the school name" do + expect(form.error_message).to eq("Select yes if you are still employed to teach at a school in England") + end + end + end + + describe "#save" do + context "when no_school is submitted" do + let(:claim_params) { {employment_status: "no_school"} } + + it "set the current_school_id to nil and saves employment status" do + expect(form.save).to be true + expect(claim.eligibility.current_school_id).to be_nil + expect(claim.eligibility).to be_employed_at_no_school + end + end + + context "when different_school is submitted" do + let(:claim_params) { {employment_status: "different_school"} } + + it "set the current_school_id to nil and saves employment status" do + expect(form.save).to be true + expect(claim.eligibility.current_school_id).to be_nil + expect(claim.eligibility).to be_employed_at_different_school + end + end + + context "when suggested school is the claim_school (non-TID)" do + let(:claim_params) { {current_school_id: claim_school.id, employment_status: "claim_school"} } + + it "set the current_school_id and saves employment status" do + expect(form.save).to be true + expect(claim.eligibility.current_school_id).to eq claim_school.id + expect(claim.eligibility).to be_employed_at_claim_school + end + end + + context "when suggested school is from TPS (TID journey)" do + let(:claim_params) { {current_school_id: claim_school.id, employment_status: "recent_tps_school"} } + + it "set the current_school_id and saves employment status" do + expect(form.save).to be true + expect(claim.eligibility.current_school_id).to eq claim_school.id + expect(claim.eligibility).to be_employed_at_recent_tps_school + end + end + end +end diff --git a/spec/forms/still_teaching_form_spec.rb b/spec/forms/still_teaching_form_spec.rb deleted file mode 100644 index 0daf13c643..0000000000 --- a/spec/forms/still_teaching_form_spec.rb +++ /dev/null @@ -1,67 +0,0 @@ -require "rails_helper" - -RSpec.describe StillTeachingForm do - context "no school" do - it "updates employment_status to no_school, no current_school set" do - expected_claim_params = { - eligibility_attributes: { - current_school_id: nil, - employment_status: "no_school" - } - } - - claim_params = {eligibility_attributes: {employment_status: "no_school"}} - updated_claim_params = StillTeachingForm.extract_params(claim_params) - - expect(updated_claim_params).to eq(expected_claim_params) - end - end - - context "somewhere else" do - it "updates employment_status to different_school, no current_school set" do - expected_claim_params = { - eligibility_attributes: { - current_school_id: nil, - employment_status: "different_school" - } - } - - claim_params = {eligibility_attributes: {employment_status: "different_school"}} - updated_claim_params = StillTeachingForm.extract_params(claim_params) - - expect(updated_claim_params).to eq(expected_claim_params) - end - end - - context "suggested school is the claim_school (non-TID)" do - it "updates employment_status to claim_school, current_school is set" do - expected_claim_params = { - eligibility_attributes: { - current_school_id: "1", - employment_status: "claim_school" - } - } - - claim_params = {eligibility_attributes: {current_school_id: "1", employment_status: "claim_school"}} - updated_claim_params = StillTeachingForm.extract_params(claim_params) - - expect(updated_claim_params).to eq(expected_claim_params) - end - end - - context "suggested school is suggest from TPS (TID journey)" do - it "updates employment_status to TPS school, current_school is set" do - expected_claim_params = { - eligibility_attributes: { - current_school_id: "2", - employment_status: "recent_tps_school" - } - } - - claim_params = {eligibility_attributes: {current_school_id: "2", employment_status: "recent_tps_school"}} - updated_claim_params = StillTeachingForm.extract_params(claim_params) - - expect(updated_claim_params).to eq(expected_claim_params) - end - end -end diff --git a/spec/models/student_loans/eligibility_spec.rb b/spec/models/student_loans/eligibility_spec.rb index 9249259b6a..2b349e8301 100644 --- a/spec/models/student_loans/eligibility_spec.rb +++ b/spec/models/student_loans/eligibility_spec.rb @@ -246,20 +246,6 @@ end end - context "when saving in the “still-teaching” context" do - it "validates the presence of employment_status" do - expect(described_class.new).not_to be_valid(:"still-teaching") - expect(described_class.new(employment_status: :claim_school)).to be_valid(:"still-teaching") - end - - it "includes the claim school name in the error message" do - eligibility = build(:student_loans_eligibility, claim_school: eligible_school, employment_status: nil) - - expect(eligibility).not_to be_valid(:"still-teaching") - expect(eligibility.errors[:employment_status]).to eq(["Select if you still work at #{eligible_school.name}, another school or no longer teach in England"]) - end - end - context "when saving in the “submit” context" do it "is valid when all attributes are present" do expect(build(:student_loans_eligibility, :eligible)).to be_valid(:submit)