Browse Source

rubocop

pull/63/head
magicmilo 3 years ago
parent
commit
c6fb2580df
  1. 3
      app/helpers/check_answers_helper.rb
  2. 5
      app/models/case_log.rb
  3. 22
      spec/features/case_log_spec.rb

3
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)

5
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

22
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

Loading…
Cancel
Save