Browse Source

Code review suggestion

pull/41/head
baarkerlounger 4 years ago
parent
commit
800d82dd75
  1. 11
      app/helpers/tasklist_helper.rb
  2. 4
      spec/helpers/tasklist_helper_spec.rb

11
app/helpers/tasklist_helper.rb

@ -37,11 +37,12 @@ module TasklistHelper
end
def get_first_page_or_check_answers(subsection, case_log, form, questions)
if is_started?(subsection, case_log, questions)
send("case_log_#{subsection}_check_answers_path", case_log)
else
send("case_log_#{form.first_page_for_subsection(subsection)}_path", case_log)
end
path = if is_started?(subsection, case_log, questions)
"case_log_#{subsection}_check_answers_path"
else
"case_log_#{form.first_page_for_subsection(subsection)}_path"
end
send(path, case_log)
end
private

4
spec/helpers/tasklist_helper_spec.rb

@ -77,11 +77,11 @@ RSpec.describe TasklistHelper do
let(:household_characteristics_questions) { form.questions_for_subsection("household_characteristics").keys }
it "returns the check answers page path if the section has been started already" do
expect(get_first_page_or_check_answers('household_characteristics', case_log, form, household_characteristics_questions)).to match(/check_answers/)
expect(get_first_page_or_check_answers("household_characteristics", case_log, form, household_characteristics_questions)).to match(/check_answers/)
end
it "returns the first question page path for the section if it has not been started yet" do
expect(get_first_page_or_check_answers('household_characteristics', empty_case_log, form, household_characteristics_questions)).to match(/tenant_code/)
expect(get_first_page_or_check_answers("household_characteristics", empty_case_log, form, household_characteristics_questions)).to match(/tenant_code/)
end
end
end

Loading…
Cancel
Save