Browse Source

tests for validations locaion

juris_katrina_test
JG 3 years ago
parent
commit
f70385ad36
  1. 5
      config/locales/en.yml
  2. 20
      spec/models/location_spec.rb

5
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"

20
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

Loading…
Cancel
Save