From 1f559f57b2d4fd394e61906401a7834d11a6bb75 Mon Sep 17 00:00:00 2001 From: Jamie Wilkinson Date: Tue, 12 Sep 2023 15:48:08 +0100 Subject: [PATCH 1/4] Add task status service Move the task status service (excluding the submission email status) from forms-admin to forms-api. This is a precursor to adding validation to the make_live endpoint. --- app/models/form.rb | 14 ++ app/service/task_status_service.rb | 87 ++++++++++ spec/factories/forms.rb | 1 + spec/service/task_status_service_spec.rb | 212 +++++++++++++++++++++++ 4 files changed, 314 insertions(+) create mode 100644 app/service/task_status_service.rb create mode 100644 spec/service/task_status_service_spec.rb diff --git a/app/models/form.rb b/app/models/form.rb index 1e62cbf8..46f85491 100644 --- a/app/models/form.rb +++ b/app/models/form.rb @@ -78,4 +78,18 @@ def has_routing_errors def marking_complete_with_errors errors.add(:base, :has_validation_errors, message: "Form has routing validation errors") if question_section_completed && has_routing_errors end + + def ready_for_live + task_status_service.mandatory_tasks_completed? + end + + delegate :missing_sections, to: :task_status_service + + delegate :task_statuses, to: :task_status_service + +private + + def task_status_service + @task_status_service ||= TaskStatusService.new(form: self) + end end diff --git a/app/service/task_status_service.rb b/app/service/task_status_service.rb new file mode 100644 index 00000000..03dd707c --- /dev/null +++ b/app/service/task_status_service.rb @@ -0,0 +1,87 @@ +class TaskStatusService + def initialize(form:) + @form = form + end + + def name_status + :completed + end + + def pages_status + if @form.question_section_completed && @form.pages.any? + :completed + elsif @form.pages.any? + :in_progress + else + :not_started + end + end + + def declaration_status + if @form.declaration_section_completed + :completed + elsif @form.declaration_text.present? + :in_progress + else + :not_started + end + end + + def what_happens_next_status + if @form.what_happens_next_text.present? + :completed + else + :not_started + end + end + + def privacy_policy_status + if @form.privacy_policy_url.present? + :completed + else + :not_started + end + end + + def support_contact_details_status + if @form.support_email.present? || @form.support_phone.present? || (@form.support_url_text.present? && @form.support_url) + :completed + else + :not_started + end + end + + def make_live_status + if @form.has_draft_version + if mandatory_tasks_completed? + return :not_started + else + return :cannot_start + end + end + return :completed if @form.has_live_version + end + + def mandatory_tasks_completed? + missing_sections.empty? + end + + def missing_sections + { missing_pages: pages_status, + missing_what_happens_next: what_happens_next_status, + missing_privacy_policy_url: privacy_policy_status, + missing_contact_details: support_contact_details_status }.reject { |_k, v| v == :completed }.map { |k, _v| k } + end + + def task_statuses + { + name_status:, + pages_status:, + declaration_status:, + what_happens_next_status:, + privacy_policy_status:, + support_contact_details_status:, + make_live_status:, + } + end +end diff --git a/spec/factories/forms.rb b/spec/factories/forms.rb index be1bdca0..5ea996e5 100644 --- a/spec/factories/forms.rb +++ b/spec/factories/forms.rb @@ -50,6 +50,7 @@ trait :live do ready_for_live + after(:create, &:make_live!) end trait :with_support do diff --git a/spec/service/task_status_service_spec.rb b/spec/service/task_status_service_spec.rb new file mode 100644 index 00000000..e659ef9e --- /dev/null +++ b/spec/service/task_status_service_spec.rb @@ -0,0 +1,212 @@ +require "rails_helper" + +describe TaskStatusService do + let(:task_status_service) do + described_class.new(form:) + end + + let(:current_user) { build(:user, role: :editor) } + + describe "statuses" do + describe "name status" do + let(:form) { build(:form, :new_form) } + + it "returns the correct default value" do + expect(task_status_service.name_status).to eq :completed + end + end + + describe "pages status" do + context "with a new form" do + let(:form) { build(:form, :new_form) } + + it "returns the correct default value" do + expect(task_status_service.pages_status).to eq :not_started + end + end + + context "with a form which has pages" do + let(:form) { build(:form, :new_form, :with_pages, question_section_completed: false) } + + it "returns the in progress status" do + expect(task_status_service.pages_status).to eq :in_progress + end + + context "and questions marked completed" do + let(:form) { build(:form, :new_form, :with_pages, question_section_completed: true) } + + it "returns the completed status" do + expect(task_status_service.pages_status).to eq :completed + end + end + end + end + + describe "declaration status" do + context "with a new form" do + let(:form) { build(:form, :new_form) } + + it "returns the correct default value" do + expect(task_status_service.declaration_status).to eq :not_started + end + end + + context "with a form which has no declaration content and is marked incomplete" do + let(:form) { build(:form, declaration_section_completed: false) } + + it "returns the not started status" do + expect(task_status_service.declaration_status).to eq :not_started + end + end + + context "with a form which has declaration content and is marked incomplete" do + let(:form) { build(:form, declaration_text: "I understand the implications", declaration_section_completed: false) } + + it "returns the in progress status" do + expect(task_status_service.declaration_status).to eq :in_progress + end + end + + context "with a form which has a declaration marked complete" do + let(:form) { build(:form, declaration_section_completed: true) } + + it "returns the completed status" do + expect(task_status_service.declaration_status).to eq :completed + end + end + end + + describe "what happens next status" do + context "with a new form" do + let(:form) { build(:form, :new_form) } + + it "returns the correct default value" do + expect(task_status_service.what_happens_next_status).to eq :not_started + end + end + + context "with a form which has a what happens next section" do + let(:form) { build(:form, :new_form, what_happens_next_text: "We usually respond to applications within 10 working days.") } + + it "returns the in progress status" do + expect(task_status_service.what_happens_next_status).to eq :completed + end + end + end + + describe "privacy policy status" do + context "with a new form" do + let(:form) { build(:form, :new_form) } + + it "returns the correct default value" do + expect(task_status_service.privacy_policy_status).to eq :not_started + end + end + + context "with a form which has a privacy policy section" do + let(:form) { build(:form, :new_form, privacy_policy_url: Faker::Internet.url(host: "gov.uk")) } + + it "returns the in progress status" do + expect(task_status_service.privacy_policy_status).to eq :completed + end + end + end + + describe "support contact details status status" do + context "with a new form" do + let(:form) { build(:form, :new_form) } + + it "returns the correct default value" do + expect(task_status_service.support_contact_details_status).to eq :not_started + end + end + + context "with a form which has contact details set" do + let(:form) { build(:form, :new_form, :with_support) } + + it "returns the in progress status" do + expect(task_status_service.support_contact_details_status).to eq :completed + end + end + end + + describe "make live status" do + context "with a new form" do + let(:form) { build(:form, :new_form) } + + it "returns the correct default value" do + expect(task_status_service.make_live_status).to eq :cannot_start + end + end + + context "with a form which is ready to go live" do + let(:form) { build(:form, :ready_for_live) } + + it "returns the not started status" do + expect(task_status_service.make_live_status).to eq :not_started + end + end + + context "with a live form" do + let(:form) { create(:form, :live) } + + it "returns the completed status" do + expect(task_status_service.make_live_status).to eq :completed + end + end + end + end + + describe "#mandatory_tasks_completed" do + context "when mandatory tasks have not been completed" do + let(:form) { build(:form, :new_form) } + + it "returns false" do + expect(task_status_service.mandatory_tasks_completed?).to eq false + end + end + + context "when mandatory tasks have been completed" do + let(:form) { build(:form, :ready_for_live) } + + it "returns true" do + expect(task_status_service.mandatory_tasks_completed?).to eq true + end + end + end + + describe "#missing_sections" do + context "when mandatory tasks are complete" do + let(:form) { build :form, :live } + + it "returns no missing sections" do + expect(task_status_service.missing_sections).to be_empty + end + end + + context "when a form is incomplete and should still be in draft state" do + let(:form) { build :form, :new_form } + + it "returns a set of keys related to missing fields" do + expect(task_status_service.missing_sections).to match_array(%i[missing_pages missing_privacy_policy_url missing_contact_details missing_what_happens_next]) + end + end + end + + describe "#task_statuses" do + let(:form) { create(:form, :live) } + + it "returns a hash with each of the task statuses" do + expected_hash = { + name_status: :completed, + pages_status: :completed, + declaration_status: :completed, + what_happens_next_status: :completed, + privacy_policy_status: :completed, + support_contact_details_status: :completed, + make_live_status: :completed, + } + expect(task_status_service.task_statuses).to eq expected_hash + end + end +end From b51b5e16d08e326feced2a4200f910cc6d29c564 Mon Sep 17 00:00:00 2001 From: Jamie Wilkinson Date: Tue, 12 Sep 2023 15:49:05 +0100 Subject: [PATCH 2/4] Add task validation data to form JSON Add the ready_for_live, missing_sections, and task_statuses attributes to the JSON returned when retrieving a form. --- app/models/form.rb | 2 +- spec/models/form_spec.rb | 73 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/app/models/form.rb b/app/models/form.rb index 46f85491..7a522b8d 100644 --- a/app/models/form.rb +++ b/app/models/form.rb @@ -52,7 +52,7 @@ def name=(val) end def as_json(options = {}) - options[:methods] ||= %i[live_at start_page has_draft_version has_live_version has_routing_errors] + options[:methods] ||= %i[live_at start_page has_draft_version has_live_version has_routing_errors ready_for_live missing_sections task_statuses] super(options) end diff --git a/spec/models/form_spec.rb b/spec/models/form_spec.rb index b391bba4..c826c077 100644 --- a/spec/models/form_spec.rb +++ b/spec/models/form_spec.rb @@ -273,4 +273,77 @@ end end end + + describe "#ready_for_live" do + context "when a form is complete and ready to be made live" do + let(:completed_form) { create(:form, :live) } + + it "returns true" do + expect(completed_form.ready_for_live).to eq true + end + end + + context "when a form is incomplete and should still be in draft state" do + let(:new_form) { build :form, :new_form } + + [ + { + attribute: :pages, + attribute_value: [], + }, + { + attribute: :what_happens_next_text, + attribute_value: nil, + }, + { + attribute: :privacy_policy_url, + attribute_value: nil, + }, + { + attribute: :support_email, + attribute_value: nil, + }, + ].each do |scenario| + it "returns false if #{scenario[:attribute]} is missing" do + new_form.send("#{scenario[:attribute]}=", scenario[:attribute_value]) + expect(new_form.ready_for_live).to eq false + end + end + end + end + + describe "#missing_sections" do + context "when a form is complete and ready to be made live" do + let(:completed_form) { build :form, :live } + + it "returns no missing sections" do + expect(completed_form.missing_sections).to be_empty + end + end + + context "when a form is incomplete and should still be in draft state" do + let(:new_form) { build :form, :new_form } + + it "returns a set of keys related to missing fields" do + expect(new_form.missing_sections).to match_array(%i[missing_pages missing_privacy_policy_url missing_contact_details missing_what_happens_next]) + end + end + end + + describe "#task_statuses" do + let(:completed_form) { create(:form, :live) } + + it "returns a hash with each of the task statuses" do + expected_hash = { + name_status: :completed, + pages_status: :completed, + declaration_status: :completed, + what_happens_next_status: :completed, + privacy_policy_status: :completed, + support_contact_details_status: :completed, + make_live_status: :completed, + } + expect(completed_form.task_statuses).to eq expected_hash + end + end end From fd0fb92d42cb8a5616906f5e7bc6102cc3939ca0 Mon Sep 17 00:00:00 2001 From: Jamie Wilkinson Date: Tue, 12 Sep 2023 15:49:31 +0100 Subject: [PATCH 3/4] Add task status validation to make_live endpoint This uses the validation logic in the task status service to prevent a form being made live if it has missing mandatory sections. If the validation fails it returns the missing sections with a 403 Forbidden status code. --- app/controllers/api/v1/forms_controller.rb | 8 ++++++-- spec/factories/forms.rb | 1 + spec/request/api/v1/forms_controller_spec.rb | 15 ++++++++++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/v1/forms_controller.rb b/app/controllers/api/v1/forms_controller.rb index 8db31ddc..ed3a4d74 100644 --- a/app/controllers/api/v1/forms_controller.rb +++ b/app/controllers/api/v1/forms_controller.rb @@ -37,8 +37,12 @@ def destroy end def make_live - form.make_live! - render json: { success: true }.to_json, status: :ok + if form.ready_for_live + form.make_live! + render json: { success: true }.to_json, status: :ok + else + render json: form.missing_sections.to_json, status: :forbidden + end end def show_live diff --git a/spec/factories/forms.rb b/spec/factories/forms.rb index 5ea996e5..91feda92 100644 --- a/spec/factories/forms.rb +++ b/spec/factories/forms.rb @@ -42,6 +42,7 @@ end trait :ready_for_live do + with_pages support_email { Faker::Internet.email(domain: "example.gov.uk") } what_happens_next_text { "We usually respond to applications within 10 working days." } question_section_completed { true } diff --git a/spec/request/api/v1/forms_controller_spec.rb b/spec/request/api/v1/forms_controller_spec.rb index f8dab490..0795438b 100644 --- a/spec/request/api/v1/forms_controller_spec.rb +++ b/spec/request/api/v1/forms_controller_spec.rb @@ -193,6 +193,9 @@ created_at: form1.created_at.as_json, updated_at: form1.updated_at.as_json, has_routing_errors: false, + missing_sections: %w[missing_pages missing_what_happens_next missing_privacy_policy_url missing_contact_details], + ready_for_live: false, + task_statuses: { declaration_status: "not_started", make_live_status: "cannot_start", name_status: "completed", pages_status: "not_started", privacy_policy_status: "not_started", support_contact_details_status: "not_started", what_happens_next_status: "not_started" }, ) end end @@ -251,8 +254,18 @@ end describe "#make_live" do + context "when given a form with missing sections" do + it "doesn't make the form live" do + form_to_be_made_live = create(:form, :new_form) + post make_live_form_path(form_to_be_made_live), as: :json + expect(response.status).to eq(403) + expect(response.headers["Content-Type"]).to eq("application/json") + expect(json_body).to eq(%w[missing_pages missing_what_happens_next missing_privacy_policy_url missing_contact_details]) + end + end + it "when given a form, sets live_at to current time" do - form_to_be_made_live = create :form + form_to_be_made_live = create(:form, :ready_for_live) post make_live_form_path(form_to_be_made_live), as: :json expect(response.status).to eq(200) expect(response.headers["Content-Type"]).to eq("application/json") From 7335175238700d0b038c66e50ebb0bc225774288 Mon Sep 17 00:00:00 2001 From: Jamie Wilkinson Date: Wed, 13 Sep 2023 15:33:58 +0100 Subject: [PATCH 4/4] Refactor TaskStatusService Make each status method private, and rename missing_sections to incomplete_tasks to be clearer about what the method does --- app/controllers/api/v1/forms_controller.rb | 2 +- app/models/form.rb | 4 +- app/service/task_status_service.rb | 54 ++++++++++---------- spec/models/form_spec.rb | 6 +-- spec/request/api/v1/forms_controller_spec.rb | 2 +- spec/service/task_status_service_spec.rb | 40 +++++++-------- 6 files changed, 53 insertions(+), 55 deletions(-) diff --git a/app/controllers/api/v1/forms_controller.rb b/app/controllers/api/v1/forms_controller.rb index ed3a4d74..7d5dd9fe 100644 --- a/app/controllers/api/v1/forms_controller.rb +++ b/app/controllers/api/v1/forms_controller.rb @@ -41,7 +41,7 @@ def make_live form.make_live! render json: { success: true }.to_json, status: :ok else - render json: form.missing_sections.to_json, status: :forbidden + render json: form.incomplete_tasks.to_json, status: :forbidden end end diff --git a/app/models/form.rb b/app/models/form.rb index 7a522b8d..80ce0749 100644 --- a/app/models/form.rb +++ b/app/models/form.rb @@ -52,7 +52,7 @@ def name=(val) end def as_json(options = {}) - options[:methods] ||= %i[live_at start_page has_draft_version has_live_version has_routing_errors ready_for_live missing_sections task_statuses] + options[:methods] ||= %i[live_at start_page has_draft_version has_live_version has_routing_errors ready_for_live incomplete_tasks task_statuses] super(options) end @@ -83,7 +83,7 @@ def ready_for_live task_status_service.mandatory_tasks_completed? end - delegate :missing_sections, to: :task_status_service + delegate :incomplete_tasks, to: :task_status_service delegate :task_statuses, to: :task_status_service diff --git a/app/service/task_status_service.rb b/app/service/task_status_service.rb index 03dd707c..ae6a70ea 100644 --- a/app/service/task_status_service.rb +++ b/app/service/task_status_service.rb @@ -3,6 +3,31 @@ def initialize(form:) @form = form end + def mandatory_tasks_completed? + incomplete_tasks.empty? + end + + def incomplete_tasks + { missing_pages: pages_status, + missing_what_happens_next: what_happens_next_status, + missing_privacy_policy_url: privacy_policy_status, + missing_contact_details: support_contact_details_status }.reject { |_k, v| v == :completed }.map { |k, _v| k } + end + + def task_statuses + { + name_status:, + pages_status:, + declaration_status:, + what_happens_next_status:, + privacy_policy_status:, + support_contact_details_status:, + make_live_status:, + } + end + +private + def name_status :completed end @@ -53,35 +78,8 @@ def support_contact_details_status def make_live_status if @form.has_draft_version - if mandatory_tasks_completed? - return :not_started - else - return :cannot_start - end + return mandatory_tasks_completed? ? :not_started : :cannot_start end return :completed if @form.has_live_version end - - def mandatory_tasks_completed? - missing_sections.empty? - end - - def missing_sections - { missing_pages: pages_status, - missing_what_happens_next: what_happens_next_status, - missing_privacy_policy_url: privacy_policy_status, - missing_contact_details: support_contact_details_status }.reject { |_k, v| v == :completed }.map { |k, _v| k } - end - - def task_statuses - { - name_status:, - pages_status:, - declaration_status:, - what_happens_next_status:, - privacy_policy_status:, - support_contact_details_status:, - make_live_status:, - } - end end diff --git a/spec/models/form_spec.rb b/spec/models/form_spec.rb index c826c077..c2569cbd 100644 --- a/spec/models/form_spec.rb +++ b/spec/models/form_spec.rb @@ -312,12 +312,12 @@ end end - describe "#missing_sections" do + describe "#incomplete_tasks" do context "when a form is complete and ready to be made live" do let(:completed_form) { build :form, :live } it "returns no missing sections" do - expect(completed_form.missing_sections).to be_empty + expect(completed_form.incomplete_tasks).to be_empty end end @@ -325,7 +325,7 @@ let(:new_form) { build :form, :new_form } it "returns a set of keys related to missing fields" do - expect(new_form.missing_sections).to match_array(%i[missing_pages missing_privacy_policy_url missing_contact_details missing_what_happens_next]) + expect(new_form.incomplete_tasks).to match_array(%i[missing_pages missing_privacy_policy_url missing_contact_details missing_what_happens_next]) end end end diff --git a/spec/request/api/v1/forms_controller_spec.rb b/spec/request/api/v1/forms_controller_spec.rb index 0795438b..5352ace0 100644 --- a/spec/request/api/v1/forms_controller_spec.rb +++ b/spec/request/api/v1/forms_controller_spec.rb @@ -193,7 +193,7 @@ created_at: form1.created_at.as_json, updated_at: form1.updated_at.as_json, has_routing_errors: false, - missing_sections: %w[missing_pages missing_what_happens_next missing_privacy_policy_url missing_contact_details], + incomplete_tasks: %w[missing_pages missing_what_happens_next missing_privacy_policy_url missing_contact_details], ready_for_live: false, task_statuses: { declaration_status: "not_started", make_live_status: "cannot_start", name_status: "completed", pages_status: "not_started", privacy_policy_status: "not_started", support_contact_details_status: "not_started", what_happens_next_status: "not_started" }, ) diff --git a/spec/service/task_status_service_spec.rb b/spec/service/task_status_service_spec.rb index e659ef9e..179eb963 100644 --- a/spec/service/task_status_service_spec.rb +++ b/spec/service/task_status_service_spec.rb @@ -12,7 +12,7 @@ let(:form) { build(:form, :new_form) } it "returns the correct default value" do - expect(task_status_service.name_status).to eq :completed + expect(task_status_service.task_statuses[:name_status]).to eq :completed end end @@ -21,7 +21,7 @@ let(:form) { build(:form, :new_form) } it "returns the correct default value" do - expect(task_status_service.pages_status).to eq :not_started + expect(task_status_service.task_statuses[:pages_status]).to eq :not_started end end @@ -29,14 +29,14 @@ let(:form) { build(:form, :new_form, :with_pages, question_section_completed: false) } it "returns the in progress status" do - expect(task_status_service.pages_status).to eq :in_progress + expect(task_status_service.task_statuses[:pages_status]).to eq :in_progress end context "and questions marked completed" do let(:form) { build(:form, :new_form, :with_pages, question_section_completed: true) } it "returns the completed status" do - expect(task_status_service.pages_status).to eq :completed + expect(task_status_service.task_statuses[:pages_status]).to eq :completed end end end @@ -47,7 +47,7 @@ let(:form) { build(:form, :new_form) } it "returns the correct default value" do - expect(task_status_service.declaration_status).to eq :not_started + expect(task_status_service.task_statuses[:declaration_status]).to eq :not_started end end @@ -55,7 +55,7 @@ let(:form) { build(:form, declaration_section_completed: false) } it "returns the not started status" do - expect(task_status_service.declaration_status).to eq :not_started + expect(task_status_service.task_statuses[:declaration_status]).to eq :not_started end end @@ -63,7 +63,7 @@ let(:form) { build(:form, declaration_text: "I understand the implications", declaration_section_completed: false) } it "returns the in progress status" do - expect(task_status_service.declaration_status).to eq :in_progress + expect(task_status_service.task_statuses[:declaration_status]).to eq :in_progress end end @@ -71,7 +71,7 @@ let(:form) { build(:form, declaration_section_completed: true) } it "returns the completed status" do - expect(task_status_service.declaration_status).to eq :completed + expect(task_status_service.task_statuses[:declaration_status]).to eq :completed end end end @@ -81,7 +81,7 @@ let(:form) { build(:form, :new_form) } it "returns the correct default value" do - expect(task_status_service.what_happens_next_status).to eq :not_started + expect(task_status_service.task_statuses[:what_happens_next_status]).to eq :not_started end end @@ -89,7 +89,7 @@ let(:form) { build(:form, :new_form, what_happens_next_text: "We usually respond to applications within 10 working days.") } it "returns the in progress status" do - expect(task_status_service.what_happens_next_status).to eq :completed + expect(task_status_service.task_statuses[:what_happens_next_status]).to eq :completed end end end @@ -99,7 +99,7 @@ let(:form) { build(:form, :new_form) } it "returns the correct default value" do - expect(task_status_service.privacy_policy_status).to eq :not_started + expect(task_status_service.task_statuses[:privacy_policy_status]).to eq :not_started end end @@ -107,7 +107,7 @@ let(:form) { build(:form, :new_form, privacy_policy_url: Faker::Internet.url(host: "gov.uk")) } it "returns the in progress status" do - expect(task_status_service.privacy_policy_status).to eq :completed + expect(task_status_service.task_statuses[:privacy_policy_status]).to eq :completed end end end @@ -117,7 +117,7 @@ let(:form) { build(:form, :new_form) } it "returns the correct default value" do - expect(task_status_service.support_contact_details_status).to eq :not_started + expect(task_status_service.task_statuses[:support_contact_details_status]).to eq :not_started end end @@ -125,7 +125,7 @@ let(:form) { build(:form, :new_form, :with_support) } it "returns the in progress status" do - expect(task_status_service.support_contact_details_status).to eq :completed + expect(task_status_service.task_statuses[:support_contact_details_status]).to eq :completed end end end @@ -135,7 +135,7 @@ let(:form) { build(:form, :new_form) } it "returns the correct default value" do - expect(task_status_service.make_live_status).to eq :cannot_start + expect(task_status_service.task_statuses[:make_live_status]).to eq :cannot_start end end @@ -143,7 +143,7 @@ let(:form) { build(:form, :ready_for_live) } it "returns the not started status" do - expect(task_status_service.make_live_status).to eq :not_started + expect(task_status_service.task_statuses[:make_live_status]).to eq :not_started end end @@ -151,7 +151,7 @@ let(:form) { create(:form, :live) } it "returns the completed status" do - expect(task_status_service.make_live_status).to eq :completed + expect(task_status_service.task_statuses[:make_live_status]).to eq :completed end end end @@ -175,12 +175,12 @@ end end - describe "#missing_sections" do + describe "#incomplete_tasks" do context "when mandatory tasks are complete" do let(:form) { build :form, :live } it "returns no missing sections" do - expect(task_status_service.missing_sections).to be_empty + expect(task_status_service.incomplete_tasks).to be_empty end end @@ -188,7 +188,7 @@ let(:form) { build :form, :new_form } it "returns a set of keys related to missing fields" do - expect(task_status_service.missing_sections).to match_array(%i[missing_pages missing_privacy_policy_url missing_contact_details missing_what_happens_next]) + expect(task_status_service.incomplete_tasks).to match_array(%i[missing_pages missing_privacy_policy_url missing_contact_details missing_what_happens_next]) end end end