diff --git a/app/assets/javascripts/components/subjects_taught.js b/app/assets/javascripts/components/subjects_taught.js deleted file mode 100644 index 26b66d23f2..0000000000 --- a/app/assets/javascripts/components/subjects_taught.js +++ /dev/null @@ -1,35 +0,0 @@ -"use strict"; - -document.addEventListener("DOMContentLoaded", function () { - var fieldset = document.querySelector("#claim_subjects_taught"); - - if (!fieldset) { - return; - } - - function toggleSubjectValues(event) { - var el = event.target; - var eligibleSubjectsClass = "subject"; - var notTeachingSubjectsName = "claim[eligibility_attributes][taught_eligible_subjects]"; - - if (!el) { - return; - } - - if (el.checked === false) { - return; - } - - if (el.classList.contains(eligibleSubjectsClass)) { - var radioButton = document.querySelector("input[type='radio'][name='" + notTeachingSubjectsName + "']"); - radioButton.checked = false; - } else if (el.name == notTeachingSubjectsName) { - var checkboxes = document.querySelectorAll("input." + eligibleSubjectsClass); - checkboxes.forEach(function (item, _index) { - item.checked = false; - }); - } - } - - fieldset.addEventListener("click", toggleSubjectValues, false); -}); diff --git a/app/controllers/claims_controller.rb b/app/controllers/claims_controller.rb index c3623548c2..b1c60110a7 100644 --- a/app/controllers/claims_controller.rb +++ b/app/controllers/claims_controller.rb @@ -39,8 +39,6 @@ def show if params[:slug] == "select-claim-school" update_session_with_tps_school(current_claim.tps_school_for_student_loan_in_previous_financial_year) - elsif params[:slug] == "subjects-taught" && page_sequence.in_sequence?("select-claim-school") - @backlink_path = claim_path(current_journey_routing_name, "select-claim-school") elsif params[:slug] == "postcode-search" && postcode redirect_to claim_path(current_journey_routing_name, "select-home-address", {"claim[postcode]": params[:claim][:postcode], "claim[address_line_1]": params[:claim][:address_line_1]}) and return unless invalid_postcode? elsif params[:slug] == "select-home-address" && postcode diff --git a/app/forms/journeys/teacher_student_loan_reimbursement/subjects_taught_form.rb b/app/forms/journeys/teacher_student_loan_reimbursement/subjects_taught_form.rb new file mode 100644 index 0000000000..4288e110cb --- /dev/null +++ b/app/forms/journeys/teacher_student_loan_reimbursement/subjects_taught_form.rb @@ -0,0 +1,73 @@ +module Journeys + module TeacherStudentLoanReimbursement + class SubjectsTaughtForm < Form + attr_accessor :subjects_taught + + attribute :taught_eligible_subjects, :boolean + attribute :biology_taught, :boolean + attribute :chemistry_taught, :boolean + attribute :physics_taught, :boolean + attribute :computing_taught, :boolean + attribute :languages_taught, :boolean + + validate :one_subject_must_be_selected + + before_validation :determine_dependant_attributes + + def save + return false unless valid? + + update!(eligibility_attributes: attributes) + end + + def claim_school_name + @claim_school_name ||= claim.eligibility.claim_school_name + end + + def subject_attributes + Policies::StudentLoans::Eligibility::SUBJECT_ATTRIBUTES + end + + def subject_taught_selected?(subject) + public_send(subject) == true if respond_to?(subject) + end + + private + + def determine_dependant_attributes + subject_attributes.each(&method(:update_subject_taught_attribute)) + assign_attributes(taught_eligible_subjects: selected_subjects.empty? ? nil : !no_subject_taught_selected?) + end + + def update_subject_taught_attribute(subject) + assign_attributes(subject => subject.to_s.in?(selected_subjects)) + end + + def no_subject_taught_selected? + "none_taught".in?(selected_subjects) + end + + def selected_subjects + permitted_params.fetch(:subjects_taught, []) + end + + def permitted_params + @permitted_params ||= params.fetch(:claim, {}).permit(subjects_taught: []) + end + + def any_subjects_taught_selected? + subject_attributes.any?(&method(:subject_taught_selected?)) + end + + def not_taught_eligible_subjects? + taught_eligible_subjects == false + end + + def one_subject_must_be_selected + return if not_taught_eligible_subjects? || any_subjects_taught_selected? + + errors.add(:subjects_taught, i18n_errors_path(:select_subject)) + end + end + end +end diff --git a/app/helpers/student_loans_helper.rb b/app/helpers/student_loans_helper.rb index 06a2886c31..9dd013afb5 100644 --- a/app/helpers/student_loans_helper.rb +++ b/app/helpers/student_loans_helper.rb @@ -20,7 +20,7 @@ def claim_school_question(additional_school: false) # Accepts a `school_name` named parameter that is the school that the claimant # was teaching at during the financial year. def subjects_taught_question(school_name:) - translate("student_loans.questions.subjects_taught", school: school_name, financial_year: Policies::StudentLoans.current_financial_year) + translate("student_loans.forms.subjects_taught.questions.subjects_taught", school: school_name, financial_year: Policies::StudentLoans.current_financial_year) end # Returns the question for the leadership-position question in the Student diff --git a/app/models/journeys/teacher_student_loan_reimbursement.rb b/app/models/journeys/teacher_student_loan_reimbursement.rb index df85b9f69d..7c0ab9537c 100644 --- a/app/models/journeys/teacher_student_loan_reimbursement.rb +++ b/app/models/journeys/teacher_student_loan_reimbursement.rb @@ -14,6 +14,7 @@ module TeacherStudentLoanReimbursement "claim-school" => ClaimSchoolForm, "qualification-details" => QualificationDetailsForm, "qts-year" => QtsYearForm, + "subjects-taught" => SubjectsTaughtForm, "leadership-position" => LeadershipPositionForm, "mostly-performed-leadership-duties" => MostlyPerformedLeadershipDutiesForm } diff --git a/app/models/policies/student_loans/eligibility.rb b/app/models/policies/student_loans/eligibility.rb index 3a4d3ead60..9b9de515d2 100644 --- a/app/models/policies/student_loans/eligibility.rb +++ b/app/models/policies/student_loans/eligibility.rb @@ -50,7 +50,6 @@ class Eligibility < ApplicationRecord 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" }} - validate :one_subject_must_be_selected, on: [:"subjects-taught", :submit], unless: :not_taught_eligible_subjects? 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 @@ -136,10 +135,6 @@ def made_zero_repayments? claim.present? && claim.has_student_loan == true && student_loan_repayment_amount == 0 end - def one_subject_must_be_selected - errors.add(:subjects_taught, "Select if you taught Biology, Chemistry, Physics, Computing, Languages or you did not teach any of these subjects") if subjects_taught.empty? - end - def ineligible_current_school? current_school.present? && !current_school.eligible_for_student_loans_as_current_school? end diff --git a/app/models/policies/student_loans/presenter_methods.rb b/app/models/policies/student_loans/presenter_methods.rb index a39dfeadb8..cdb30564c7 100644 --- a/app/models/policies/student_loans/presenter_methods.rb +++ b/app/models/policies/student_loans/presenter_methods.rb @@ -12,7 +12,7 @@ def qts_award_year_answer(eligibility) def subject_list(subjects) connector = " and " - translated_subjects = subjects.map { |subject| I18n.t("student_loans.questions.eligible_subjects.#{subject}") } + translated_subjects = subjects.map { |subject| I18n.t("student_loans.forms.subjects_taught.answers.#{subject}") } translated_subjects.sort.to_sentence( last_word_connector: connector, two_words_connector: connector diff --git a/app/views/additional_payments/claims/disciplinary_action.html.erb b/app/views/additional_payments/claims/disciplinary_action.html.erb deleted file mode 100644 index cffd43e217..0000000000 --- a/app/views/additional_payments/claims/disciplinary_action.html.erb +++ /dev/null @@ -1,46 +0,0 @@ -<% content_for(:page_title, page_title(t("additional_payments.questions.disciplinary_action"), journey: current_journey_routing_name, show_error: current_claim.errors.any?)) %> -<% path_for_form = current_claim.persisted? ? claim_path(current_journey_routing_name) : claims_path(current_journey_routing_name) %> - -
-
- <%= render("shared/error_summary", instance: current_claim, errored_field_id_overrides: { "eligibility.subject_to_disciplinary_action": "claim_eligibility_attributes_subject_to_disciplinary_action_true" }) if current_claim.errors.any? %> - - <%= form_for current_claim, url: path_for_form do |form| %> - <%= form_group_tag current_claim do %> - <%= form.fields_for :eligibility, include_id: false do |fields| %> - - <%= fields.hidden_field :subject_to_disciplinary_action %> - -
- - -

