From c6fb2580df1b856ccf0708b11d26c78f03cc8b6b Mon Sep 17 00:00:00 2001 From: magicmilo Date: Tue, 26 Oct 2021 16:10:25 +0100 Subject: [PATCH] rubocop --- app/helpers/check_answers_helper.rb | 3 --- app/models/case_log.rb | 5 +++-- spec/features/case_log_spec.rb | 22 +++++++++++----------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/app/helpers/check_answers_helper.rb b/app/helpers/check_answers_helper.rb index 16f07032d..3e59de811 100644 --- a/app/helpers/check_answers_helper.rb +++ b/app/helpers/check_answers_helper.rb @@ -16,9 +16,6 @@ module CheckAnswersHelper while page_name.to_s != "check_answers" && subsection_keys.include?(page_name) questions = form.questions_for_page(page_name) - question_key = questions.keys[0] - question_value = questions.values[0] - applicable_questions = filter_conditional_questions(questions, case_log) total_questions = total_questions.merge(applicable_questions) diff --git a/app/models/case_log.rb b/app/models/case_log.rb index baab481af..16c1915ed 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -72,12 +72,13 @@ class CaseLogValidator < ActiveModel::Validator end end - private +private def women_of_child_bearing_age_in_household(record) (1..8).any? do |n| next if record["person_#{n}_gender"].nil? || record["person_#{n}_age"].nil? - record["person_#{n}_gender"] == "Female" && record["person_#{n}_age"] >= 16 && record["person_#{n}_age"] <= 50 + + record["person_#{n}_gender"] == "Female" && record["person_#{n}_age"] >= 16 && record["person_#{n}_age"] <= 50 end end end diff --git a/spec/features/case_log_spec.rb b/spec/features/case_log_spec.rb index 6bd4d14b0..587fc80f1 100644 --- a/spec/features/case_log_spec.rb +++ b/spec/features/case_log_spec.rb @@ -97,41 +97,41 @@ RSpec.describe "Test Features" do it "Cannot answer yes if no female tenants" do expect { CaseLog.create!(pregnancy: "Yes", - person_1_gender: "Male", - person_1_age: 20) + person_1_gender: "Male", + person_1_age: 20) }.to raise_error(ActiveRecord::RecordInvalid) end it "Cannot answer yes if no female tenants within age range" do expect { CaseLog.create!(pregnancy: "Yes", - person_1_gender: "Female", - person_1_age: 51) + person_1_gender: "Female", + person_1_age: 51) }.to raise_error(ActiveRecord::RecordInvalid) end it "Cannot answer prefer not to say if no valid tenants" do expect { CaseLog.create!(pregnancy: "Prefer not to say", - person_1_gender: "Male", - person_1_age: 20) + person_1_gender: "Male", + person_1_age: 20) }.to raise_error(ActiveRecord::RecordInvalid) end it "Can answer yes if valid tenants" do expect { CaseLog.create!(pregnancy: "Yes", - person_1_gender: "Female", - person_1_age: 20) + person_1_gender: "Female", + person_1_age: 20) }.not_to raise_error end it "Can answer yes if valid second tenant" do expect { CaseLog.create!(pregnancy: "Yes", - person_1_gender: "Male", person_1_age: 99, - person_2_gender: "Female", - person_2_age: 20) + person_1_gender: "Male", person_1_age: 99, + person_2_gender: "Female", + person_2_age: 20) }.not_to raise_error end end