From 0f8b1e6bef32c810d2ba869e59d7246f43b2ab92 Mon Sep 17 00:00:00 2001 From: Joel Sugarman Date: Wed, 15 Jan 2025 14:29:15 +0000 Subject: [PATCH 1/3] AP-4407: Improve merits task list RSpec matcher --- spec/support/task_list_matcher.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/spec/support/task_list_matcher.rb b/spec/support/task_list_matcher.rb index ca712b33e0..ed0689b885 100644 --- a/spec/support/task_list_matcher.rb +++ b/spec/support/task_list_matcher.rb @@ -1,16 +1,22 @@ RSpec::Matchers.define :have_completed_task do |group, task_name| + description { "have task in a \"completed\" state" } + match do |actual| expect(actual).to have_task_in_state(group, task_name, :complete) end end RSpec::Matchers.define :have_not_started_task do |group, task_name| + description { "have task in a \"not started\" state" } + match do |actual| expect(actual).to have_task_in_state(group, task_name, :not_started) end end RSpec::Matchers.define :have_task_in_state do |group, task_name, expected_state| + description { "have task in the expected state" } + match do |actual| possible_tasks = actual.task_list.tasks[group.to_sym] || actual.task_list.tasks.dig(:proceedings, group.to_sym, :tasks) if possible_tasks.nil? @@ -18,7 +24,7 @@ break end - @found_task = possible_tasks.detect { |task| task.name == task_name.to_sym } + @found_task = possible_tasks.find { |task| task.name == task_name.to_sym } if @found_task.nil? @error_message = "No task named '#{task_name}' exists in group named ':#{group}'" break @@ -30,4 +36,8 @@ failure_message do @error_message ||= "The [:#{group}][:#{task_name}] task is set to :#{@found_task.state}, not :#{expected_state}'" end + + failure_message_when_negated do + @error_message ||= "The [:#{group}][:#{task_name}] task is set to :#{@found_task.state} but expected to not be" + end end From 962c5654afe826dcef013543fcfe7ea24cc899ac Mon Sep 17 00:00:00 2001 From: Joel Sugarman Date: Tue, 14 Jan 2025 14:35:23 +0000 Subject: [PATCH 2/3] AP-4407: Add child_care_assessments To store proceedings merit task list items answers --- .../20250114142619_create_child_care_assessments.rb | 12 ++++++++++++ db/schema.rb | 13 ++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20250114142619_create_child_care_assessments.rb diff --git a/db/migrate/20250114142619_create_child_care_assessments.rb b/db/migrate/20250114142619_create_child_care_assessments.rb new file mode 100644 index 0000000000..0e4f8f0120 --- /dev/null +++ b/db/migrate/20250114142619_create_child_care_assessments.rb @@ -0,0 +1,12 @@ +class CreateChildCareAssessments < ActiveRecord::Migration[7.2] + def change + create_table :child_care_assessments, id: :uuid do |t| + t.belongs_to :proceeding, null: false, foreign_key: true, type: :uuid + t.boolean :assessed + t.boolean :result + t.string :details + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index dd7cbecee8..85ba5fe6e4 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.2].define(version: 2024_12_12_085816) do +ActiveRecord::Schema[7.2].define(version: 2025_01_14_142619) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -418,6 +418,16 @@ t.index ["proceeding_id"], name: "index_chances_of_successes_on_proceeding_id" end + create_table "child_care_assessments", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + t.uuid "proceeding_id", null: false + t.boolean "assessed" + t.boolean "result" + t.string "details" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["proceeding_id"], name: "index_child_care_assessments_on_proceeding_id" + end + create_table "citizen_access_tokens", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "legal_aid_application_id", null: false t.string "token", default: "", null: false @@ -1139,6 +1149,7 @@ add_foreign_key "ccms_submissions", "legal_aid_applications", on_delete: :cascade add_foreign_key "cfe_submissions", "legal_aid_applications" add_foreign_key "chances_of_successes", "proceedings", on_delete: :cascade + add_foreign_key "child_care_assessments", "proceedings" add_foreign_key "citizen_access_tokens", "legal_aid_applications", on_delete: :cascade add_foreign_key "dependants", "legal_aid_applications" add_foreign_key "domestic_abuse_summaries", "legal_aid_applications" From df60d93c97040c644b006c95f7c8f51f1147f530 Mon Sep 17 00:00:00 2001 From: Joel Sugarman Date: Tue, 14 Jan 2025 17:26:11 +0000 Subject: [PATCH 3/3] AP-4407: Add model, view, controller, forms and steps for child care assesments --- .../child_care_assessments_controller.rb | 43 +++++ .../child_care_assessment_form.rb | 30 +++ app/models/proceeding.rb | 1 + .../child_care_assessment.rb | 5 + app/services/flow/flows/provider_merits.rb | 1 + app/services/flow/merits_loop.rb | 1 + .../child_care_assessment_step.rb | 32 ++++ .../child_care_assessments/show.html.erb | 24 +++ config/locales/en/activemodel.yml | 4 + config/locales/en/providers.yml | 7 + config/routes.rb | 1 + db/anonymise/rules.rb | 5 + .../legal_framework_merits_task_list.rb | 4 + ...l_framework_serialized_merits_task_list.rb | 25 +++ .../child_care_assessments.rb | 18 ++ spec/factories/proceedings.rb | 19 ++ .../child_care_assessments_controller_spec.rb | 175 ++++++++++++++++++ 17 files changed, 395 insertions(+) create mode 100644 app/controllers/providers/proceeding_merits_task/child_care_assessments_controller.rb create mode 100644 app/forms/providers/proceeding_merits_task/child_care_assessment_form.rb create mode 100644 app/models/proceeding_merits_task/child_care_assessment.rb create mode 100644 app/services/flow/steps/provider_merits/child_care_assessment_step.rb create mode 100644 app/views/providers/proceeding_merits_task/child_care_assessments/show.html.erb create mode 100644 spec/factories/proceeding_merits_task/child_care_assessments.rb create mode 100644 spec/requests/providers/proceeding_merits_task/child_care_assessments_controller_spec.rb diff --git a/app/controllers/providers/proceeding_merits_task/child_care_assessments_controller.rb b/app/controllers/providers/proceeding_merits_task/child_care_assessments_controller.rb new file mode 100644 index 0000000000..b97d7b574f --- /dev/null +++ b/app/controllers/providers/proceeding_merits_task/child_care_assessments_controller.rb @@ -0,0 +1,43 @@ +module Providers + module ProceedingMeritsTask + class ChildCareAssessmentsController < ProviderBaseController + def show + @form = ChildCareAssessmentForm.new(model: child_care_assessment) + end + + def update + @form = ChildCareAssessmentForm.new(form_params.merge(proceeding_id: proceeding.id)) + + if @form.assessed? + save_continue_or_draft(@form) + else + render :show unless update_task_save_continue_or_draft(proceeding.ccms_code.to_sym, :client_child_care_assessment) + end + end + + private + + def child_care_assessment + @child_care_assessment ||= proceeding.child_care_assessment || proceeding.build_child_care_assessment + end + + def proceeding + @proceeding ||= Proceeding.find(params[:merits_task_list_id]) + end + + def legal_aid_application + @legal_aid_application ||= proceeding.legal_aid_application + end + + def form_params + merge_with_model(child_care_assessment) do + params + .require(:proceeding_merits_task_child_care_assessment) + .permit( + :assessed, + ) + end + end + end + end +end diff --git a/app/forms/providers/proceeding_merits_task/child_care_assessment_form.rb b/app/forms/providers/proceeding_merits_task/child_care_assessment_form.rb new file mode 100644 index 0000000000..fe96ecc536 --- /dev/null +++ b/app/forms/providers/proceeding_merits_task/child_care_assessment_form.rb @@ -0,0 +1,30 @@ +module Providers + module ProceedingMeritsTask + class ChildCareAssessmentForm < BaseForm + form_for ::ProceedingMeritsTask::ChildCareAssessment + + attr_accessor :proceeding_id, :assessed + + validates :assessed, inclusion: %w[true false], unless: :draft? + + set_callback :save, :before, :sync_result_details + + def assessed? + attributes["assessed"] == "true" + end + + private + + def sync_result_details + if assessed_changed? + attributes["result"] = nil + attributes["details"] = nil + end + end + + def assessed_changed? + attributes["assessed"] != model.assessed.to_s + end + end + end +end diff --git a/app/models/proceeding.rb b/app/models/proceeding.rb index 2f33354200..d7bde0066b 100644 --- a/app/models/proceeding.rb +++ b/app/models/proceeding.rb @@ -10,6 +10,7 @@ class Proceeding < ApplicationRecord has_one :chances_of_success, class_name: "ProceedingMeritsTask::ChancesOfSuccess", dependent: :destroy has_one :prohibited_steps, class_name: "ProceedingMeritsTask::ProhibitedSteps", dependent: :destroy + has_one :child_care_assessment, class_name: "ProceedingMeritsTask::ChildCareAssessment", dependent: :destroy has_many :final_hearings, dependent: :destroy has_many :proceeding_linked_children, class_name: "ProceedingMeritsTask::ProceedingLinkedChild", dependent: :destroy diff --git a/app/models/proceeding_merits_task/child_care_assessment.rb b/app/models/proceeding_merits_task/child_care_assessment.rb new file mode 100644 index 0000000000..9fc7519bf0 --- /dev/null +++ b/app/models/proceeding_merits_task/child_care_assessment.rb @@ -0,0 +1,5 @@ +module ProceedingMeritsTask + class ChildCareAssessment < ApplicationRecord + belongs_to :proceeding + end +end diff --git a/app/services/flow/flows/provider_merits.rb b/app/services/flow/flows/provider_merits.rb index e18383bd63..041ffd0d8d 100644 --- a/app/services/flow/flows/provider_merits.rb +++ b/app/services/flow/flows/provider_merits.rb @@ -34,6 +34,7 @@ class ProviderMerits < FlowSteps linked_children: Steps::ProviderMerits::LinkedChildrenStep, specific_issue: Steps::ProviderMerits::SpecificIssueStep, vary_order: Steps::ProviderMerits::VaryOrderStep, + child_care_assessments: Steps::ProviderMerits::ChildCareAssessmentStep, is_client_biological_parent: Steps::ProviderMerits::BiologicalParentStep, does_client_have_parental_responsibilities: Steps::ProviderMerits::ParentalResponsibilitiesStep, is_client_child_subject: Steps::ProviderMerits::ChildSubjectStep, diff --git a/app/services/flow/merits_loop.rb b/app/services/flow/merits_loop.rb index 3111ac3ef4..23d94e7958 100644 --- a/app/services/flow/merits_loop.rb +++ b/app/services/flow/merits_loop.rb @@ -47,6 +47,7 @@ def convert_task_to_flow_name(task) vary_order: :vary_order, opponents_application: :opponents_application, client_relationship_to_proceeding: :is_client_biological_parent, + client_child_care_assessment: :child_care_assessment, }[task] end diff --git a/app/services/flow/steps/provider_merits/child_care_assessment_step.rb b/app/services/flow/steps/provider_merits/child_care_assessment_step.rb new file mode 100644 index 0000000000..bd571bb976 --- /dev/null +++ b/app/services/flow/steps/provider_merits/child_care_assessment_step.rb @@ -0,0 +1,32 @@ +module Flow + module Steps + module ProviderMerits + ChildCareAssessmentStep = Step.new( + path: lambda do |application| + proceeding = application.proceedings.find(application.provider_step_params["merits_task_list_id"]) + Steps.urls.providers_merits_task_list_child_care_assessment_path(proceeding) + end, + forward: lambda do |application| + proceeding = application.proceedings.find(application.provider_step_params["merits_task_list_id"]) + Flow::MeritsLoop.forward_flow(application, proceeding.ccms_code.to_sym) + # TODO: AP-5533 - should goto question 4b or CYA page + # if proceeding.child_care_assessment.assessed? + # :child_care_assessment_result + # else + # Flow::MeritsLoop.forward_flow(application, proceeding.ccms_code.to_sym) + # end + end, + check_answers: lambda do |_application| + :check_merits_answers + # TODO: AP-5533 - should goto question 4b or CYA page + # proceeding = application.proceedings.find(application.provider_step_params["merits_task_list_id"]) + # if proceeding.child_care_assessment.assessed? + # :child_care_assessment_result + # else + # :check_merits_answers + # end + end, + ) + end + end +end diff --git a/app/views/providers/proceeding_merits_task/child_care_assessments/show.html.erb b/app/views/providers/proceeding_merits_task/child_care_assessments/show.html.erb new file mode 100644 index 0000000000..00d32d363a --- /dev/null +++ b/app/views/providers/proceeding_merits_task/child_care_assessments/show.html.erb @@ -0,0 +1,24 @@ +<%= form_with( + model: @form, + url: providers_merits_task_list_child_care_assessment_path(@proceeding), + method: :patch, + local: true, + ) do |form| %> + + <%= page_template page_title: t(".h1-heading"), + head_title: "#{@proceeding.meaning} - " + t(".h1-heading"), + template: :basic, + form: do %> + <%= form.govuk_collection_radio_buttons :assessed, + yes_no_options(yes: t(".radio_hint_yes")), + :value, # value_method + :label, # text_method + :radio_hint, # hint_method + bold_labels: false, + caption: { text: @proceeding.meaning, size: "xl" }, + legend: { text: content_for(:page_title), tag: "h1", size: "xl" }, + hint: { text: t(".hint") } %> + + <%= next_action_buttons(show_draft: true, form:) %> + <% end %> +<% end %> diff --git a/config/locales/en/activemodel.yml b/config/locales/en/activemodel.yml index 14b4afc3cc..0d9d51ca40 100644 --- a/config/locales/en/activemodel.yml +++ b/config/locales/en/activemodel.yml @@ -340,6 +340,10 @@ en: attributes: details: blank: Enter details of the changes since the original order was made + proceeding_merits_task/child_care_assessment: + attributes: + assessed: + inclusion: Select yes if the local authority has assessed your client's ability to care for the children involved partner: attributes: date_of_birth: diff --git a/config/locales/en/providers.yml b/config/locales/en/providers.yml index 81b4baa602..dcd6723eef 100644 --- a/config/locales/en/providers.yml +++ b/config/locales/en/providers.yml @@ -530,6 +530,11 @@ en: show: page_title: Check who your client is paragraph: You must answer 'yes' to one of these questions. Check your answers and change the one that is wrong. + child_care_assessments: + show: + h1-heading: Has the local authority assessed your client's ability to care for the children involved? + radio_hint_yes: You'll need to upload supporting evidence later. + hint: For example, if your client is the grandparent, the local authority may check if they could be a suitable carer. application_merits_task: involved_children: new: @@ -1428,6 +1433,7 @@ en: opponents_application_html: %{proceeding} Opponent application vary_order_html: %{proceeding} Changes since original order was made client_relationship_to_proceeding_html: %{proceeding} Who your client is in the proceeding + client_child_care_assessment_html: %{proceeding} Assessment of your client states: not_started: Not started waiting_for_dependency: Cannot start yet @@ -1457,6 +1463,7 @@ en: client_relationship_to_proceeding: is_client_biological_parent check_who_client_is: check_who_client_is second_appeal: second_appeal + client_child_care_assessment: child_care_assessment merits_reports: show: heading: Merits report diff --git a/config/routes.rb b/config/routes.rb index 5bad9bd23b..59cbfdf69b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -390,6 +390,7 @@ resource :does_client_have_parental_responsibility, only: %i[show update] resource :is_client_child_subject, only: %i[show update], controller: :is_client_child_subject, path: "is_client_a_child_subject_of_proceeding" resource :check_who_client_is, only: %i[show update] + resource :child_care_assessment, only: %i[show update], path: "assessment_of_client" end end end diff --git a/db/anonymise/rules.rb b/db/anonymise/rules.rb index baeb0b108f..d5d7c523ac 100644 --- a/db/anonymise/rules.rb +++ b/db/anonymise/rules.rb @@ -100,6 +100,11 @@ row_context[:field_1_val] = Faker::Lorem.paragraph(sentence_count: 2) unless original_value.eql?('\N') end, }, + child_care_assessments: { + details: lambda do |original_value, row_context| + row_context[:field_1_val] = Faker::Lorem.paragraph(sentence_count: 2) unless original_value.eql?('\N') + end, + }, citizen_access_tokens: {}, debugs: {}, dependants: { diff --git a/spec/factories/legal_framework_merits_task_list.rb b/spec/factories/legal_framework_merits_task_list.rb index 606f22c457..1e48f8d81e 100644 --- a/spec/factories/legal_framework_merits_task_list.rb +++ b/spec/factories/legal_framework_merits_task_list.rb @@ -59,6 +59,10 @@ serialized_data { build(:legal_framework_serializable_merits_task_list, :pbm01a).to_yaml } end + trait :pbm32_as_applicant do + serialized_data { build(:legal_framework_serializable_merits_task_list, :pbm32_as_applicant).to_yaml } + end + trait :broken_opponent do serialized_data { build(:legal_framework_serializable_merits_task_list, :broken_opponent).to_yaml } end diff --git a/spec/factories/legal_framework_serialized_merits_task_list.rb b/spec/factories/legal_framework_serialized_merits_task_list.rb index 444ec28028..484774d670 100644 --- a/spec/factories/legal_framework_serialized_merits_task_list.rb +++ b/spec/factories/legal_framework_serialized_merits_task_list.rb @@ -494,6 +494,31 @@ end end + trait :pbm32_as_applicant do + lfa_response do + { + request_id: SecureRandom.uuid, + application: { + tasks: { + opponent_name: [], + statement_of_case: [], + children_application: [], + }, + }, + proceedings: [ + { + ccms_code: "PBM32", + tasks: { + children_proceeding: [:children_application], + chances_of_success: [], + client_child_care_assessment: [], + }, + }, + ], + } + end + end + trait :broken_opponent do lfa_response do { diff --git a/spec/factories/proceeding_merits_task/child_care_assessments.rb b/spec/factories/proceeding_merits_task/child_care_assessments.rb new file mode 100644 index 0000000000..fffd2930f3 --- /dev/null +++ b/spec/factories/proceeding_merits_task/child_care_assessments.rb @@ -0,0 +1,18 @@ +FactoryBot.define do + factory :child_care_assessment, class: "ProceedingMeritsTask::ChildCareAssessment" do + proceeding + assessed { false } + + trait :negative_assessment do + assessed { true } + result { false } + details { Faker::Lorem.paragraph(sentence_count: 2) } + end + + trait :positive_assessment do + assessed { true } + result { true } + details { nil } + end + end +end diff --git a/spec/factories/proceedings.rb b/spec/factories/proceedings.rb index d108813b23..4f7bccab65 100644 --- a/spec/factories/proceedings.rb +++ b/spec/factories/proceedings.rb @@ -419,4 +419,23 @@ client_involvement_type_ccms_code { "A" } client_involvement_type_description { "Applicant/Claimant/Petitioner" } end + + trait :pbm32 do + lead_proceeding { false } + ccms_code { "PBM32" } + meaning { "Special guardianship order" } + description { "to be represented on an application for a Special Guardianship Order" } + substantive_cost_limitation { 25_000 } + delegated_functions_cost_limitation { 2_250 } + used_delegated_functions { nil } + used_delegated_functions_on { nil } + used_delegated_functions_reported_on { nil } + name { "special_guardianship_order_plf" } + matter_type { "public law family (PLF)" } + category_of_law { "Family" } + category_law_code { "MAT" } + ccms_matter_code { "KPBLB" } + client_involvement_type_ccms_code { "A" } + client_involvement_type_description { "Applicant/Claimant/Petitioner" } + end end diff --git a/spec/requests/providers/proceeding_merits_task/child_care_assessments_controller_spec.rb b/spec/requests/providers/proceeding_merits_task/child_care_assessments_controller_spec.rb new file mode 100644 index 0000000000..03fb230381 --- /dev/null +++ b/spec/requests/providers/proceeding_merits_task/child_care_assessments_controller_spec.rb @@ -0,0 +1,175 @@ +require "rails_helper" + +RSpec.describe Providers::ProceedingMeritsTask::ChildCareAssessmentsController do + let!(:legal_aid_application) { create(:legal_aid_application, :with_proceedings, explicit_proceedings: [:pbm32]) } + let(:smtl) { create(:legal_framework_merits_task_list, :pbm32_as_applicant, legal_aid_application:) } + let(:proceeding) { legal_aid_application.proceedings.find_by(ccms_code: "PBM32") } + let(:provider) { legal_aid_application.provider } + + before { allow(LegalFramework::MeritsTasksService).to receive(:call).with(legal_aid_application).and_return(smtl) } + + describe "GET /providers/merits_task_list/:id/child_care_assessments" do + subject(:get_request) { get providers_merits_task_list_child_care_assessment_path(proceeding) } + + context "when the provider is not authenticated" do + before { get_request } + + it_behaves_like "a provider not authenticated" + end + + context "when the provider is authenticated" do + before do + login_as provider + get_request + end + + it "returns http success" do + expect(response).to have_http_status(:ok) + expect(response).to render_template("providers/proceeding_merits_task/child_care_assessments/show") + end + end + end + + describe "PATCH providers/merits_task_list/:id/child_care_assessments" do + subject(:patch_request) { patch providers_merits_task_list_child_care_assessment_path(proceeding), params: params.merge(submit_button) } + + let(:params) do + { + proceeding_merits_task_child_care_assessment: { + assessed:, + }, + } + end + + context "when the provider is authenticated" do + before { login_as provider } + + context "with Continue button pressed" do + let(:assessed) { "true" } + let(:submit_button) { { continue_button: "Continue" } } + + it "creates the child_care_assessment record" do + expect { patch_request }.to change { proceeding.reload.child_care_assessment } + .from(nil) + .to(instance_of(ProceedingMeritsTask::ChildCareAssessment)) + end + + it "updates the child_care_assessment assessed" do + expect { patch_request }.to change { proceeding.reload.child_care_assessment&.reload&.assessed } + .from(nil) + .to(true) + end + + it "redirects to the next page" do + patch_request + expect(response).to have_http_status(:redirect) + end + + context "when yes selected" do + let(:assessed) { "true" } + + it "leaves the task as not_started" do + patch_request + expect(legal_aid_application.legal_framework_merits_task_list) + .to have_task_in_state(:PBM32, :client_child_care_assessment, :not_started) + end + + it "redirects to the assessment result page", skip: "TODO: AP-5533" do + patch_request + expect(response).to have_http_status(:redirect) + expect(response).to render_template("providers/proceeding_merits_task/child_care_assessment_results/show") + end + end + + context "when no selected" do + let(:assessed) { "false" } + + it "updates the task to be completed" do + patch_request + expect(legal_aid_application.legal_framework_merits_task_list) + .to have_task_in_state(:PBM32, :client_child_care_assessment, :complete) + end + end + + context "when nothing selected" do + let(:assessed) { nil } + + it "renders show" do + patch_request + expect(response) + .to have_http_status(:ok) + .and render_template("providers/proceeding_merits_task/child_care_assessments/show") + end + + it "displays expected error" do + patch_request + expect(page) + .to have_content("Select yes if the local authority has assessed your client's ability to care for the children involved") + end + end + + context "when assessed changed from yes to no" do + before do + create(:child_care_assessment, :negative_assessment, assessed: true, proceeding:) + end + + let(:assessed) { "false" } + + it "clears the assessment result and details" do + expect { patch_request } + .to change { proceeding.child_care_assessment.reload.attributes.symbolize_keys } + .from(hash_including(result: false, details: instance_of(String))) + .to(hash_including(result: nil, details: nil)) + end + end + + context "when assessed changed from no to yes" do + before do + create(:child_care_assessment, :positive_assessment, assessed: false, proceeding:) + end + + let(:assessed) { "true" } + + it "clears the assessment result (and details)" do + expect { patch_request } + .to change { proceeding.child_care_assessment.reload.attributes.symbolize_keys } + .from(hash_including(result: true, details: nil)) + .to(hash_including(result: nil, details: nil)) + end + end + end + + context "with Save as draft button pressed", skip: "TODO: AP-4407" do + let(:submit_button) do + { + draft_button: "Save as draft", + } + end + + it "creates the child_care_assessment record" do + expect { patch_request }.to change { proceeding.reload.child_care_assessment } + .from(nil) + .to(instance_of(ProceedingMeritsTask::ChildCareAssessment)) + end + + it "updates the record" do + expect(proceeding.chances_of_success.reload.success_prospect).to eq(success_prospect) + expect(proceeding.chances_of_success.reload.success_prospect_details).to eq(success_prospect_details) + end + + it "redirects to provider applications home page" do + expect(response).to redirect_to submitted_providers_legal_aid_applications_path + end + + context "with nothing specified" do + let(:success_prospect) { nil } + let(:success_prospect_details) { nil } + + it "redirects to provider applications home page" do + expect(response).to redirect_to submitted_providers_legal_aid_applications_path + end + end + end + end + end +end