- <%= t("additional_payments.questions.disciplinary_action") %> -

-
- - <%= errors_tag current_claim.eligibility, :subject_to_disciplinary_action %> - -
- -
- <%= fields.radio_button(:subject_to_disciplinary_action, true, class: "govuk-radios__input") %> - <%= fields.label :subject_to_disciplinary_action_true, "Yes", class: "govuk-label govuk-radios__label" %> -
- -
- <%= fields.radio_button(:subject_to_disciplinary_action, false, class: "govuk-radios__input") %> - <%= fields.label :subject_to_disciplinary_action_false, "No", class: "govuk-label govuk-radios__label" %> -
- -
- -
- - <% end %> - <% end %> - - <%= form.submit "Continue", class: "govuk-button", data: {module: "govuk-button"} %> - <% end %> -
-
diff --git a/app/views/student_loans/claims/subjects_taught.html.erb b/app/views/student_loans/claims/subjects_taught.html.erb index 46b4ab056e..77eb651fe3 100644 --- a/app/views/student_loans/claims/subjects_taught.html.erb +++ b/app/views/student_loans/claims/subjects_taught.html.erb @@ -1,48 +1,44 @@ -<% content_for(:page_title, page_title(subjects_taught_question(school_name: current_claim.eligibility.claim_school_name), journey: current_journey_routing_name, show_error: current_claim.errors.any?)) %> +<% content_for(:page_title, page_title(subjects_taught_question(school_name: @form.claim_school_name), journey: current_journey_routing_name, show_error: @form.errors.any?)) %>
- <%= render("shared/error_summary", instance: current_claim, errored_field_id_overrides: { "eligibility.subjects_taught": "eligible_subjects_biology_taught" }) if current_claim.errors.any? %> + <%= render("shared/error_summary", instance: @form, errored_field_id_overrides: { "subjects_taught": "claim_biology_taught" }) if @form.errors.any? %> - <%= form_for current_claim, url: claim_path(current_journey_routing_name) do |form| %> + <%= form_for @form, url: claim_path(current_journey_routing_name) do |f| %> - <%= form_group_tag current_claim do %> - <%= form.fields_for :eligibility, include_id: false do |fields| %> -
+ <%= form_group_tag @form do %> +
- -

