<%= f.govuk_error_summary %>
- <% secondary_client_group_selection = Scheme.secondary_client_groups.keys.excluding("Missing").map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %>
+ <% secondary_client_group_selection = Scheme.secondary_client_groups.keys.excluding("Missing").map { |key, _| OpenStruct.new(id: key, name: key) } %>
<%= f.govuk_collection_radio_buttons :secondary_client_group,
secondary_client_group_selection,
:id,
diff --git a/app/views/schemes/support.html.erb b/app/views/schemes/support.html.erb
index b4482bf66..dd2758cfd 100644
--- a/app/views/schemes/support.html.erb
+++ b/app/views/schemes/support.html.erb
@@ -14,19 +14,29 @@
<%= f.govuk_error_summary %>
- <% support_type_selection = Scheme.support_types.keys.excluding("Missing").map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %>
+ <% support_level_options_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." } %>
+
+ <% support_level_options_with_hints = Scheme.support_types.keys.excluding("Missing").map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize, description: support_level_options_hints[key.to_sym]) } %>
+
<%= f.govuk_collection_radio_buttons :support_type,
- support_type_selection,
- :id,
- :name,
- legend: { text: "Level of support given", size: "m" } %>
+ support_level_options_with_hints,
+ :id,
+ :name,
+ :description,
+ legend: { text: "Level of support given", size: "m" },
+ bold_labels: false %>
+
+ <% intended_length_of_stay_options_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." } %>
+
+ <% intended_length_of_stay_options_with_hints = Scheme.intended_stays.keys.excluding("Missing").map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize, description: intended_length_of_stay_options_hints[key.to_sym]) } %>
- <% 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" } %>
+ 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/app/views/schemes/support_services_provider.html.erb b/app/views/schemes/support_services_provider.html.erb
new file mode 100644
index 000000000..5a1dae620
--- /dev/null
+++ b/app/views/schemes/support_services_provider.html.erb
@@ -0,0 +1,36 @@
+<% content_for :title, "Which organisation provides the support services used by this scheme?" %>
+
+<% content_for :before_content do %>
+ <%= govuk_back_link(
+ text: "Back",
+ href: request.query_parameters["check_answers"] ? "/schemes/#{@scheme.id}/check-answers" : "/schemes/#{@scheme.id}/details",
+ ) %>
+<% end %>
+
+<%= render partial: "organisations/headings", locals: { main: "Which organisation provides the support services used by this scheme?", sub: nil } %>
+
+<%= form_for(@scheme, method: :patch) do |f| %>
+
+
+ <%= f.govuk_error_summary %>
+
+ <% null_option = [OpenStruct.new(id: "", name: "Select an option")] %>
+ <% organisations = Organisation.all.map { |org| OpenStruct.new(id: org.id, name: org.name) } %>
+ <% managing_org_answer_options = null_option + organisations %>
+
+ <%= f.govuk_collection_select :managing_organisation_id,
+ managing_org_answer_options,
+ :id,
+ :name,
+ label: { text: "Which organisation manages this scheme?", size: "m" },
+ options: { required: true },
+ "data-controller": %w[accessible-autocomplete conditional-filter] %>
+
+ <%= f.hidden_field :page, value: "support-services-provider" %>
+ <% if request.query_parameters["check_answers"] %>
+ <%= f.hidden_field :check_answers, value: "true" %>
+ <% end %>
+ <%= f.govuk_submit "Save and continue" %>
+
+
+<% end %>
diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb
index 2b3db667e..1965da4a2 100644
--- a/app/views/users/new.html.erb
+++ b/app/views/users/new.html.erb
@@ -15,7 +15,7 @@
<%= f.govuk_text_field :name,
autocomplete: "name",
- label: { text: "Name (optional)", size: "m" } %>
+ label: { text: "Location name (optional)", size: "m" } %>
<%= f.govuk_email_field :email,
label: { text: "Email address", size: "m" },
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 6b5ad6412..76709ba83 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -44,8 +44,35 @@ en:
scheme:
attributes:
owning_organisation_id:
- required: "Enter the existing organisation’s name"
invalid: "Enter the existing organisation’s name"
+ managing_organisation_id:
+ invalid: "Enter the existing organisation’s name"
+ service_name:
+ invalid: "Enter the scheme’s name"
+ scheme_type:
+ invalid: "Select the scheme’s type"
+ registered_under_care_act:
+ invalid: "Select if this scheme is registered under the Care Standards Act 2000"
+ primary_client_group:
+ invalid: "Select what client group is this scheme intended for"
+ secondary_client_group:
+ invalid: "Select what is the other client group"
+ support_type:
+ invalid: "Select level of support given"
+ intended_stay:
+ invalid: "Select intended length of stay"
+ has_other_client_group:
+ invalid: "Select if this scheme provides for another client group"
+ support_services_provider:
+ invalid: "Select who provides the support services used by this scheme"
+ support_services_provider_before_type_cast:
+ invalid: "Select who provides the support services used by this scheme"
+ location:
+ attributes:
+ units:
+ blank: "Enter total number of units at this location"
+ type_of_unit:
+ blank: "Select the most common type of unit at this location"
validations:
organisation:
diff --git a/config/routes.rb b/config/routes.rb
index de42be41a..dc6588142 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -43,6 +43,7 @@ Rails.application.routes.draw do
get "details", to: "schemes#details"
get "check-answers", to: "schemes#check_answers"
get "edit-name", to: "schemes#edit_name"
+ get "support-services-provider", to: "schemes#support_services_provider"
member do
resources :locations do
diff --git a/db/migrate/20220711134558_add_support_services_provider_to_schemes.rb b/db/migrate/20220711134558_add_support_services_provider_to_schemes.rb
new file mode 100644
index 000000000..e2c7de937
--- /dev/null
+++ b/db/migrate/20220711134558_add_support_services_provider_to_schemes.rb
@@ -0,0 +1,5 @@
+class AddSupportServicesProviderToSchemes < ActiveRecord::Migration[7.0]
+ def change
+ add_column :schemes, :support_services_provider, :integer
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 7654de950..096056489 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -257,7 +257,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_07_15_133937) do
create_table "logs_exports", force: :cascade do |t|
t.datetime "created_at", default: -> { "CURRENT_TIMESTAMP" }
- t.datetime "started_at", precision: nil, null: false
+ t.datetime "started_at", null: false
t.integer "base_number", default: 1, null: false
t.integer "increment_number", default: 1, null: false
t.boolean "empty_export", default: false, null: false
@@ -321,6 +321,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_07_15_133937) do
t.string "old_id"
t.integer "old_visible_id"
t.integer "total_units"
+ t.integer "support_services_provider"
t.index ["managing_organisation_id"], name: "index_schemes_on_managing_organisation_id"
t.index ["owning_organisation_id"], name: "index_schemes_on_owning_organisation_id"
end
diff --git a/db/seeds.rb b/db/seeds.rb
index 3ac0aa7d5..03a61cf59 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -73,8 +73,8 @@ unless Rails.env.test?
scheme1 = Scheme.create!(
service_name: "Beulahside Care",
sensitive: 0,
- registered_under_care_act: 0,
- support_type: 1,
+ registered_under_care_act: 1,
+ support_type: 2,
scheme_type: 4,
intended_stay: "M",
primary_client_group: "O",
@@ -87,7 +87,7 @@ unless Rails.env.test?
service_name: "Abdullahview Point",
sensitive: 0,
registered_under_care_act: 1,
- support_type: 1,
+ support_type: 2,
scheme_type: 5,
intended_stay: "S",
primary_client_group: "D",
@@ -115,9 +115,9 @@ unless Rails.env.test?
postcode: "CU193AA",
name: "Rectory Road",
type_of_unit: 4,
+ units: 1,
type_of_building: "Purpose built",
- county: "Mid Sussex",
- wheelchair_adaptation: 0,
+ wheelchair_adaptation: 2,
)
Location.create!(
@@ -126,8 +126,8 @@ unless Rails.env.test?
postcode: "DM250DC",
name: "Smithy Lane",
type_of_unit: 1,
+ units: 1,
type_of_building: "Converted from previous residential or non-residential property",
- county: "Fife",
wheelchair_adaptation: 1,
)
@@ -137,8 +137,8 @@ unless Rails.env.test?
postcode: "YX130WP",
name: "Smithy Lane",
type_of_unit: 2,
+ units: 1,
type_of_building: "Converted from previous residential or non-residential property",
- county: "Rochford",
wheelchair_adaptation: 1,
)
end
diff --git a/spec/factories/location.rb b/spec/factories/location.rb
index daef3d2ce..934f6d1be 100644
--- a/spec/factories/location.rb
+++ b/spec/factories/location.rb
@@ -3,6 +3,7 @@ FactoryBot.define do
postcode { Faker::Address.postcode.delete(" ") }
name { Faker::Address.street_name }
type_of_unit { [1, 2, 3, 4, 6, 7].sample }
+ units { [1, 2, 3, 4, 6, 7].sample }
type_of_building { "Purpose built" }
mobility_type { %w[A M N W X].sample }
wheelchair_adaptation { 2 }
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 9230ab143..049916ce5 100644
--- a/spec/features/schemes_spec.rb
+++ b/spec/features/schemes_spec.rb
@@ -240,9 +240,9 @@ RSpec.describe "Schemes scheme Features" do
expect(page).to have_content "Scheme name"
expect(page).to have_content "This scheme contains confidential information"
expect(page).to have_content "Which organisation owns the housing stock for this scheme?"
- expect(page).to have_content "Which organisation manages this scheme?"
expect(page).to have_content "What is this type of scheme?"
expect(page).to have_content "Is this scheme registered under the Care Standards Act 2000?"
+ expect(page).to have_content "Who provides the support services used by this scheme?"
end
context "when I fill in scheme details and I press save I see primary client group section" do
@@ -253,8 +253,8 @@ RSpec.describe "Schemes scheme Features" do
check "This scheme contains confidential information"
choose "Direct access hostel"
choose "Yes – registered care home providing nursing care"
- select organisation.name, from: "scheme-managing-organisation-id-field"
select organisation.name, from: "scheme-owning-organisation-id-field"
+ choose "The same organisation that owns the housing stock"
click_button "Save and continue"
end
@@ -271,8 +271,8 @@ RSpec.describe "Schemes scheme Features" do
expect(page).to have_current_path("/schemes/#{scheme.id}/details")
expect(page).to have_content "Scheme name"
expect(page).to have_content "This scheme contains confidential information"
- expect(page).to have_content "Which organisation manages this scheme"
expect(page).to have_content "What is this type of scheme?"
+ expect(page).to have_content "Who provides the support services used by this scheme?"
expect(page).to have_content "Is this scheme registered under the Care Standards Act 2000?"
end
@@ -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
@@ -479,7 +479,7 @@ RSpec.describe "Schemes scheme Features" do
context "when changing answers" do
it "displays change links" do
- assert_selector "a", text: "Change", count: 12
+ assert_selector "a", text: "Change", count: 13
end
context "when changing details" do
@@ -491,13 +491,10 @@ RSpec.describe "Schemes scheme Features" do
expect(page).to have_current_path("/schemes/#{scheme.id}/details?check_answers=true")
fill_in "Scheme name", with: "Example"
- choose "Direct access hostel"
- choose "Yes – registered care home providing nursing care"
click_button "Save and continue"
expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers")
expect(page).to have_content "Example"
- expect(page).to have_content "Yes – registered care home providing nursing care"
end
context "when I press the back button" do
@@ -511,150 +508,317 @@ RSpec.describe "Schemes scheme Features" do
end
end
end
+ end
- context "when changing primary client group" do
- before do
- click_link("Change", href: "/schemes/#{scheme.id}/primary-client-group?check_answers=true")
- end
+ context "and I select to create a scheme" do
+ before do
+ click_link "Create scheme"
+ end
- it "allows changing primary-client-group question" do
- expect(page).to have_current_path("/schemes/#{scheme.id}/primary-client-group?check_answers=true")
+ it "adds scheme to the list of schemes" do
+ expect(page).to have_content "Supported housing schemes"
+ expect(page).to have_content scheme.id_to_display
+ expect(page).to have_content scheme.service_name
+ expect(page).to have_content scheme.owning_organisation.name
+ expect(page).to have_content "#{scheme.owning_organisation.name} has been created."
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
- choose "Older people with support needs"
- click_button "Save and continue"
+ context "when I fill in scheme details indicating that supported services provided by a different organisation and I press save I see primary client group section" do
+ let(:scheme) { Scheme.first }
+ let!(:another_organisation) { FactoryBot.create(:organisation, name: "Another Org") }
- expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers")
- expect(page).to have_content "Older people with support needs"
- end
+ before do
+ fill_in "Scheme name", with: "FooBar"
+ check "This scheme contains confidential information"
+ choose "Direct access hostel"
+ choose "Yes – registered care home providing nursing care"
+ select organisation.name, from: "scheme-owning-organisation-id-field"
+ choose "Another registered housing provider"
+ click_button "Save and continue"
+ end
- context "when I press the back button" do
- before do
- click_link "Back"
- end
+ it "lets me fill in the managing organisation details" do
+ expect(page).to have_content "Which organisation provides the support services used by this scheme?"
+ end
- it "lets me select the support answers" do
- expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers")
- expect(page).to have_content "Check your changes before creating this scheme"
- end
- end
- end
+ context "when I press the back button" do
+ before do
+ click_link "Back"
+ end
- context "when changing confirm secondary group answer" do
- before do
- click_link("Change", href: "/schemes/#{scheme.id}/confirm-secondary-client-group?check_answers=true")
- end
+ it "lets me fill in the scheme details" do
+ expect(page).to have_current_path("/schemes/#{scheme.id}/details")
+ expect(page).to have_content "Scheme name"
+ expect(page).to have_content "This scheme contains confidential information"
+ expect(page).to have_content "What is this type of scheme?"
+ expect(page).to have_content "Who provides the support services used by this scheme?"
+ expect(page).to have_content "Is this scheme registered under the Care Standards Act 2000?"
+ end
- it "allows changing confirm-secondary-client-group question to yes" do
- expect(page).to have_current_path("/schemes/#{scheme.id}/confirm-secondary-client-group?check_answers=true")
+ context "when we amend scheme details" do
+ it "returns to the primary client group question" do
+ click_button "Save and continue"
+ expect(page).to have_current_path("/schemes/#{scheme.id}/support-services-provider")
+ end
+ end
+ end
- choose "Yes"
- click_button "Save and continue"
+ context "when I select organisation providing support for scheme" do
+ before do
+ select another_organisation.name, from: "scheme-managing-organisation-id-field"
+ click_button "Save and continue"
+ end
- expect(page).to have_current_path("/schemes/#{scheme.id}/secondary-client-group?check_answers=true")
+ it "lets me select the primary client group" do
+ expect(page).to have_content "What client group is this scheme intended for?"
+ end
- choose "People at risk of domestic violence"
- click_button "Save and continue"
+ context "when I select primary client group details" do
+ before do
+ choose "Homeless families with support needs"
+ click_button "Save and continue"
+ end
- expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers")
- expect(page).to have_content "People at risk of domestic violence"
- end
+ it "lets me confirm if I want to select secondary group details" do
+ expect(page).to have_content "Does this scheme provide for another client group?"
+ end
- context "when I press the back button" do
- before do
- click_link "Back"
- end
+ context "when I press the back button" do
+ before do
+ click_link "Back"
+ end
- it "lets me select the support answers" do
- expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers")
- expect(page).to have_content "Check your changes before creating this scheme"
- end
- end
+ it "lets me select the primary client group" do
+ expect(page).to have_current_path("/schemes/#{scheme.id}/primary-client-group")
+ expect(page).to have_content "What client group is this scheme intended for?"
+ end
+
+ context "when we amend primary client group" do
+ it "returns to the confirm secondary client group question" do
+ click_button "Save and continue"
+ expect(page).to have_current_path("/schemes/#{scheme.id}/confirm-secondary-client-group")
+ end
+ end
+ end
+
+ context "when I confirm the secondary group" do
+ before do
+ choose "Yes"
+ click_button "Save and continue"
+ end
+
+ it "lets me select secondary client group" do
+ expect(page).to have_content "What is the other client group?"
+ end
+
+ context "when I press the back button" do
+ before do
+ click_link "Back"
+ end
+
+ it "lets me confirm the secondary group" do
+ expect(page).to have_current_path("/schemes/#{scheme.id}/confirm-secondary-client-group")
+ expect(page).to have_content "Does this scheme provide for another client group?"
+ end
+
+ context "when we amend confirm secondary client" do
+ it "returns to the secondary client group question" do
+ click_button "Save and continue"
+ expect(page).to have_current_path("/schemes/#{scheme.id}/secondary-client-group")
+ end
+ end
+ end
+
+ context "when I select the secondary group" do
+ before do
+ choose "Homeless families with support needs"
+ click_button "Save and continue"
+ end
+
+ it "lets me select level of support" do
+ expect(page).to have_content "What support does this scheme provide?"
+ end
+
+ context "when I press the back button" do
+ before do
+ click_link "Back"
+ end
+
+ it "lets me select the secondary group" do
+ expect(page).to have_current_path("/schemes/#{scheme.id}/secondary-client-group")
+ expect(page).to have_content "What is the other client group?"
+ end
+
+ context "when we amend secondary client" do
+ it "returns to the support question" do
+ click_button "Save and continue"
+ expect(page).to have_current_path("/schemes/#{scheme.id}/support")
end
+ end
+ end
- context "when allows changing confirm-secondary-client-group question to no" do
- before do
- click_link("Change", href: "/schemes/#{scheme.id}/confirm-secondary-client-group?check_answers=true")
- end
+ context "when I select the support answers" do
+ before do
+ choose "Low level"
+ choose "Very short stay"
+ click_button "Save and continue"
+ end
- it "allows changing confirm-secondary-client-group question to no" do
- expect(page).to have_current_path("/schemes/#{scheme.id}/confirm-secondary-client-group?check_answers=true")
+ it "lets me add location" do
+ expect(page).to have_content "Add a location to this scheme"
+ end
- choose "No"
- click_button "Save and continue"
+ context "when I press the back button" do
+ before do
+ click_link "Back"
+ end
- expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers")
- expect(page).not_to have_content "Secondary client group"
+ it "lets me select the secondary group" do
+ expect(page).to have_current_path("/schemes/#{scheme.id}/support")
+ expect(page).to have_content "What support does this scheme provide?"
+ end
+
+ context "when I amend support" do
+ it "returns to the add location page" do
+ click_button "Save and continue"
+ expect(page).to have_current_path("/schemes/#{scheme.id}/locations/new")
end
end
+ end
- context "when changing secondary-client-group question" do
+ context "when I add location to the scheme" do
+ before do
+ fill_in "Postcode", with: "SW1P 4DF"
+ fill_in "Location name (optional)", with: "Some name"
+ fill_in "Total number of units at this location", with: 1
+ choose "Self-contained house"
+ choose "location-wheelchair-adaptation-no-field"
+ choose "location-add-another-location-no-field"
+ click_button "Save and continue"
+ end
+
+ it "lets me check my answers" do
+ expect(page).to have_content "Check your changes before creating this scheme"
+ end
+
+ context "when I select to view locations" do
before do
- click_link("Change", href: "/schemes/#{scheme.id}/secondary-client-group?check_answers=true")
+ click_link "Locations"
end
- it "allows changing secondary-client-group question" do
- expect(page).to have_current_path("/schemes/#{scheme.id}/secondary-client-group?check_answers=true")
+ it "displays information about locations" do
+ expect(page).to have_content "Locations"
+ expect(page).to have_content "#{scheme.locations.count} location"
+ end
- choose "People at risk of domestic violence"
+ it "displays information about newly created location" do
+ expect(page).to have_content "SW1P4DF"
+ expect(page).to have_content "Some name"
+ expect(page).to have_content "Self-contained house"
+ end
+ end
+
+ context "and I select to add another location a scheme" do
+ before do
+ click_link "Add a location"
+ fill_in "Postcode", with: "XX1 1XX"
+ fill_in "Location name (optional)", with: "Other name"
+ fill_in "Total number of units at this location", with: 2
+ choose "Self-contained house"
+ choose "location-wheelchair-adaptation-no-field"
+ choose "location-add-another-location-no-field"
click_button "Save and continue"
+ end
- expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers")
- expect(page).to have_content "People at risk of domestic violence"
+ it "lets me check my answers" do
+ expect(page).to have_content "Check your changes before creating this scheme"
end
- context "when I press the back button" do
+ context "when I select to view locations" do
before do
- click_link "Back"
+ click_link "Locations"
end
- it "lets me select the support answers" do
- expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers")
- expect(page).to have_content "Check your changes before creating this scheme"
+ it "displays information about another location" do
+ expect(page).to have_content "Locations"
+ expect(page).to have_content "#{scheme.locations.count} location"
+ end
+
+ it "displays information about newly created location" do
+ expect(page).to have_content "XX11XX"
+ expect(page).to have_content "Other name"
+ expect(page).to have_content "Self-contained house"
+ end
+
+ context "when changing location details" do
+ before do
+ click_link "XX11XX"
+ fill_in "Postcode", with: "ZZ1 1ZZ"
+ click_button "Save and continue"
+ end
+
+ it "displays changed location" do
+ expect(page).to have_content "Locations"
+ expect(page).to have_content "#{scheme.locations.count} location"
+ expect(page).to have_content "ZZ11ZZ"
+ end
end
end
end
- context "when changing support questions" do
- before do
- click_link("Change", href: "/schemes/#{scheme.id}/support?check_answers=true", match: :first)
+ context "when changing answers" do
+ it "displays change links" do
+ assert_selector "a", text: "Change", count: 13
end
- it "allows changing support questions" do
- expect(page).to have_current_path("/schemes/#{scheme.id}/support?check_answers=true")
+ context "when changing details" do
+ before do
+ click_link("Change", href: "/schemes/#{scheme.id}/details?check_answers=true", match: :first)
+ end
- choose "Resettlement support"
- choose "Medium stay"
- click_button "Save and continue"
+ it "allows changing details questions" do
+ expect(page).to have_current_path("/schemes/#{scheme.id}/details?check_answers=true")
- expect(page).to have_current_path("/schemes/#{scheme.id}/locations/new")
- expect(page).to have_content "Add a location to this scheme"
- end
+ fill_in "Scheme name", with: "Example"
+ click_button "Save and continue"
- context "when I press the back button" do
- before do
- click_link "Back"
+ expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers")
+ expect(page).to have_content "Example"
end
- it "lets me select the support answers" do
- expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers")
- expect(page).to have_content "Check your changes before creating this scheme"
+ context "when I press the back button" do
+ before do
+ click_link "Back"
+ end
+
+ it "lets me select the support answers" do
+ expect(page).to have_current_path("/schemes/#{scheme.id}/check-answers")
+ expect(page).to have_content "Check your changes before creating this scheme"
+ end
end
end
end
- end
- context "and I select to create a scheme" do
- before do
- click_link "Create scheme"
- end
+ context "and I select to create a scheme" do
+ before do
+ click_link "Create scheme"
+ end
- it "adds scheme to the list of schemes" do
- expect(page).to have_content "Supported housing schemes"
- expect(page).to have_content scheme.id_to_display
- expect(page).to have_content scheme.service_name
- expect(page).to have_content scheme.owning_organisation.name
- expect(page).to have_content scheme.managing_organisation.name
- expect(page).to have_content "#{scheme.owning_organisation.name} has been created."
+ it "adds scheme to the list of schemes" do
+ expect(page).to have_content "Supported housing schemes"
+ expect(page).to have_content scheme.id_to_display
+ expect(page).to have_content scheme.service_name
+ expect(page).to have_content scheme.owning_organisation.name
+ expect(page).to have_content scheme.managing_organisation.name
+ expect(page).to have_content "#{scheme.owning_organisation.name} has been created."
+ end
end
end
end
diff --git a/spec/models/location_spec.rb b/spec/models/location_spec.rb
index ae78df6c5..e5feaec24 100644
--- a/spec/models/location_spec.rb
+++ b/spec/models/location_spec.rb
@@ -35,4 +35,24 @@ RSpec.describe Location, type: :model do
.to raise_error(ActiveRecord::RecordInvalid, "Validation failed: Postcode Enter a postcode in the correct format, for example AA1 1AA")
end
end
+
+ describe "#units" do
+ let(:location) { FactoryBot.build(:location) }
+
+ it "does add an error when the postcode is invalid" do
+ location.units = nil
+ expect { location.save! }
+ .to raise_error(ActiveRecord::RecordInvalid, "Validation failed: Units Enter total number of units at this location")
+ end
+ end
+
+ describe "#type_of_unit" do
+ let(:location) { FactoryBot.build(:location) }
+
+ it "does add an error when the postcode is invalid" do
+ location.type_of_unit = nil
+ expect { location.save! }
+ .to raise_error(ActiveRecord::RecordInvalid, "Validation failed: Type of unit Select the most common type of unit at this location")
+ end
+ end
end
diff --git a/spec/requests/locations_controller_spec.rb b/spec/requests/locations_controller_spec.rb
index 0f770ddb3..2148f350d 100644
--- a/spec/requests/locations_controller_spec.rb
+++ b/spec/requests/locations_controller_spec.rb
@@ -133,15 +133,6 @@ RSpec.describe LocationsController, type: :request do
end
end
- context "when required postcode param is missing" do
- let(:params) { { location: { name: "Test", units: "5", type_of_unit: "Bungalow", wheelchair_adaptation: "No", add_another_location: "No" } } }
-
- it "displays the new page with an error message" do
- expect(response).to have_http_status(:unprocessable_entity)
- expect(page).to have_content(I18n.t("validations.postcode"))
- end
- end
-
context "when do you want to add another location is selected as yes" do
let(:params) { { location: { name: "Test", units: "5", type_of_unit: "Bungalow", wheelchair_adaptation: "No", add_another_location: "Yes", postcode: "ZZ1 1ZZ" } } }
@@ -198,6 +189,17 @@ RSpec.describe LocationsController, type: :request do
expect(Location.last.wheelchair_adaptation).to eq("No")
end
end
+
+ context "when required param are missing" do
+ let(:params) { { location: { postcode: "", name: "Test", units: "", type_of_unit: "", wheelchair_adaptation: "No", add_another_location: "No" } } }
+
+ it "displays the new page with an error message" do
+ expect(response).to have_http_status(:unprocessable_entity)
+ expect(page).to have_content(I18n.t("validations.postcode"))
+ expect(page).to have_content(I18n.t("activerecord.errors.models.location.attributes.units.blank"))
+ expect(page).to have_content(I18n.t("activerecord.errors.models.location.attributes.type_of_unit.blank"))
+ end
+ end
end
context "when signed in as a support user" do
@@ -297,6 +299,17 @@ RSpec.describe LocationsController, type: :request do
expect(Location.last.wheelchair_adaptation).to eq("No")
end
end
+
+ context "when required param are missing" do
+ let(:params) { { location: { postcode: "", name: "Test", units: "", type_of_unit: "", wheelchair_adaptation: "No", add_another_location: "No" } } }
+
+ it "displays the new page with an error message" do
+ expect(response).to have_http_status(:unprocessable_entity)
+ expect(page).to have_content(I18n.t("validations.postcode"))
+ expect(page).to have_content(I18n.t("activerecord.errors.models.location.attributes.units.blank"))
+ expect(page).to have_content(I18n.t("activerecord.errors.models.location.attributes.type_of_unit.blank"))
+ end
+ end
end
end
@@ -511,6 +524,17 @@ RSpec.describe LocationsController, type: :request do
expect(Location.last.wheelchair_adaptation).to eq("No")
end
end
+
+ context "when required param are missing" do
+ let(:params) { { location: { postcode: "", name: "Test", units: "", type_of_unit: "", wheelchair_adaptation: "No", add_another_location: "No" } } }
+
+ it "displays the new page with an error message" do
+ expect(response).to have_http_status(:unprocessable_entity)
+ expect(page).to have_content(I18n.t("validations.postcode"))
+ expect(page).to have_content(I18n.t("activerecord.errors.models.location.attributes.units.blank"))
+ expect(page).to have_content(I18n.t("activerecord.errors.models.location.attributes.type_of_unit.blank"))
+ end
+ end
end
context "when signed in as a support user" do
@@ -620,6 +644,17 @@ RSpec.describe LocationsController, type: :request do
expect(Location.last.wheelchair_adaptation).to eq("No")
end
end
+
+ context "when required param are missing" do
+ let(:params) { { location: { postcode: "", name: "Test", units: "", type_of_unit: "", wheelchair_adaptation: "No", add_another_location: "No" } } }
+
+ it "displays the new page with an error message" do
+ expect(response).to have_http_status(:unprocessable_entity)
+ expect(page).to have_content(I18n.t("validations.postcode"))
+ expect(page).to have_content(I18n.t("activerecord.errors.models.location.attributes.units.blank"))
+ expect(page).to have_content(I18n.t("activerecord.errors.models.location.attributes.type_of_unit.blank"))
+ end
+ end
end
end
diff --git a/spec/requests/schemes_controller_spec.rb b/spec/requests/schemes_controller_spec.rb
index 2d92c7385..a2dc3e584 100644
--- a/spec/requests/schemes_controller_spec.rb
+++ b/spec/requests/schemes_controller_spec.rb
@@ -336,7 +336,13 @@ RSpec.describe SchemesController, type: :request do
context "when signed in as a data coordinator" do
let(:user) { FactoryBot.create(:user, :data_coordinator) }
- let(:params) { { scheme: { service_name: "testy", sensitive: "1", scheme_type: "Foyer", registered_under_care_act: "No" } } }
+ let(:params) do
+ { scheme: { service_name: "testy",
+ sensitive: "1",
+ scheme_type: "Foyer",
+ registered_under_care_act: "No",
+ support_services_provider_before_type_cast: "0" } }
+ end
before do
sign_in user
@@ -344,6 +350,7 @@ RSpec.describe SchemesController, type: :request do
it "creates a new scheme for user organisation with valid params and renders correct page" do
expect { post "/schemes", params: }.to change(Scheme, :count).by(1)
+ follow_redirect!
expect(response).to have_http_status(:ok)
expect(page).to have_content("What client group is this scheme intended for?")
end
@@ -364,12 +371,72 @@ RSpec.describe SchemesController, type: :request do
expect(Scheme.last.intended_stay).to eq(nil)
expect(Scheme.last.id_to_display).to match(/S*/)
end
+
+ context "when support services provider is selected" do
+ let(:params) do
+ { scheme: { service_name: "testy",
+ sensitive: "1",
+ scheme_type: "Foyer",
+ registered_under_care_act: "No",
+ support_services_provider_before_type_cast: "1" } }
+ end
+
+ it "creates a new scheme for user organisation with valid params and renders correct page" do
+ expect { post "/schemes", params: }.to change(Scheme, :count).by(1)
+ follow_redirect!
+ expect(response).to have_http_status(:ok)
+ expect(page).to have_content("Which organisation provides the support services used by this scheme?")
+ end
+
+ it "creates a new scheme for user organisation with valid params" do
+ post "/schemes", params: params
+
+ expect(Scheme.last.owning_organisation_id).to eq(user.organisation_id)
+ expect(Scheme.last.service_name).to eq("testy")
+ expect(Scheme.last.scheme_type).to eq("Foyer")
+ expect(Scheme.last.sensitive).to eq("Yes")
+ expect(Scheme.last.registered_under_care_act).to eq("No")
+ expect(Scheme.last.id).not_to eq(nil)
+ expect(Scheme.last.has_other_client_group).to eq(nil)
+ expect(Scheme.last.primary_client_group).to eq(nil)
+ expect(Scheme.last.secondary_client_group).to eq(nil)
+ expect(Scheme.last.support_type).to eq(nil)
+ expect(Scheme.last.intended_stay).to eq(nil)
+ expect(Scheme.last.id_to_display).to match(/S*/)
+ end
+ end
+
+ context "when missing required scheme params" do
+ let(:params) do
+ { scheme: { service_name: "",
+ scheme_type: "",
+ registered_under_care_act: "",
+ support_services_provider_before_type_cast: "" } }
+ end
+
+ it "renders the same page with error message" do
+ post "/schemes", params: params
+ expect(response).to have_http_status(:unprocessable_entity)
+ expect(page).to have_content("Create a new supported housing scheme")
+ expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.scheme_type.invalid"))
+ expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.registered_under_care_act.invalid"))
+ expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.support_services_provider.invalid"))
+ expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.service_name.invalid"))
+ end
+ end
end
context "when signed in as a support user" do
let(:organisation) { FactoryBot.create(:organisation) }
let(:user) { FactoryBot.create(:user, :support) }
- let(:params) { { scheme: { service_name: "testy", sensitive: "1", scheme_type: "Foyer", registered_under_care_act: "No", owning_organisation_id: organisation.id } } }
+ let(:params) do
+ { scheme: { service_name: "testy",
+ sensitive: "1",
+ scheme_type: "Foyer",
+ registered_under_care_act: "No",
+ owning_organisation_id: organisation.id,
+ support_services_provider_before_type_cast: "0" } }
+ end
before do
allow(user).to receive(:need_two_factor_authentication?).and_return(false)
@@ -378,6 +445,7 @@ RSpec.describe SchemesController, type: :request do
it "creates a new scheme for user organisation with valid params and renders correct page" do
expect { post "/schemes", params: }.to change(Scheme, :count).by(1)
+ follow_redirect!
expect(response).to have_http_status(:ok)
expect(page).to have_content("What client group is this scheme intended for?")
end
@@ -399,13 +467,67 @@ RSpec.describe SchemesController, type: :request do
expect(Scheme.last.id_to_display).to match(/S*/)
end
+ context "when support services provider is selected" do
+ let(:params) do
+ { scheme: { service_name: "testy",
+ sensitive: "1",
+ scheme_type: "Foyer",
+ registered_under_care_act: "No",
+ owning_organisation_id: organisation.id,
+ support_services_provider_before_type_cast: "1" } }
+ end
+
+ it "creates a new scheme for user organisation with valid params and renders correct page" do
+ expect { post "/schemes", params: }.to change(Scheme, :count).by(1)
+ follow_redirect!
+ expect(response).to have_http_status(:ok)
+ expect(page).to have_content("Which organisation provides the support services used by this scheme?")
+ end
+
+ it "creates a new scheme for user organisation with valid params" do
+ post "/schemes", params: params
+ expect(Scheme.last.owning_organisation_id).to eq(organisation.id)
+ expect(Scheme.last.service_name).to eq("testy")
+ expect(Scheme.last.scheme_type).to eq("Foyer")
+ expect(Scheme.last.sensitive).to eq("Yes")
+ expect(Scheme.last.registered_under_care_act).to eq("No")
+ expect(Scheme.last.id).not_to eq(nil)
+ expect(Scheme.last.has_other_client_group).to eq(nil)
+ expect(Scheme.last.primary_client_group).to eq(nil)
+ expect(Scheme.last.secondary_client_group).to eq(nil)
+ expect(Scheme.last.support_type).to eq(nil)
+ expect(Scheme.last.intended_stay).to eq(nil)
+ expect(Scheme.last.id_to_display).to match(/S*/)
+ end
+ end
+
+ context "when missing required scheme params" do
+ let(:params) do
+ { scheme: { service_name: "",
+ scheme_type: "",
+ registered_under_care_act: "",
+ support_services_provider_before_type_cast: "" } }
+ end
+
+ it "renders the same page with error message" do
+ post "/schemes", params: params
+ expect(response).to have_http_status(:unprocessable_entity)
+ expect(page).to have_content("Create a new supported housing scheme")
+ expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.scheme_type.invalid"))
+ expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.registered_under_care_act.invalid"))
+ expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.support_services_provider.invalid"))
+ expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.service_name.invalid"))
+ expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.owning_organisation_id.invalid"))
+ end
+ end
+
context "when required organisation id param is missing" do
let(:params) { { "scheme" => { "service_name" => "qweqwer", "sensitive" => "Yes", "owning_organisation_id" => "", "scheme_type" => "Foyer", "registered_under_care_act" => "Yes – part registered as a care home" } } }
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
@@ -442,6 +564,84 @@ RSpec.describe SchemesController, type: :request do
patch "/schemes/#{scheme_to_update.id}", params:
end
+ context "when params are missing" do
+ let(:params) do
+ { scheme: {
+ service_name: "",
+ managing_organisation_id: "",
+ owning_organisation_id: "",
+ primary_client_group: "",
+ secondary_client_group: "",
+ scheme_type: "",
+ registered_under_care_act: "",
+ support_type: "",
+ intended_stay: "",
+ support_services_provider_before_type_cast: "",
+ has_other_client_group: "",
+ page: "details",
+ } }
+ end
+
+ it "renders primary client group after successful update" do
+ expect(response).to have_http_status(:unprocessable_entity)
+ expect(page).to have_content("Create a new supported housing scheme")
+ expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.service_name.invalid"))
+ expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.scheme_type.invalid"))
+ expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.registered_under_care_act.invalid"))
+ expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.primary_client_group.invalid"))
+ expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.secondary_client_group.invalid"))
+ expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.support_type.invalid"))
+ expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.intended_stay.invalid"))
+ expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.has_other_client_group.invalid"))
+ expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.support_services_provider_before_type_cast.invalid"))
+ 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" } } }
+
+ it "renders check answers page after successful update" do
+ follow_redirect!
+ expect(response).to have_http_status(:ok)
+ expect(page).to have_content("Check your changes before creating this scheme")
+ end
+
+ it "updates a scheme with valid params" do
+ follow_redirect!
+ expect(scheme_to_update.reload.primary_client_group).to eq("Homeless families with support needs")
+ end
+ end
+ end
+
+ context "when updating support services provider" do
+ let(:params) { { scheme: { managing_organisation_id: organisation.id, page: "support-services-provider" } } }
+
+ it "renders primary client group after successful update" do
+ follow_redirect!
+ expect(response).to have_http_status(:ok)
+ expect(page).to have_content("What client group is this scheme intended for?")
+ 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" } } }
+
+ it "renders check answers page after successful update" do
+ follow_redirect!
+ expect(response).to have_http_status(:ok)
+ expect(page).to have_content("Check your changes before creating this scheme")
+ end
+
+ it "updates a scheme with valid params" do
+ follow_redirect!
+ expect(scheme_to_update.reload.primary_client_group).to eq("Homeless families with support needs")
+ end
+ end
+ end
+
context "when updating primary client group" do
let(:params) { { scheme: { primary_client_group: "Homeless families with support needs", page: "primary-client-group" } } }
@@ -548,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!
@@ -559,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!
@@ -574,13 +774,21 @@ 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
context "when updating details" do
- let(:params) { { scheme: { service_name: "testy", sensitive: "1", scheme_type: "Foyer", registered_under_care_act: "No", page: "details" } } }
+ let(:params) do
+ { scheme: { service_name: "testy",
+ sensitive: "1",
+ scheme_type: "Foyer",
+ registered_under_care_act: "No",
+ page: "details",
+ owning_organisation_id: organisation.id,
+ support_services_provider_before_type_cast: "0" } }
+ end
it "renders confirm secondary group after successful update" do
follow_redirect!
@@ -642,6 +850,55 @@ RSpec.describe SchemesController, type: :request do
patch "/schemes/#{scheme_to_update.id}", params:
end
+ context "when params are missing" do
+ let(:params) do
+ { scheme: {
+ service_name: "",
+ managing_organisation_id: "",
+ owning_organisation_id: "",
+ primary_client_group: "",
+ secondary_client_group: "",
+ scheme_type: "",
+ registered_under_care_act: "",
+ support_type: "",
+ intended_stay: "",
+ support_services_provider_before_type_cast: "",
+ has_other_client_group: "",
+ page: "details",
+ } }
+ end
+
+ it "renders primary client group after successful update" do
+ expect(response).to have_http_status(:unprocessable_entity)
+ expect(page).to have_content("Create a new supported housing scheme")
+ expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.owning_organisation_id.invalid"))
+ expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.service_name.invalid"))
+ expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.scheme_type.invalid"))
+ expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.registered_under_care_act.invalid"))
+ expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.primary_client_group.invalid"))
+ expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.secondary_client_group.invalid"))
+ expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.support_type.invalid"))
+ expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.intended_stay.invalid"))
+ expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.has_other_client_group.invalid"))
+ expect(page).to have_content(I18n.t("activerecord.errors.models.scheme.attributes.support_services_provider_before_type_cast.invalid"))
+ 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" } } }
+
+ it "renders check answers page after successful update" do
+ follow_redirect!
+ expect(response).to have_http_status(:ok)
+ expect(page).to have_content("Check your changes before creating this scheme")
+ end
+
+ it "updates a scheme with valid params" do
+ follow_redirect!
+ expect(scheme_to_update.reload.primary_client_group).to eq("Homeless families with support needs")
+ end
+ end
+ end
+
context "when updating primary client group" do
let(:params) { { scheme: { primary_client_group: "Homeless families with support needs", page: "primary-client-group" } } }
@@ -748,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!
@@ -759,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!
@@ -774,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
@@ -787,8 +1044,8 @@ RSpec.describe SchemesController, type: :request do
scheme_type: "Foyer",
registered_under_care_act: "No",
page: "details",
- owning_organisation_id: another_organisation.id,
- managing_organisation_id: another_organisation.id } }
+ support_services_provider_before_type_cast: "0",
+ owning_organisation_id: another_organisation.id } }
end
it "renders confirm secondary group after successful update" do
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