Browse Source

Linting

pull/31/head
baarkerlounger 4 years ago
parent
commit
42ea2c9230
  1. 2
      app/helpers/check_answers_helper.rb
  2. 27
      spec/helpers/check_answers_helper_spec.rb

2
app/helpers/check_answers_helper.rb

@ -26,7 +26,9 @@ module CheckAnswersHelper
def condition_not_met(case_log, question_key, question, condition) def condition_not_met(case_log, question_key, question, condition)
case question["type"] case question["type"]
when "numeric" when "numeric"
# rubocop:disable Security/Eval
case_log[question_key].blank? || !eval(case_log[question_key].to_s + condition) case_log[question_key].blank? || !eval(case_log[question_key].to_s + condition)
# rubocop:enable Security/Eval
when "radio" when "radio"
case_log[question_key].blank? || !condition.include?(case_log[question_key]) case_log[question_key].blank? || !condition.include?(case_log[question_key])
else else

27
spec/helpers/check_answers_helper_spec.rb

@ -7,7 +7,7 @@ RSpec.describe CheckAnswersHelper do
:case_log, :case_log,
:in_progress, :in_progress,
household_number_of_other_members: 2, household_number_of_other_members: 2,
person_2_relationship: "Partner" person_2_relationship: "Partner",
) )
end end
let(:case_log_with_met_radio_condition) do let(:case_log_with_met_radio_condition) do
@ -83,19 +83,18 @@ RSpec.describe CheckAnswersHelper do
context "conditional questions with type that hasn't been implemented yet" do context "conditional questions with type that hasn't been implemented yet" do
let(:unimplemented_conditional) do let(:unimplemented_conditional) do
{"question_1"=> { "question_1" =>
{"header"=>"The actual question?", { "header" => "The actual question?",
"hint_text"=>"", "hint_text" => "",
"type"=>"date", "type" => "date",
"check_answer_label"=>"Question Label", "check_answer_label" => "Question Label",
"conditional_for"=>{"question_2"=>["12-12-2021"]}}, "conditional_for" => { "question_2" => %w[12-12-2021] } },
"question_2"=> "question_2" =>
{"header"=>"The second actual question?", { "header" => "The second actual question?",
"hint_text"=>"", "hint_text" => "",
"type"=>"radio", "type" => "radio",
"check_answer_label"=>"The second question label", "check_answer_label" => "The second question label",
"answer_options"=>{"0"=>"Yes", "1"=>"No"}} "answer_options" => { "0" => "Yes", "1" => "No" } } }
}
end end
it "raises an error" do it "raises an error" do

Loading…
Cancel
Save