From 10d10902be7cec6af13cac36ae366d9531ab1480 Mon Sep 17 00:00:00 2001 From: meyric Date: Mon, 8 Apr 2024 12:01:45 +0100 Subject: [PATCH] Users can change two requires improvement response Like other conversion project attributes, we want users to be able to change the response they gave for 'Is this conversion due to intervention following 2RI?'. Co-authored-by: Lorna --- CHANGELOG.md | 2 ++ .../conversions/projects_controller.rb | 3 +- app/forms/conversion/edit_project_form.rb | 9 +++-- app/forms/create_project_form.rb | 7 ---- app/helpers/project_helper.rb | 7 ++++ .../_reasons_for_conversion.html.erb | 1 + app/views/conversions/projects/edit.html.erb | 10 ++++++ app/views/conversions/projects/new.html.erb | 4 +-- .../conversions/projects/new_mat.html.erb | 4 +-- app/views/transfers/projects/new.html.erb | 10 +++--- app/views/transfers/projects/new_mat.html.erb | 10 +++--- .../users_can_edit_project_details_spec.rb | 35 +++++++++++++++++++ .../conversion/edit_project_form_spec.rb | 16 +++++++++ 13 files changed, 94 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5af1141bef..32e24b0b6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - users can now change the advisory board date and any conditions on a conversion project. - users can now change the academy order type for a conversion project. +- users can now change the conversion due to intervention following 2RI response + for a conversion project. ## [Release-62][release-62] diff --git a/app/controllers/conversions/projects_controller.rb b/app/controllers/conversions/projects_controller.rb index 0a767cba89..0926497f7a 100644 --- a/app/controllers/conversions/projects_controller.rb +++ b/app/controllers/conversions/projects_controller.rb @@ -69,7 +69,8 @@ def update :incoming_trust_ukprn, :advisory_board_date, :advisory_board_conditions, - :directive_academy_order + :directive_academy_order, + :two_requires_improvement ) end diff --git a/app/forms/conversion/edit_project_form.rb b/app/forms/conversion/edit_project_form.rb index b20bc504aa..b17b2e7b1f 100644 --- a/app/forms/conversion/edit_project_form.rb +++ b/app/forms/conversion/edit_project_form.rb @@ -11,6 +11,7 @@ class Conversion::EditProjectForm attribute :advisory_board_date, :date attribute :advisory_board_conditions attribute :directive_academy_order, :boolean + attribute :two_requires_improvement, :boolean validates :establishment_sharepoint_link, presence: true, sharepoint_url: true validates :incoming_trust_sharepoint_link, presence: true, sharepoint_url: true @@ -23,6 +24,8 @@ class Conversion::EditProjectForm validates :directive_academy_order, inclusion: {in: [true, false]} + validates :two_requires_improvement, inclusion: {in: [true, false], message: I18n.t("errors.conversion_project.attributes.two_requires_improvement.inclusion")} + def self.new_from_project(project) new( project: project, @@ -31,7 +34,8 @@ def self.new_from_project(project) incoming_trust_ukprn: project.incoming_trust_ukprn, advisory_board_date: project.advisory_board_date, advisory_board_conditions: project.advisory_board_conditions, - directive_academy_order: project.directive_academy_order + directive_academy_order: project.directive_academy_order, + two_requires_improvement: project.two_requires_improvement ) end @@ -51,7 +55,8 @@ def update(params) incoming_trust_ukprn: incoming_trust_ukprn, advisory_board_date: advisory_board_date, advisory_board_conditions: advisory_board_conditions, - directive_academy_order: directive_academy_order + directive_academy_order: directive_academy_order, + two_requires_improvement: two_requires_improvement ) project.save! diff --git a/app/forms/create_project_form.rb b/app/forms/create_project_form.rb index 215943ed26..4247d6cac6 100644 --- a/app/forms/create_project_form.rb +++ b/app/forms/create_project_form.rb @@ -51,13 +51,6 @@ def advisory_board_date=(hash) @attributes_with_invalid_values << :advisory_board_date end - def yes_no_responses - @yes_no_responses ||= [ - OpenStruct.new(id: true, name: I18n.t("yes")), - OpenStruct.new(id: false, name: I18n.t("no")) - ] - end - private def establishment @establishment || fetch_establishment(urn) end diff --git a/app/helpers/project_helper.rb b/app/helpers/project_helper.rb index c5f9277812..f3f1e2312b 100644 --- a/app/helpers/project_helper.rb +++ b/app/helpers/project_helper.rb @@ -84,4 +84,11 @@ def directive_academy_order_responses OpenStruct.new(id: false, name: I18n.t("helpers.responses.conversion_project.directive_academy_order.no")) ] end + + def yes_no_responses + @yes_no_responses ||= [ + OpenStruct.new(id: true, name: I18n.t("yes")), + OpenStruct.new(id: false, name: I18n.t("no")) + ] + end end diff --git a/app/views/conversions/project_information/_reasons_for_conversion.html.erb b/app/views/conversions/project_information/_reasons_for_conversion.html.erb index 0fca8812dc..e90953f743 100644 --- a/app/views/conversions/project_information/_reasons_for_conversion.html.erb +++ b/app/views/conversions/project_information/_reasons_for_conversion.html.erb @@ -9,6 +9,7 @@ summary_list.with_row do |row| row.with_key { t("project_information.show.reasons_for.two_requires_improvement.conversion_project.title") } row.with_value { t("project_information.show.reasons_for.two_requires_improvement.#{project.two_requires_improvement}") } + row.with_action(text: "Change", href: conversions_edit_path(@project, anchor: "two-requires-improvement"), visually_hidden_text: "the conversion due to two requires improvement") end end %> diff --git a/app/views/conversions/projects/edit.html.erb b/app/views/conversions/projects/edit.html.erb index 137d0a6ab2..c8099a0edd 100644 --- a/app/views/conversions/projects/edit.html.erb +++ b/app/views/conversions/projects/edit.html.erb @@ -26,6 +26,16 @@ form_group: {id: "directive-academy-order"} %> +
+ <%= form.govuk_collection_radio_buttons :two_requires_improvement, + yes_no_responses, + :id, + :name, + legend: {text: t("helpers.legend.conversion_project.two_requires_improvement")}, + hint: {text: t("helpers.hint.conversion_project.two_requires_improvement")}, + form_group: {id: "two-requires-improvement"} %> +
+ <%= form.govuk_submit do %> <%= govuk_link_to "Cancel", project_information_path(@project) %> <% end %> diff --git a/app/views/conversions/projects/new.html.erb b/app/views/conversions/projects/new.html.erb index 97c0754923..ed050482c1 100644 --- a/app/views/conversions/projects/new.html.erb +++ b/app/views/conversions/projects/new.html.erb @@ -34,7 +34,7 @@
- <%= form.govuk_collection_radio_buttons :assigned_to_regional_caseworker_team, @project.yes_no_responses, :id, :name, legend: {text: t("helpers.hint.conversion_project.assigned_to_regional_caseworker_team")}, form_group: {id: "assigned-to-regional-caseworker-team"} %> + <%= form.govuk_collection_radio_buttons :assigned_to_regional_caseworker_team, yes_no_responses, :id, :name, legend: {text: t("helpers.hint.conversion_project.assigned_to_regional_caseworker_team")}, form_group: {id: "assigned-to-regional-caseworker-team"} %> <%= form.govuk_text_area :handover_note_body, label: {text: t("project.new.handover_comments_label"), size: "m"}, hint: {text: t("project.new.handover_comments_hint").html_safe} %> @@ -48,7 +48,7 @@ legend: {text: t("helpers.legend.conversion_project.directive_academy_order")}, form_group: {id: "directive-academy-order"} %> <%= form.govuk_collection_radio_buttons :two_requires_improvement, - @project.yes_no_responses, + yes_no_responses, :id, :name, legend: {text: t("helpers.legend.conversion_project.two_requires_improvement")}, diff --git a/app/views/conversions/projects/new_mat.html.erb b/app/views/conversions/projects/new_mat.html.erb index 1c1fb8d951..6d59c8ee4d 100644 --- a/app/views/conversions/projects/new_mat.html.erb +++ b/app/views/conversions/projects/new_mat.html.erb @@ -38,7 +38,7 @@
- <%= form.govuk_collection_radio_buttons :assigned_to_regional_caseworker_team, @project.yes_no_responses, :id, :name, legend: {text: t("helpers.hint.conversion_project.assigned_to_regional_caseworker_team")}, form_group: {id: "assigned-to-regional-caseworker-team"} %> + <%= form.govuk_collection_radio_buttons :assigned_to_regional_caseworker_team, yes_no_responses, :id, :name, legend: {text: t("helpers.hint.conversion_project.assigned_to_regional_caseworker_team")}, form_group: {id: "assigned-to-regional-caseworker-team"} %> <%= form.govuk_text_area :handover_note_body, label: {text: t("project.new.handover_comments_label"), size: "m"}, hint: {text: t("project.new.handover_comments_hint").html_safe} %> @@ -52,7 +52,7 @@ legend: {text: t("helpers.legend.conversion_project.directive_academy_order")}, form_group: {id: "directive-academy-order"} %> <%= form.govuk_collection_radio_buttons :two_requires_improvement, - @project.yes_no_responses, + yes_no_responses, :id, :name, legend: {text: t("helpers.legend.conversion_project.two_requires_improvement")}, diff --git a/app/views/transfers/projects/new.html.erb b/app/views/transfers/projects/new.html.erb index 6c680a1d25..28ee627581 100644 --- a/app/views/transfers/projects/new.html.erb +++ b/app/views/transfers/projects/new.html.erb @@ -37,26 +37,26 @@
<%= form.govuk_collection_radio_buttons :two_requires_improvement, - @project.yes_no_responses, + yes_no_responses, :id, :name, form_group: {id: "two-requires-improvement"}, hint: {text: t("helpers.hint.transfer_project.two_requires_improvement")} %> <%= form.govuk_collection_radio_buttons :inadequate_ofsted, - @project.yes_no_responses, + yes_no_responses, :id, :name, form_group: {id: "inadequate-ofsted"} %> <%= form.govuk_collection_radio_buttons :financial_safeguarding_governance_issues, - @project.yes_no_responses, + yes_no_responses, :id, :name, form_group: {id: "financial-safeguarding-governance-issues"} %> <%= form.govuk_collection_radio_buttons :outgoing_trust_to_close, - @project.yes_no_responses, + yes_no_responses, :id, :name, form_group: {id: "outgoing-trust-to-close"} %> @@ -64,7 +64,7 @@
<%= form.govuk_collection_radio_buttons :assigned_to_regional_caseworker_team, - @project.yes_no_responses, + yes_no_responses, :id, :name, form_group: {id: "assigned-to-regional-caseworker-team"}, diff --git a/app/views/transfers/projects/new_mat.html.erb b/app/views/transfers/projects/new_mat.html.erb index a08aa3be43..77090a6856 100644 --- a/app/views/transfers/projects/new_mat.html.erb +++ b/app/views/transfers/projects/new_mat.html.erb @@ -44,26 +44,26 @@
<%= form.govuk_collection_radio_buttons :two_requires_improvement, - @project.yes_no_responses, + yes_no_responses, :id, :name, form_group: {id: "two-requires-improvement"}, hint: {text: t("helpers.hint.transfer_project.two_requires_improvement")} %> <%= form.govuk_collection_radio_buttons :inadequate_ofsted, - @project.yes_no_responses, + yes_no_responses, :id, :name, form_group: {id: "inadequate-ofsted"} %> <%= form.govuk_collection_radio_buttons :financial_safeguarding_governance_issues, - @project.yes_no_responses, + yes_no_responses, :id, :name, form_group: {id: "financial-safeguarding-governance-issues"} %> <%= form.govuk_collection_radio_buttons :outgoing_trust_to_close, - @project.yes_no_responses, + yes_no_responses, :id, :name, form_group: {id: "outgoing-trust-to-close"} %> @@ -71,7 +71,7 @@
<%= form.govuk_collection_radio_buttons :assigned_to_regional_caseworker_team, - @project.yes_no_responses, + yes_no_responses, :id, :name, form_group: {id: "assigned-to-regional-caseworker-team"}, diff --git a/spec/features/conversions/users_can_edit_project_details_spec.rb b/spec/features/conversions/users_can_edit_project_details_spec.rb index 53d790237d..d7535a345b 100644 --- a/spec/features/conversions/users_can_edit_project_details_spec.rb +++ b/spec/features/conversions/users_can_edit_project_details_spec.rb @@ -138,6 +138,41 @@ expect(page).to have_content("No") end end + + scenario "they can change the two requires improvement response" do + visit project_information_path(project) + + row = find("#reasonsFor .govuk-summary-list__row:nth-child(2)") + + within(row) do + expect(page).to have_content("No") + click_link "Change" + end + + within("#two-requires-improvement") do + choose("Yes") + end + + click_on "Continue" + + within(row) do + expect(page).to have_content("Yes") + end + + within(row) do + click_link "Change" + end + + within("#two-requires-improvement") do + choose("No") + end + + click_on "Continue" + + within(row) do + expect(page).to have_content("No") + end + end end def mock_api_for_editing diff --git a/spec/forms/conversion/edit_project_form_spec.rb b/spec/forms/conversion/edit_project_form_spec.rb index 678eb86567..81978f6e04 100644 --- a/spec/forms/conversion/edit_project_form_spec.rb +++ b/spec/forms/conversion/edit_project_form_spec.rb @@ -132,5 +132,21 @@ expect(project.directive_academy_order).to be false end end + + describe "two requires improvement" do + it "can be changed" do + updated_params = {two_requires_improvement: "true"} + + subject.update(updated_params) + + expect(project.two_requires_improvement).to be true + + updated_params = {two_requires_improvement: "false"} + + subject.update(updated_params) + + expect(project.two_requires_improvement).to be false + end + end end end