From 0916c1e94af09b3097db3395b0054e694f65302c Mon Sep 17 00:00:00 2001 From: Arthur Campbell Date: Thu, 15 Jun 2023 16:45:39 +0100 Subject: [PATCH] amend ordering in scheme and location show pages to raise status towards top implement a muted explanation text on schemes when they have complete details but no active locations to explain why they are incomplete write tests to ensure this text is shown under the right conditions --- app/helpers/locations_helper.rb | 2 +- app/helpers/schemes_helper.rb | 2 +- app/views/schemes/show.html.erb | 7 ++++++- spec/requests/schemes_controller_spec.rb | 17 +++++++++++++++++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/app/helpers/locations_helper.rb b/app/helpers/locations_helper.rb index 619bf20d5..235029e9d 100644 --- a/app/helpers/locations_helper.rb +++ b/app/helpers/locations_helper.rb @@ -27,13 +27,13 @@ module LocationsHelper [ { name: "Postcode", value: location.postcode, attribute: "postcode" }, { name: "Location name", value: location.name, attribute: "name" }, + { name: "Status", value: location.status, attribute: "status" }, { name: "Local authority", value: formatted_local_authority_timeline(location, "name"), attribute: "local_authority" }, { name: "Number of units", value: location.units, attribute: "units" }, { name: "Most common unit", value: location.type_of_unit, attribute: "type_of_unit" }, { name: "Mobility standards", value: location.mobility_type, attribute: "mobility_standards" }, { name: "Location code", value: formatted_local_authority_timeline(location, "code"), attribute: "location_code" }, { name: "Availability", value: location_availability(location), attribute: "availability" }, - { name: "Status", value: location.status, attribute: "status" }, ] end diff --git a/app/helpers/schemes_helper.rb b/app/helpers/schemes_helper.rb index 7f801d8a6..204ac19aa 100644 --- a/app/helpers/schemes_helper.rb +++ b/app/helpers/schemes_helper.rb @@ -3,6 +3,7 @@ module SchemesHelper base_attributes = [ { name: "Scheme code", value: scheme.id_to_display }, { name: "Name", value: scheme.service_name, edit: true }, + { name: "Status", value: status_tag(scheme.status) }, { name: "Confidential information", value: scheme.sensitive, edit: true }, { name: "Type of scheme", value: scheme.scheme_type }, { name: "Registered under Care Standards Act 2000", value: scheme.registered_under_care_act }, @@ -14,7 +15,6 @@ module SchemesHelper { name: "Level of support given", value: scheme.support_type }, { name: "Intended length of stay", value: scheme.intended_stay }, { name: "Availability", value: scheme_availability(scheme) }, - { name: "Status", value: status_tag_from_resource(scheme) }, ] if user.data_coordinator? diff --git a/app/views/schemes/show.html.erb b/app/views/schemes/show.html.erb index 4fe3a65de..66209fa28 100644 --- a/app/views/schemes/show.html.erb +++ b/app/views/schemes/show.html.erb @@ -19,7 +19,12 @@ <% display_scheme_attributes(@scheme, current_user).each do |attr| %> <%= summary_list.row do |row| %> <% row.key { attr[:name] } %> - <% row.value { details_html(attr) } %> + <% row.value do %> + <%= details_html(attr) %> + <% if attr[:name] == "Status" && @scheme.confirmed? && @scheme.locations.confirmed.none? %> + Add a location to complete this scheme + <% end %> + <% end %> <% if SchemePolicy.new(current_user, @scheme).update? %> <% row.action(text: "Change", href: scheme_edit_name_path(scheme_id: @scheme.id)) if attr[:edit] %> <% end %> diff --git a/spec/requests/schemes_controller_spec.rb b/spec/requests/schemes_controller_spec.rb index b68e31b06..754d8cb22 100644 --- a/spec/requests/schemes_controller_spec.rb +++ b/spec/requests/schemes_controller_spec.rb @@ -364,6 +364,23 @@ RSpec.describe SchemesController, type: :request do expect(page).not_to have_content("Deactivate this scheme") end end + + context "when the scheme has all details but no confirmed locations" do + it "shows the scheme as incomplete with text to explain" do + get scheme_path(specific_scheme) + expect(page).to have_content "Incomplete" + expect(page).to have_content "Add a location to complete this scheme" + end + end + + context "when the scheme has all details and confirmed locations" do + it "shows the scheme as complete" do + create(:location, scheme: specific_scheme) + get scheme_path(specific_scheme) + expect(page).to have_content "Active" + expect(page).not_to have_content "Add a location to complete this scheme" + end + end end context "when signed in as a support user" do