From f70385ad36fe240c10393947cb043101f089927f Mon Sep 17 00:00:00 2001 From: JG Date: Wed, 13 Jul 2022 15:09:50 +0100 Subject: [PATCH] tests for validations locaion --- config/locales/en.yml | 5 ----- spec/models/location_spec.rb | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 1cba663a1..296c59aa2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -44,17 +44,12 @@ en: scheme: attributes: owning_organisation_id: - required: "Enter the existing organisation’s name" invalid: "Enter the existing organisation’s name" - blank: "Enter the existing organisation’s name" service_name: - blank: "Enter the scheme’s name" invalid: "Enter the scheme’s name" scheme_type: - blank: "Select the scheme’s type" invalid: "Select the scheme’s type" registered_under_care_act: - blank: "Select if this scheme is registered under the Care Standards Act 2000" 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" diff --git a/spec/models/location_spec.rb b/spec/models/location_spec.rb index a886c6034..677fc3133 100644 --- a/spec/models/location_spec.rb +++ b/spec/models/location_spec.rb @@ -24,4 +24,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