- <%= subjects_taught_question(school_name: current_claim.eligibility.claim_school_name) %> -

-
+ +

+ <%= subjects_taught_question(school_name: f.object.claim_school_name) %> +

+
- <%= errors_tag current_claim.eligibility, :subjects_taught %> + <%= errors_tag f.object, :subjects_taught %> -
+
- <%- Policies::StudentLoans::Eligibility::SUBJECT_ATTRIBUTES.each do |subject| %> -
- <%= fields.hidden_field subject, value: false %> - <%= fields.check_box subject, class: "govuk-checkboxes__input subject", id: "eligible_subjects_#{subject}" %> - <%= fields.label subject, t("student_loans.questions.eligible_subjects.#{subject}"), class: "govuk-label govuk-checkboxes__label", for: "eligible_subjects_#{subject}" %> -
- <% end %> - -
or
- -
- <%= fields.hidden_field :taught_eligible_subjects, value: true %> - <%= fields.radio_button :taught_eligible_subjects, false, class: "govuk-radios__input" %> - <%= fields.label :taught_eligible_subjects_false, t('student_loans.questions.eligible_subjects.none_taught'), class: "govuk-label govuk-radios__label" %> + <%- f.object.subject_attributes.each do |subject| %> +
+ <%= f.check_box :subjects_taught, { class: "govuk-checkboxes__input", id: "claim_#{subject}", include_hidden: false, checked: f.object.subject_taught_selected?(subject), multiple: true }, subject %> + <%= f.label :subjects_taught, t("student_loans.forms.subjects_taught.answers.#{subject}"), class: "govuk-label govuk-checkboxes__label", for: "claim_#{subject}" %>
+ <% end %> +
or
+ +
+ <%= f.check_box :subjects_taught, { class: "govuk-checkboxes__input", id: "claim_taught_eligible_subjects", include_hidden: false, multiple: true, data: { behaviour: "exclusive" } }, "none_taught" %> + <%= f.label :subjects_taught, t("student_loans.forms.subjects_taught.answers.none_taught"), class: "govuk-label govuk-checkboxes__label", for: "claim_taught_eligible_subjects" %>
-
- <% end %> +
+ + <% end %> - <%= form.submit "Continue", class: "govuk-button" %> + <%= f.submit "Continue", class: "govuk-button" %> <% end %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index e0f762b1b9..cc03c8cdd0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -252,6 +252,18 @@ en: qts_award_year: When did you complete your initial teacher training (ITT)? errors: select_itt_year: Select when you completed your initial teacher training + subjects_taught: + questions: + subjects_taught: Which of the following subjects did you teach at %{school} between %{financial_year}? + answers: + biology_taught: Biology + chemistry_taught: Chemistry + physics_taught: Physics + computing_taught: Computing + languages_taught: Languages + none_taught: I did not teach any of these subjects + errors: + 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?" diff --git a/spec/features/changing_answers_spec.rb b/spec/features/changing_answers_spec.rb index 0a18425e28..5fd1dbed60 100644 --- a/spec/features/changing_answers_spec.rb +++ b/spec/features/changing_answers_spec.rb @@ -20,7 +20,7 @@ find("a[href='#{claim_path(Journeys::TeacherStudentLoanReimbursement::ROUTING_NAME, "subjects-taught")}']").click - expect(find("#eligible_subjects_physics_taught").checked?).to eq(true) + expect(find("#claim_physics_taught").checked?).to eq(true) check "Biology" click_on "Continue" @@ -73,8 +73,8 @@ expect(current_path).to eq(claim_path(Journeys::TeacherStudentLoanReimbursement::ROUTING_NAME, "subjects-taught")) - check I18n.t("student_loans.questions.eligible_subjects.biology_taught"), visible: false - check I18n.t("student_loans.questions.eligible_subjects.chemistry_taught"), visible: false + check I18n.t("student_loans.forms.subjects_taught.answers.biology_taught"), visible: false + check I18n.t("student_loans.forms.subjects_taught.answers.chemistry_taught"), visible: false click_on "Continue" @@ -123,7 +123,7 @@ find("a[href='#{claim_path(Journeys::TeacherStudentLoanReimbursement::ROUTING_NAME, "subjects-taught")}']").click - expect(find("#eligible_subjects_physics_taught").checked?).to eq(true) + expect(find("#claim_physics_taught").checked?).to eq(true) click_on "Continue" diff --git a/spec/features/ineligible_student_loans_claims_spec.rb b/spec/features/ineligible_student_loans_claims_spec.rb index 92d760c357..de2ba8d480 100644 --- a/spec/features/ineligible_student_loans_claims_spec.rb +++ b/spec/features/ineligible_student_loans_claims_spec.rb @@ -86,7 +86,7 @@ claim = start_student_loans_claim choose_school school - choose I18n.t("student_loans.questions.eligible_subjects.none_taught") + check I18n.t("student_loans.forms.subjects_taught.answers.none_taught") click_on "Continue" expect(claim.eligibility.reload.taught_eligible_subjects?).to eq(false) diff --git a/spec/features/multiple_claim_schools_spec.rb b/spec/features/multiple_claim_schools_spec.rb index 5c88f06129..27f8182513 100644 --- a/spec/features/multiple_claim_schools_spec.rb +++ b/spec/features/multiple_claim_schools_spec.rb @@ -44,7 +44,7 @@ scenario "didn't teach eligible subjects, but taught eligible subjects at a different eligible school" do choose_school eligible_school - choose I18n.t("student_loans.questions.eligible_subjects.none_taught") + check I18n.t("student_loans.forms.subjects_taught.answers.none_taught") click_on "Continue" expect(page).to have_text("You did not select an eligible subject") @@ -57,8 +57,8 @@ choose_school eligible_school - check I18n.t("student_loans.questions.eligible_subjects.biology_taught") - check I18n.t("student_loans.questions.eligible_subjects.physics_taught") + check I18n.t("student_loans.forms.subjects_taught.answers.biology_taught") + check I18n.t("student_loans.forms.subjects_taught.answers.physics_taught") click_on "Continue" expect(claim.eligibility.reload.taught_eligible_subjects).to eq(true) @@ -69,14 +69,14 @@ scenario "didn't teach eligible subjects and did not teach eligible subjects at a different eligible school" do choose_school eligible_school - choose I18n.t("student_loans.questions.eligible_subjects.none_taught") + check I18n.t("student_loans.forms.subjects_taught.answers.none_taught") click_on "Continue" click_on "Enter another school" choose_school eligible_school - choose I18n.t("student_loans.questions.eligible_subjects.none_taught") + check I18n.t("student_loans.forms.subjects_taught.answers.none_taught") click_on "Continue" expect(page).to have_text("You did not select an eligible subject") diff --git a/spec/features/subjects_taught_spec.rb b/spec/features/subjects_taught_spec.rb index 9d81a9841a..449baf30ee 100644 --- a/spec/features/subjects_taught_spec.rb +++ b/spec/features/subjects_taught_spec.rb @@ -15,15 +15,15 @@ check "Biology" check "Physics" - expect(page).to have_checked_field("eligible_subjects_biology_taught", visible: false) - expect(page).to have_checked_field("eligible_subjects_physics_taught", visible: false) + expect(page).to have_checked_field("claim_biology_taught", visible: false) + expect(page).to have_checked_field("claim_physics_taught", visible: false) - choose I18n.t("student_loans.questions.eligible_subjects.none_taught") + check I18n.t("student_loans.forms.subjects_taught.answers.none_taught") - expect(page).to have_checked_field("claim_eligibility_attributes_taught_eligible_subjects_false", visible: false) + expect(page).to have_checked_field("claim_taught_eligible_subjects", visible: false) - expect(page).to_not have_checked_field("eligible_subjects_biology_taught", visible: false) - expect(page).to_not have_checked_field("eligible_subjects_physics_taught", visible: false) + expect(page).to_not have_checked_field("claim_biology_taught", visible: false) + expect(page).to_not have_checked_field("claim_physics_taught", visible: false) click_on "Continue" @@ -32,14 +32,14 @@ end scenario "checks not applicable and then chooses a subject" do - choose I18n.t("student_loans.questions.eligible_subjects.none_taught") + check I18n.t("student_loans.forms.subjects_taught.answers.none_taught") - expect(page).to have_checked_field("claim_eligibility_attributes_taught_eligible_subjects_false", visible: false) + expect(page).to have_checked_field("claim_taught_eligible_subjects", visible: false) check "Biology" - expect(page).to have_checked_field("eligible_subjects_biology_taught", visible: false) - expect(page).to_not have_checked_field("claim_eligibility_attributes_taught_eligible_subjects_false", visible: false) + expect(page).to have_checked_field("claim_biology_taught", visible: false) + expect(page).to_not have_checked_field("claim_taught_eligible_subjects", visible: false) click_on "Continue" @@ -55,7 +55,7 @@ check "Biology" check "Physics" - choose I18n.t("student_loans.questions.eligible_subjects.none_taught") + check I18n.t("student_loans.forms.subjects_taught.answers.none_taught") click_on "Continue" expect(page).to have_text("You did not select an eligible subject") @@ -63,7 +63,7 @@ end scenario "checks not applicable and then chooses a subject" do - choose I18n.t("student_loans.questions.eligible_subjects.none_taught") + check I18n.t("student_loans.forms.subjects_taught.answers.none_taught") check "Biology" click_on "Continue" diff --git a/spec/forms/journeys/teacher_student_loan_reimbursement/subjects_taught_form_spec.rb b/spec/forms/journeys/teacher_student_loan_reimbursement/subjects_taught_form_spec.rb new file mode 100644 index 0000000000..6ca8ee6bed --- /dev/null +++ b/spec/forms/journeys/teacher_student_loan_reimbursement/subjects_taught_form_spec.rb @@ -0,0 +1,123 @@ +require "rails_helper" + +RSpec.describe Journeys::TeacherStudentLoanReimbursement::SubjectsTaughtForm, type: :model do + subject(:form) { described_class.new(claim:, journey:, params:) } + + let(:journey) { Journeys::TeacherStudentLoanReimbursement } + let(:claim) { CurrentClaim.new(claims: [build(:claim, policy: Policies::StudentLoans)]) } + let(:slug) { "subjects-taught" } + let(:params) { ActionController::Parameters.new({slug:, claim: claim_params}) } + let(:claim_params) { {"subjects_taught" => ["biology_taught"]} } + + it { is_expected.to be_a(Form) } + + describe "validations" do + context "when no options are selected" do + let(:claim_params) { {"subjects_taught" => []} } + + it do + aggregate_failures do + is_expected.not_to be_valid + expect(form.errors[:subjects_taught]).to eq([form.i18n_errors_path(:select_subject)]) + end + end + end + + context "when one or more subjects are selected" do + let(:claim_params) { {"subjects_taught" => ["biology_taught", "chemistry_taught"]} } + + it { is_expected.to be_valid } + end + + context "when 'I did not teach any of these subjects' is selected" do + let(:claim_params) { {"subjects_taught" => ["none_taught"]} } + + it { is_expected.to be_valid } + end + end + + describe "#save" do + before do + allow(form).to receive(:update!) + form.save + end + + context "valid params" do + context "when multiple subject are selected" do + let(:claim_params) { {"subjects_taught" => ["biology_taught", "chemistry_taught"]} } + let(:expected_saved_attributes) do + { + eligibility_attributes: { + "biology_taught" => true, + "chemistry_taught" => true, + "physics_taught" => false, + "computing_taught" => false, + "languages_taught" => false, + "taught_eligible_subjects" => true + } + } + end + + it { is_expected.to have_received(:update!).with(expected_saved_attributes) } + end + + context "when no subjects are selected" do + let(:claim_params) { {"subjects_taught" => ["none_taught"]} } + let(:expected_saved_attributes) do + { + eligibility_attributes: { + "biology_taught" => false, + "chemistry_taught" => false, + "physics_taught" => false, + "computing_taught" => false, + "languages_taught" => false, + "taught_eligible_subjects" => false + } + } + end + + it { is_expected.to have_received(:update!).with(expected_saved_attributes) } + end + end + + context "invalid params" do + let(:claim_params) { {"subjects_taught" => []} } + + it { expect(form).not_to have_received(:update!) } + end + end + + describe "#claim_school_name" do + before do + allow(claim).to receive(:eligibility).and_return(double(claim_school_name: "test school")) + end + + it { expect(form.claim_school_name).to eq("test school") } + end + + describe "#subject_attributes" do + it { expect(form.subject_attributes).to eq(Policies::StudentLoans::Eligibility::SUBJECT_ATTRIBUTES) } + end + + describe "#subject_taught_selected?" do + context "when the subject is invalid" do + it { expect(form.subject_taught_selected?(:invalid_subject_taught)).to be_nil } + end + + context "when the subject is taught" do + before do + claim.eligibility.biology_taught = true + end + + it { expect(form.subject_taught_selected?(:biology_taught)).to eq(true) } + end + + context "when the subject is not taught" do + before do + claim.eligibility.biology_taught = false + end + + it { expect(form.subject_taught_selected?(:biology_taught)).to eq(false) } + end + end +end diff --git a/spec/models/student_loans/eligibility_spec.rb b/spec/models/student_loans/eligibility_spec.rb index 745a0d3a96..9249259b6a 100644 --- a/spec/models/student_loans/eligibility_spec.rb +++ b/spec/models/student_loans/eligibility_spec.rb @@ -260,25 +260,6 @@ end end - context "when saving in the “subjects-taught” context" do - it "is not valid if none of the subjects-taught attributes are true" do - expect(described_class.new).not_to be_valid(:"subjects-taught") - expect(described_class.new(biology_taught: false)).not_to be_valid(:"subjects-taught") - expect(described_class.new(biology_taught: false, physics_taught: false)).not_to be_valid(:"subjects-taught") - end - - it "is valid when one or more of the subjects-taught attributes are true" do - expect(described_class.new(biology_taught: true)).to be_valid(:"subjects-taught") - expect(described_class.new(biology_taught: true, computing_taught: false)).to be_valid(:"subjects-taught") - expect(described_class.new(chemistry_taught: true, languages_taught: true)).to be_valid(:"subjects-taught") - end - - it "is valid with no subjects present if taught_eligible_subjects is false" do - expect(described_class.new(taught_eligible_subjects: false)).to be_valid(:"subjects-taught") - expect(described_class.new(taught_eligible_subjects: true)).not_to be_valid(:"subjects-taught") - 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) @@ -288,10 +269,6 @@ expect(build(:student_loans_eligibility, :eligible, employment_status: nil)).not_to be_valid(:submit) end - it "is not valid without at least one subject being taught selected" do - expect(build(:student_loans_eligibility, :eligible, physics_taught: nil)).not_to be_valid(:submit) - end - it "is not valid without a value for student_loan_repayment_amount" do expect(build(:student_loans_eligibility, student_loan_repayment_amount: nil)).not_to be_valid(:submit) end