Browse Source

Code review suggestion

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

7
app/helpers/tasklist_helper.rb

@ -37,11 +37,12 @@ module TasklistHelper
end end
def get_first_page_or_check_answers(subsection, case_log, form, questions) def get_first_page_or_check_answers(subsection, case_log, form, questions)
if is_started?(subsection, case_log, questions) path = if is_started?(subsection, case_log, questions)
send("case_log_#{subsection}_check_answers_path", case_log) "case_log_#{subsection}_check_answers_path"
else else
send("case_log_#{form.first_page_for_subsection(subsection)}_path", case_log) "case_log_#{form.first_page_for_subsection(subsection)}_path"
end end
send(path, case_log)
end end
private 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 } 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 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 end
it "returns the first question page path for the section if it has not been started yet" do 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 end
end end

Loading…
Cancel
Save