Browse Source

Merge ede2c4979b into 21b1691831

pull/3142/merge
Samuel Young 3 days ago committed by GitHub
parent
commit
47116f1b06
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 9
      app/models/scheme.rb
  2. 6
      app/views/schemes/details.html.erb
  3. 6
      app/views/schemes/new.html.erb
  4. 5
      db/migrate/20260114160036_update_scheme_care_standards_values.rb
  5. 4
      db/schema.rb
  6. 2
      spec/features/schemes_helpers.rb
  7. 10
      spec/fixtures/files/original_schemes.csv
  8. 4
      spec/fixtures/files/updated_schemes.csv
  9. 6
      spec/lib/tasks/update_schemes_and_locations_from_csv_spec.rb

9
app/models/scheme.rb

@ -148,9 +148,8 @@ class Scheme < ApplicationRecord
enum :sensitive, SENSITIVE, suffix: true
REGISTERED_UNDER_CARE_ACT = {
"Yes – registered care home providing nursing care": 4,
"Yes – registered care home providing personal care": 3,
"Yes – part registered as a care home": 2,
"Yes": 5,
"Partially - some but not all units in the scheme are regulated by the CQC": 2,
"No": 1,
}.freeze
@ -262,10 +261,10 @@ class Scheme < ApplicationRecord
]
end
def care_acts_options_with_hints
def self.care_acts_options_with_hints
hints = { "Yes – part registered as a care home": "A proportion of units are registered as being a care home." }
Scheme.registered_under_care_acts.keys.map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize, description: hints[key.to_sym]) }
Scheme.registered_under_care_acts.keys.map { |key, _| OpenStruct.new(id: key, name: key.to_s, description: hints[key.to_sym]) }
end
def support_level_options_with_hints

6
app/views/schemes/details.html.erb

@ -38,12 +38,8 @@
:name,
legend: { text: "What is this type of scheme?", size: "m" } %>
<% care_acts_options_hints = { "Yes – part registered as a care home": "A proportion of units are registered as being a care home." } %>
<% care_acts_options_with_hints = Scheme.registered_under_care_acts.keys.map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize, description: care_acts_options_hints[key.to_sym]) } %>
<%= f.govuk_collection_radio_buttons :registered_under_care_act,
care_acts_options_with_hints,
Scheme.care_acts_options_with_hints,
:id,
:name,
:description,

6
app/views/schemes/new.html.erb

@ -33,12 +33,8 @@
:name,
legend: { text: "What is this type of scheme?", size: "m" } %>
<% care_acts_options_hints = { "Yes – part registered as a care home": "A proportion of units are registered as being a care home." } %>
<% care_acts_options_with_hints = Scheme.registered_under_care_acts.keys.map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize, description: care_acts_options_hints[key.to_sym]) } %>
<%= f.govuk_collection_radio_buttons :registered_under_care_act,
care_acts_options_with_hints,
Scheme.care_acts_options_with_hints,
:id,
:name,
:description,

5
db/migrate/20260114160036_update_scheme_care_standards_values.rb

@ -0,0 +1,5 @@
class UpdateSchemeCareStandardsValues < ActiveRecord::Migration[7.2]
def change
Scheme.where(registered_under_care_act: [3, 4]).update!(registered_under_care_act: 5)
end
end

4
db/schema.rb

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.2].define(version: 2025_04_16_111741) do
ActiveRecord::Schema[7.2].define(version: 2026_01_14_160036) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -84,7 +84,7 @@ ActiveRecord::Schema[7.2].define(version: 2025_04_16_111741) do
t.datetime "last_accessed"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.check_constraint "log_type::text = ANY (ARRAY['lettings'::character varying, 'sales'::character varying]::text[])", name: "log_type_check"
t.check_constraint "log_type::text = ANY (ARRAY['lettings'::character varying::text, 'sales'::character varying::text])", name: "log_type_check"
t.check_constraint "year >= 2000 AND year <= 2099", name: "year_check"
end

2
spec/features/schemes_helpers.rb

@ -29,7 +29,7 @@ module SchemesHelpers
fill_in "Scheme name", with: "FooBar"
check "This scheme contains confidential information"
choose "Direct access hostel"
choose "Yes – registered care home providing nursing care"
choose "Yes"
select organisation_name, from: "scheme-owning-organisation-id-field"
choose answers["housing_stock_owners"].presence || "The same organisation that owns the housing stock"
click_button "Save and continue"

10
spec/fixtures/files/original_schemes.csv vendored

