Browse Source

last UI changes

juris_katrina_test
JG 3 years ago
parent
commit
bd7a6eda46
  1. 4
      app/models/location.rb
  2. 34
      app/models/scheme.rb
  3. 2
      app/views/locations/edit.html.erb
  4. 2
      app/views/schemes/details.html.erb
  5. 2
      app/views/schemes/new.html.erb
  6. 21
      app/views/schemes/support.html.erb
  7. 2
      spec/factories/scheme.rb
  8. 4
      spec/features/schemes_spec.rb
  9. 23
      spec/requests/schemes_controller_spec.rb
  10. 6
      spec/services/imports/scheme_location_import_service_spec.rb

4
app/models/location.rb

@ -23,12 +23,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

34
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
@ -159,4 +157,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

2
app/views/locations/edit.html.erb

@ -26,7 +26,7 @@
<%= f.govuk_number_field :units,
label: { text: "Total number of units at this location", size: "m" },
width: 2,
hint: { text: "A unit can be a bedroom in a shared house or flat, or a house with 4 bedrooms. Do not include bedrooms used for wardens, managers, volunteers or sleep-in staff.s" },
hint: { text: "A unit can be a bedroom in a shared house or flat, or a house with 4 bedrooms. Do not include bedrooms used for wardens, managers, volunteers or sleep-in staff" },
autofocus: true %>
<% type_of_units_selection = Location.type_of_units.keys.map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %>

2
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,

2
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,

21
app/views/schemes/support.html.erb

@ -14,19 +14,22 @@
<div class="govuk-grid-column-two-thirds">
<%= 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" %>

2
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 }

4
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

23
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

6
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
@ -145,7 +145,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

Loading…
Cancel
Save