Browse Source

Rename method

pull/49/head
Kat 4 years ago
parent
commit
f9cb838641
  1. 2
      app/helpers/tasklist_helper.rb
  2. 2
      app/views/case_logs/edit.html.erb
  3. 10
      spec/helpers/tasklist_helper_spec.rb

2
app/helpers/tasklist_helper.rb

@ -29,7 +29,7 @@ module TasklistHelper
subsections.find { |subsection| is_incomplete?(subsection, case_log, form.questions_for_subsection(subsection).keys) }
end
def get_sections_count(form, case_log, status = :all)
def get_subsections_count(form, case_log, status = :all)
subsections = form.all_subsections.keys
return subsections.count if status == :all

2
app/views/case_logs/edit.html.erb

@ -6,7 +6,7 @@
<h2 class="govuk-heading-s govuk-!-margin-bottom-2">This submission is
<%= @case_log.status %></h2>
<p class="govuk-body govuk-!-margin-bottom-7">You've completed <%= get_sections_count(@form, @case_log, :completed) %> of <%= get_sections_count(@form, @case_log, :all) %> sections.</p>
<p class="govuk-body govuk-!-margin-bottom-7">You've completed <%= get_subsections_count(@form, @case_log, :completed) %> of <%= get_subsections_count(@form, @case_log, :all) %> sections.</p>
<p class="govuk-body govuk-!-margin-bottom-7">
<% next_incomplete_section=get_next_incomplete_section(@form, @case_log) %>
<a href="#<%= next_incomplete_section %>"

10
spec/helpers/tasklist_helper_spec.rb

@ -54,23 +54,23 @@ RSpec.describe TasklistHelper do
describe "get sections count" do
it "returns the total of sections if no status is given" do
expect(get_sections_count(form, empty_case_log)).to eq(8)
expect(get_subsections_count(form, empty_case_log)).to eq(8)
end
it "returns 0 sections for completed sections if no sections are completed" do
expect(get_sections_count(form, empty_case_log, :completed)).to eq(0)
expect(get_subsections_count(form, empty_case_log, :completed)).to eq(0)
end
it "returns the number of not started sections" do
expect(get_sections_count(form, empty_case_log, :not_started)).to eq(7)
expect(get_subsections_count(form, empty_case_log, :not_started)).to eq(7)
end
it "returns the number of sections in progress" do
expect(get_sections_count(form, case_log, :in_progress)).to eq(2)
expect(get_subsections_count(form, case_log, :in_progress)).to eq(2)
end
it "returns 0 for invalid state" do
expect(get_sections_count(form, case_log, :fake)).to eq(0)
expect(get_subsections_count(form, case_log, :fake)).to eq(0)
end
end

Loading…
Cancel
Save