@ -1,6 +1,6 @@
scheme_code,scheme_service_name,scheme_status,scheme_confidential,scheme_type,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_support_services_provided_by,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,scheme_active_dates
{id1},Test name,active,Yes,Housing for older people,Yes – registered care home providing nursing care,MHCLG,The same organisation that owns the housing stock,People with alcohol problems,Yes,Older people with support needs,High level,Medium stay,2021-04-01T00:00:00+01:00,"Active from 1 April 2020"
{id2},Test name,active,Yes,Housing for older people,Yes – registered care home providing nursing care,MHCLG,The same organisation that owns the housing stock,People with alcohol problems,Yes,Older people with support needs,High level,Medium stay,2021-04-01T00:00:00+01:00,"Active from 1 April 2020"
{id3},Test name,active,Yes,Housing for older people,Yes – registered care home providing nursing care,MHCLG,The same organisation that owns the housing stock,People with alcohol problems,Yes,Older people with support needs,High level,Medium stay,2021-04-01T00:00:00+01:00,"Active from 1 April 2020"
{id4},Incomplete scheme,incomplete,Yes,Housing for older people,Yes – registered care home providing nursing care,MHCLG,The same organisation that owns the housing stock,People with alcohol problems,,,,,2021-04-01T00:00:00+01:00,"Active from 1 April 2020"
SWrong_id,Incomplete scheme,incomplete,Yes,Housing for older people,Yes – registered care home providing nursing care,MHCLG,The same organisation that owns the housing stock,People with alcohol problems,,,,,2021-04-01T00:00:00+01:00,"Active from 1 April 2020"
{id1},Test name,active,Yes,Housing for older people,Yes,MHCLG,The same organisation that owns the housing stock,People with alcohol problems,Yes,Older people with support needs,High level,Medium stay,2021-04-01T00:00:00+01:00,"Active from 1 April 2020"
{id2},Test name,active,Yes,Housing for older people,Yes,MHCLG,The same organisation that owns the housing stock,People with alcohol problems,Yes,Older people with support needs,High level,Medium stay,2021-04-01T00:00:00+01:00,"Active from 1 April 2020"
{id3},Test name,active,Yes,Housing for older people,Yes,MHCLG,The same organisation that owns the housing stock,People with alcohol problems,Yes,Older people with support needs,High level,Medium stay,2021-04-01T00:00:00+01:00,"Active from 1 April 2020"
{id4},Incomplete scheme,incomplete,Yes,Housing for older people,Yes,MHCLG,The same organisation that owns the housing stock,People with alcohol problems,,,,,2021-04-01T00:00:00+01:00,"Active from 1 April 2020"
SWrong_id,Incomplete scheme,incomplete,Yes,Housing for older people,Yes,MHCLG,The same organisation that owns the housing stock,People with alcohol problems,,,,,2021-04-01T00:00:00+01:00,"Active from 1 April 2020"

1 scheme_code scheme_service_name scheme_status scheme_confidential scheme_type scheme_registered_under_care_act scheme_owning_organisation_name scheme_support_services_provided_by scheme_primary_client_group scheme_has_other_client_group scheme_secondary_client_group scheme_support_type scheme_intended_stay scheme_created_at scheme_active_dates
2 {id1} Test name active Yes Housing for older people Yes – registered care home providing nursing care Yes MHCLG The same organisation that owns the housing stock People with alcohol problems Yes Older people with support needs High level Medium stay 2021-04-01T00:00:00+01:00 Active from 1 April 2020
3 {id2} Test name active Yes Housing for older people Yes – registered care home providing nursing care Yes MHCLG The same organisation that owns the housing stock People with alcohol problems Yes Older people with support needs High level Medium stay 2021-04-01T00:00:00+01:00 Active from 1 April 2020
4 {id3} Test name active Yes Housing for older people Yes – registered care home providing nursing care Yes MHCLG The same organisation that owns the housing stock People with alcohol problems Yes Older people with support needs High level Medium stay 2021-04-01T00:00:00+01:00 Active from 1 April 2020
5 {id4} Incomplete scheme incomplete Yes Housing for older people Yes – registered care home providing nursing care Yes MHCLG The same organisation that owns the housing stock People with alcohol problems 2021-04-01T00:00:00+01:00 Active from 1 April 2020
6 SWrong_id Incomplete scheme incomplete Yes Housing for older people Yes – registered care home providing nursing care Yes MHCLG The same organisation that owns the housing stock People with alcohol problems 2021-04-01T00:00:00+01:00 Active from 1 April 2020

4
spec/fixtures/files/updated_schemes.csv vendored

