Browse Source

tests for missing params

juris_katrina_test
JG 2 years ago
parent
commit
006a951712
  1. 2
      app/models/location.rb
  2. 2
      app/views/locations/edit.html.erb
  3. 2
      app/views/locations/new.html.erb
  4. 39
      spec/requests/schemes_controller_spec.rb

2
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

2
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") %>

2
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") %>

39
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" } } }

Loading…
Cancel
Save