Browse Source

rubocop

pull/64/head
magicmilo 3 years ago
parent
commit
ede51029e9
  1. 2
      app/models/case_log.rb
  2. 4
      spec/helpers/check_answers_helper_spec.rb
  3. 6
      spec/models/case_log_spec.rb

2
app/models/case_log.rb

@ -61,7 +61,7 @@ class CaseLogValidator < ActiveModel::Validator
record.errors.add :armed_forces_active, "You must answer the armed forces active question if the tenant has served as a regular in the armed forces" record.errors.add :armed_forces_active, "You must answer the armed forces active question if the tenant has served as a regular in the armed forces"
end end
if record.armed_forces != "Yes - a regular" && !record.armed_forces_active.blank? if record.armed_forces != "Yes - a regular" && record.armed_forces_active.present?
record.errors.add :armed_forces_active, "You must not answer the armed forces active question if the tenant has not served as a regular in the armed forces" record.errors.add :armed_forces_active, "You must not answer the armed forces active question if the tenant has not served as a regular in the armed forces"
end end
end end

4
spec/helpers/check_answers_helper_spec.rb

@ -12,8 +12,8 @@ RSpec.describe CheckAnswersHelper do
end end
let(:case_log_with_met_radio_condition) do let(:case_log_with_met_radio_condition) do
FactoryBot.create(:case_log, armed_forces: "Yes - a regular", FactoryBot.create(:case_log, armed_forces: "Yes - a regular",
armed_forces_injured: "No", armed_forces_injured: "No",
armed_forces_active: "Yes") armed_forces_active: "Yes")
end end
let(:subsection) { "income_and_benefits" } let(:subsection) { "income_and_benefits" }
let(:subsection_with_numeric_conditionals) { "household_characteristics" } let(:subsection_with_numeric_conditionals) { "household_characteristics" }

6
spec/models/case_log_spec.rb

@ -109,16 +109,16 @@ RSpec.describe Form, type: :model do
expect { expect {
CaseLog.create!(armed_forces: "No", CaseLog.create!(armed_forces: "No",
armed_forces_active: "Yes") armed_forces_active: "Yes")
}.to raise_error() }.to raise_error
end end
#Crossover over tests here as injured must be answered as well for no error # Crossover over tests here as injured must be answered as well for no error
it "must be answered if ever served in the forces as a regular" do it "must be answered if ever served in the forces as a regular" do
expect { expect {
CaseLog.create!(armed_forces: "Yes - a regular", CaseLog.create!(armed_forces: "Yes - a regular",
armed_forces_active: "Yes", armed_forces_active: "Yes",
armed_forces_injured: "Yes") armed_forces_injured: "Yes")
}.not_to raise_error() }.not_to raise_error
end end
end end
end end

Loading…
Cancel
Save