@ -1,6 +1,6 @@
scheme_code,scheme_service_name,scheme_status,scheme_confidential,scheme_type,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_support_services_provided_by,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,scheme_active_dates
{id1},Updated test name,incomplete,No,Direct Access Hostel,No,Different organisation,Another registered stock owner,People with drug problems,No,Older people with support needs,Low level,Permanent,2022-04-01T00:00:00+01:00,"Active from 2 April 2020"
{id2},Test name,active,Yes,Housing for older people,Yes – registered care home providing nursing care,MHCLG,The same organisation that owns the housing stock,People with alcohol problems,Yes,Older people with support needs,High level,Medium stay,2021-04-01T00:00:00+01:00,"Active from 1 April 2020"
{id3}, ,active,Yse,Direct access Hostel,Yes – registered care home providing nursing care,non existing org,wrong answer,FD,no,lder people with support needs,high,Permanent ,2021-04-01T00:00:00+01:00,"Active from 1 April 2020"
{id2},Test name,active,Yes,Housing for older people,Yes,MHCLG,The same organisation that owns the housing stock,People with alcohol problems,Yes,Older people with support needs,High level,Medium stay,2021-04-01T00:00:00+01:00,"Active from 1 April 2020"
{id3}, ,active,Yse,Direct access Hostel,Yes,non existing org,wrong answer,FD,no,lder people with support needs,high,Permanent ,2021-04-01T00:00:00+01:00,"Active from 1 April 2020"
Wrong_id,Incomplete scheme,incomplete,Yes,Housing for older people,No,MHCLG,The same organisation that owns the housing stock,People with alcohol problems,,,,,2021-04-01T00:00:00+01:00,"Active from 1 April 2020"
SWrong_id,Incomplete scheme,incomplete,Yes,Housing for older people,No,MHCLG,The same organisation that owns the housing stock,People with alcohol problems,,,,,2021-04-01T00:00:00+01:00,"Active from 1 April 2020"

1 scheme_code scheme_service_name scheme_status scheme_confidential scheme_type scheme_registered_under_care_act scheme_owning_organisation_name scheme_support_services_provided_by scheme_primary_client_group scheme_has_other_client_group scheme_secondary_client_group scheme_support_type scheme_intended_stay scheme_created_at scheme_active_dates
2 {id1} Updated test name incomplete No Direct Access Hostel No Different organisation Another registered stock owner People with drug problems No Older people with support needs Low level Permanent 2022-04-01T00:00:00+01:00 Active from 2 April 2020
3 {id2} Test name active Yes Housing for older people Yes – registered care home providing nursing care Yes MHCLG The same organisation that owns the housing stock People with alcohol problems Yes Older people with support needs High level Medium stay 2021-04-01T00:00:00+01:00 Active from 1 April 2020
4 {id3} active Yse Direct access Hostel Yes – registered care home providing nursing care Yes non existing org wrong answer FD no lder people with support needs high Permanent 2021-04-01T00:00:00+01:00 Active from 1 April 2020
5 Wrong_id Incomplete scheme incomplete Yes Housing for older people No MHCLG The same organisation that owns the housing stock People with alcohol problems 2021-04-01T00:00:00+01:00 Active from 1 April 2020
6 SWrong_id Incomplete scheme incomplete Yes Housing for older people No MHCLG The same organisation that owns the housing stock People with alcohol problems 2021-04-01T00:00:00+01:00 Active from 1 April 2020

6
spec/lib/tasks/update_schemes_and_locations_from_csv_spec.rb

@ -57,7 +57,7 @@ RSpec.describe "bulk_update" do
3,
service_name: "Test name",
sensitive: 1,
registered_under_care_act: 4,
registered_under_care_act: 5,
support_type: 4,
scheme_type: 7,
arrangement_type: "D",
@ -123,7 +123,7 @@ RSpec.describe "bulk_update" do
schemes[1].reload
expect(schemes[1].service_name).to eq("Test name")
expect(schemes[1].sensitive).to eq("Yes")
expect(schemes[1].registered_under_care_act).to eq("Yes – registered care home providing nursing care")
expect(schemes[1].registered_under_care_act).to eq("Yes")
expect(schemes[1].support_type).to eq("High level")
expect(schemes[1].scheme_type).to eq("Housing for older people")
expect(schemes[1].arrangement_type).to eq("The same organisation that owns the housing stock")
@ -141,7 +141,7 @@ RSpec.describe "bulk_update" do
schemes[2].reload
expect(schemes[2].service_name).to eq("Test name")
expect(schemes[2].sensitive).to eq("Yes")
expect(schemes[2].registered_under_care_act).to eq("Yes – registered care home providing nursing care")
expect(schemes[2].registered_under_care_act).to eq("Yes")
expect(schemes[2].support_type).to eq("High level")
expect(schemes[2].scheme_type).to eq("Housing for older people")
expect(schemes[2].arrangement_type).to eq("The same organisation that owns the housing stock")

Loading…
Cancel
Save