Skip to content

Commit

Permalink
Users can change two requires improvement response
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
mec and beeLorna committed Apr 8, 2024
1 parent a09c72e commit 10d1090
Show file tree
Hide file tree
Showing 13 changed files with 94 additions and 24 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
3 changes: 2 additions & 1 deletion app/controllers/conversions/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 7 additions & 2 deletions app/forms/conversion/edit_project_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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

Expand All @@ -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!
Expand Down
7 changes: 0 additions & 7 deletions app/forms/create_project_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions app/helpers/project_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
</div>
10 changes: 10 additions & 0 deletions app/views/conversions/projects/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@
form_group: {id: "directive-academy-order"} %>
</div>

<div class="govuk-form-group">
<%= 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"} %>
</div>

<%= form.govuk_submit do %>
<%= govuk_link_to "Cancel", project_information_path(@project) %>
<% end %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/conversions/projects/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</div>

<div class="govuk-form-group">
<%= 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} %>
Expand All @@ -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")},
Expand Down
4 changes: 2 additions & 2 deletions app/views/conversions/projects/new_mat.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</div>

<div class="govuk-form-group">
<%= 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} %>
Expand All @@ -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")},
Expand Down
10 changes: 5 additions & 5 deletions app/views/transfers/projects/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -37,34 +37,34 @@

<div class="govuk-form-group">
<%= 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"} %>
</div>

<div class="govuk-form-group">
<%= 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"},
Expand Down
10 changes: 5 additions & 5 deletions app/views/transfers/projects/new_mat.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -44,34 +44,34 @@

<div class="govuk-form-group">
<%= 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"} %>
</div>

<div class="govuk-form-group">
<%= 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"},
Expand Down
35 changes: 35 additions & 0 deletions spec/features/conversions/users_can_edit_project_details_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions spec/forms/conversion/edit_project_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 10d1090

Please sign in to comment.