diff --git a/app/models/location.rb b/app/models/location.rb index f8139a84c..a9ffb9147 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -1,6 +1,6 @@ class Location < ApplicationRecord validate :validate_postcode - validates :units, :type_of_unit, :wheelchair_adaptation, presence: true + validates :units, :type_of_unit, presence: true belongs_to :scheme attr_accessor :add_another_location diff --git a/app/views/locations/edit.html.erb b/app/views/locations/edit.html.erb index 9227b3efb..8b38fa1fb 100644 --- a/app/views/locations/edit.html.erb +++ b/app/views/locations/edit.html.erb @@ -42,7 +42,7 @@ :id, :name, 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?", size: "m" } %> + legend: { text: "Are the majority of units in this location built or adapted to wheelchair-user standards? (optional)", size: "m" } %> <%= govuk_section_break(visible: true, size: "m") %> diff --git a/app/views/locations/new.html.erb b/app/views/locations/new.html.erb index 88624d00d..e0bef95df 100644 --- a/app/views/locations/new.html.erb +++ b/app/views/locations/new.html.erb @@ -44,7 +44,7 @@ :id, :name, 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?", size: "m" } %> + legend: { text: "Are the majority of units in this location built or adapted to wheelchair-user standards? (optional)", size: "m" } %> <%= govuk_section_break(visible: true, size: "m") %> diff --git a/spec/requests/schemes_controller_spec.rb b/spec/requests/schemes_controller_spec.rb index 5071874bb..974a5859a 100644 --- a/spec/requests/schemes_controller_spec.rb +++ b/spec/requests/schemes_controller_spec.rb @@ -371,6 +371,25 @@ 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 "missing required scheme params" do + let(:params) do + { scheme: { service_name: "", + scheme_type: "", + registered_under_care_act: "", + support_services_provider: "" } } + 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("Select the scheme’s type") + expect(page).to have_content("Select if this scheme is registered under the Care Standards Act 2000") + expect(page).to have_content("Select who provides the support services used by this scheme") + expect(page).to have_content("Enter the scheme’s name") + end + end end context "when signed in as a support user" do @@ -414,6 +433,26 @@ RSpec.describe SchemesController, type: :request do expect(Scheme.last.id_to_display).to match(/S*/) end + context "missing required scheme params" do + let(:params) do + { scheme: { service_name: "", + scheme_type: "", + registered_under_care_act: "", + support_services_provider: "" } } + 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("Select the scheme’s type") + expect(page).to have_content("Select if this scheme is registered under the Care Standards Act 2000") + expect(page).to have_content("Select who provides the support services used by this scheme") + expect(page).to have_content("Enter the existing organisation’s name") + expect(page).to have_content("Enter the scheme’s name") + 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" } } }