diff --git a/app/models/location.rb b/app/models/location.rb index 30cb18dda..608bde049 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 before_save :infer_la!, if: :postcode_changed? diff --git a/app/views/locations/edit.html.erb b/app/views/locations/edit.html.erb index 227605485..def74ee65 100644 --- a/app/views/locations/edit.html.erb +++ b/app/views/locations/edit.html.erb @@ -41,12 +41,17 @@ 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/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" } } }