From 480f2cdb327131822c2524a6c2964d2d8584cc9a Mon Sep 17 00:00:00 2001 From: JG Date: Wed, 13 Jul 2022 17:36:12 +0100 Subject: [PATCH] last UI changes --- app/models/location.rb | 4 +-- app/models/scheme.rb | 34 ++++++++++++++----- app/views/locations/edit.html.erb | 5 --- app/views/schemes/details.html.erb | 2 +- app/views/schemes/new.html.erb | 2 +- app/views/schemes/support.html.erb | 21 +++++++----- spec/factories/scheme.rb | 2 +- spec/features/schemes_spec.rb | 4 +-- spec/requests/schemes_controller_spec.rb | 23 +++++-------- .../scheme_location_import_service_spec.rb | 6 ++-- 10 files changed, 57 insertions(+), 46 deletions(-) diff --git a/app/models/location.rb b/app/models/location.rb index 608bde049..0d5bf1a76 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -25,12 +25,12 @@ class Location < ApplicationRecord enum mobility_type: MOBILITY_TYPE TYPE_OF_UNIT = { + "Bungalow": 6, "Self-contained flat or bedsit": 1, "Self-contained flat or bedsit with common facilities": 2, + "Self-contained house": 7, "Shared flat": 3, "Shared house or hostel": 4, - "Bungalow": 6, - "Self-contained house": 7, }.freeze enum type_of_unit: TYPE_OF_UNIT diff --git a/app/models/scheme.rb b/app/models/scheme.rb index 216d573a5..53524499f 100644 --- a/app/models/scheme.rb +++ b/app/models/scheme.rb @@ -37,12 +37,10 @@ class Scheme < ApplicationRecord SUPPORT_TYPE = { "Missing": 0, - "Resettlement support": 1, - "Low levels of support": 2, - "Medium levels of support": 3, - "High levels of care and support": 4, - "Nursing care services to a care home": 5, - "Floating Support": 6, + "Low level": 2, + "Medium level": 3, + "High level": 4, + "Nursing care in a care home": 5, }.freeze enum support_type: SUPPORT_TYPE, _suffix: true @@ -71,10 +69,10 @@ class Scheme < ApplicationRecord enum secondary_client_group: PRIMARY_CLIENT_GROUP, _suffix: true INTENDED_STAY = { + "Very short stay": "V", + "Short stay": "S", "Medium stay": "M", "Permanent": "P", - "Short stay": "S", - "Very short stay": "V", "Missing": "X", }.freeze @@ -171,4 +169,24 @@ class Scheme < ApplicationRecord Scheme.registered_under_care_acts.keys.map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize, description: hints[key.to_sym]) } end + + def support_level_options_with_hints + hints = { + "Low level": "Staff visiting once a week, fortnightly or less.", + "Medium level": "Staff on site daily or making frequent visits with some out-of-hours cover.", + "High level": "Intensive level of staffing provided on a 24-hour basis.", + } + Scheme.support_types.keys.excluding("Missing").map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize, description: hints[key.to_sym]) } + end + + def intended_length_of_stay_options_with_hints + hints = { + "Very short stay": "Up to one month.", + "Short stay": "Up to one year.", + "Medium stay": "More than one year but with an expectation to move on.", + "Permanent": "Provides a home for life with no requirement for the tenant to move.", + + } + Scheme.intended_stays.keys.excluding("Missing").map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize, description: hints[key.to_sym]) } + end end diff --git a/app/views/locations/edit.html.erb b/app/views/locations/edit.html.erb index def74ee65..227605485 100644 --- a/app/views/locations/edit.html.erb +++ b/app/views/locations/edit.html.erb @@ -41,17 +41,12 @@ wheelchair_user_selection, :id, :name, -<<<<<<< HEAD hint: { text: I18n.t("hints.location.wheelchair_adaptation") }, legend: { text: I18n.t("questions.location.wheelchair_adaptation"), size: "m" } %> <%= f.govuk_date_field :startdate, legend: { text: I18n.t("questions.location.startdate"), size: "m" }, width: 20 %> -======= - hint: { text: "This includes stairlifts, ramps, level-access showers or grab rails" }, - legend: { text: "Are the majority of units in this location built or adapted to wheelchair-user standards? (optional)", size: "m" } %> ->>>>>>> 006a9517 (tests for missing params) <%= govuk_section_break(visible: true, size: "m") %> diff --git a/app/views/schemes/details.html.erb b/app/views/schemes/details.html.erb index d8202d53e..71e2e5df9 100644 --- a/app/views/schemes/details.html.erb +++ b/app/views/schemes/details.html.erb @@ -41,7 +41,7 @@ legend: { text: "What is this type of scheme?", size: "m" } %> <%= f.govuk_collection_radio_buttons :registered_under_care_act, - @scheme.care_acts_options_with_hint, + @scheme.care_acts_options_with_hints, :id, :name, :description, diff --git a/app/views/schemes/new.html.erb b/app/views/schemes/new.html.erb index 75fc4f8cc..9da4d1d95 100644 --- a/app/views/schemes/new.html.erb +++ b/app/views/schemes/new.html.erb @@ -45,7 +45,7 @@ legend: { text: "What is this type of scheme?", size: "m" } %> <%= f.govuk_collection_radio_buttons :registered_under_care_act, - @scheme.care_acts_options_with_hint, + @scheme.care_acts_options_with_hints, :id, :name, :description, diff --git a/app/views/schemes/support.html.erb b/app/views/schemes/support.html.erb index b4482bf66..5ecf2529c 100644 --- a/app/views/schemes/support.html.erb +++ b/app/views/schemes/support.html.erb @@ -14,19 +14,22 @@
<%= f.govuk_error_summary %> - <% support_type_selection = Scheme.support_types.keys.excluding("Missing").map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %> <%= f.govuk_collection_radio_buttons :support_type, - support_type_selection, - :id, - :name, - legend: { text: "Level of support given", size: "m" } %> + @scheme.support_level_options_with_hints, + :id, + :name, + :description, + legend: { text: "Level of support given", size: "m" }, + bold_labels: false %> <% intended_stay_selection = Scheme.intended_stays.keys.excluding("Missing").map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %> <%= f.govuk_collection_radio_buttons :intended_stay, - intended_stay_selection, - :id, - :name, - legend: { text: "Intended length of stay", size: "m" } %> + @scheme.intended_length_of_stay_options_with_hints, + :id, + :name, + :description, + legend: { text: "Intended length of stay", size: "m" }, + bold_labels: false %> <%= f.hidden_field :page, value: "support" %> diff --git a/spec/factories/scheme.rb b/spec/factories/scheme.rb index ecd83a930..c27b8a576 100644 --- a/spec/factories/scheme.rb +++ b/spec/factories/scheme.rb @@ -3,7 +3,7 @@ FactoryBot.define do service_name { Faker::Name.name } sensitive { Faker::Number.within(range: 0..1) } registered_under_care_act { 1 } - support_type { Faker::Number.within(range: 0..6) } + support_type { [0, 2, 3, 4, 5].sample } scheme_type { 0 } intended_stay { %w[M P S V X].sample } primary_client_group { %w[O H M L A G F B D E I S N R Q P X].sample } diff --git a/spec/features/schemes_spec.rb b/spec/features/schemes_spec.rb index 783e13432..4fe010489 100644 --- a/spec/features/schemes_spec.rb +++ b/spec/features/schemes_spec.rb @@ -370,7 +370,7 @@ RSpec.describe "Schemes scheme Features" do context "when I select the support answers" do before do - choose "Floating support" + choose "Low level" choose "Very short stay" click_button "Save and continue" end @@ -667,7 +667,7 @@ RSpec.describe "Schemes scheme Features" do context "when I select the support answers" do before do - choose "Floating support" + choose "Low level" choose "Very short stay" click_button "Save and continue" end diff --git a/spec/requests/schemes_controller_spec.rb b/spec/requests/schemes_controller_spec.rb index 3384bd4b2..b970fa57d 100644 --- a/spec/requests/schemes_controller_spec.rb +++ b/spec/requests/schemes_controller_spec.rb @@ -527,7 +527,7 @@ RSpec.describe SchemesController, type: :request do it "displays the new page with an error message" do post "/schemes", params: params expect(response).to have_http_status(:unprocessable_entity) - expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.owning_organisation_id.required")) + expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.owning_organisation_id.invalid")) end end end @@ -596,11 +596,6 @@ RSpec.describe SchemesController, type: :request do expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.support_services_provider.invalid")) end - it "updates a scheme with valid params" do - follow_redirect! - expect(scheme_to_update.reload.managing_organisation_id).to eq(organisation.id) - end - context "when updating from check answers page" do let(:params) { { scheme: { primary_client_group: "Homeless families with support needs", page: "primary-client-group", check_answers: "true" } } } @@ -753,7 +748,7 @@ RSpec.describe SchemesController, type: :request do end context "when updating support" do - let(:params) { { scheme: { intended_stay: "Medium stay", support_type: "Resettlement support", page: "support" } } } + let(:params) { { scheme: { intended_stay: "Medium stay", support_type: "Low level", page: "support" } } } it "renders add location to this scheme successful update" do follow_redirect! @@ -764,11 +759,11 @@ RSpec.describe SchemesController, type: :request do it "updates a scheme with valid params" do follow_redirect! expect(scheme_to_update.reload.intended_stay).to eq("Medium stay") - expect(scheme_to_update.reload.support_type).to eq("Resettlement support") + expect(scheme_to_update.reload.support_type).to eq("Low level") end context "when updating from check answers page" do - let(:params) { { scheme: { intended_stay: "Medium stay", support_type: "Resettlement support", page: "support", check_answers: "true" } } } + let(:params) { { scheme: { intended_stay: "Medium stay", support_type: "Low level", page: "support", check_answers: "true" } } } it "renders check answers page after successful update" do follow_redirect! @@ -779,7 +774,7 @@ RSpec.describe SchemesController, type: :request do it "updates a scheme with valid params" do follow_redirect! expect(scheme_to_update.reload.intended_stay).to eq("Medium stay") - expect(scheme_to_update.reload.support_type).to eq("Resettlement support") + expect(scheme_to_update.reload.support_type).to eq("Low level") end end end @@ -1010,7 +1005,7 @@ RSpec.describe SchemesController, type: :request do end context "when updating support" do - let(:params) { { scheme: { intended_stay: "Medium stay", support_type: "Resettlement support", page: "support" } } } + let(:params) { { scheme: { intended_stay: "Medium stay", support_type: "Low level", page: "support" } } } it "renders confirm secondary group after successful update" do follow_redirect! @@ -1021,11 +1016,11 @@ RSpec.describe SchemesController, type: :request do it "updates a scheme with valid params" do follow_redirect! expect(scheme_to_update.reload.intended_stay).to eq("Medium stay") - expect(scheme_to_update.reload.support_type).to eq("Resettlement support") + expect(scheme_to_update.reload.support_type).to eq("Low level") end context "when updating from check answers page" do - let(:params) { { scheme: { intended_stay: "Medium stay", support_type: "Resettlement support", page: "support", check_answers: "true" } } } + let(:params) { { scheme: { intended_stay: "Medium stay", support_type: "Low level", page: "support", check_answers: "true" } } } it "renders check answers page after successful update" do follow_redirect! @@ -1036,7 +1031,7 @@ RSpec.describe SchemesController, type: :request do it "updates a scheme with valid params" do follow_redirect! expect(scheme_to_update.reload.intended_stay).to eq("Medium stay") - expect(scheme_to_update.reload.support_type).to eq("Resettlement support") + expect(scheme_to_update.reload.support_type).to eq("Low level") end end end diff --git a/spec/services/imports/scheme_location_import_service_spec.rb b/spec/services/imports/scheme_location_import_service_spec.rb index 199424f54..a7c13aaca 100644 --- a/spec/services/imports/scheme_location_import_service_spec.rb +++ b/spec/services/imports/scheme_location_import_service_spec.rb @@ -81,8 +81,8 @@ RSpec.describe Imports::SchemeLocationImportService do old_scheme = Scheme.find(scheme.id) new_scheme = location.scheme - expect(old_scheme.service_name).to eq("Management Group - Low levels of support") - expect(new_scheme.service_name).to eq("Management Group - Medium levels of support") + expect(old_scheme.service_name).to eq("Management Group - Low level") + expect(new_scheme.service_name).to eq("Management Group - Medium level") end end @@ -146,7 +146,7 @@ RSpec.describe Imports::SchemeLocationImportService do location = location_service.create_scheme_location(location_xml) expect(location.scheme.scheme_type).to eq("Housing for older people") expect(location.scheme.registered_under_care_act).to eq("No") - expect(location.scheme.support_type).to eq("Low levels of support") + expect(location.scheme.support_type).to eq("Low level") expect(location.scheme.intended_stay).to eq("Permanent") expect(location.scheme.primary_client_group).to eq("Older people with support needs") expect(location.scheme.secondary_client_group).to be_nil