Browse Source

test: add missing location validations for nil postcode & mobility type

pull/987/head
Sam Seed 4 years ago
parent
commit
e4e203fb73
  1. 16
      spec/models/location_spec.rb

16
spec/models/location_spec.rb

@ -34,6 +34,12 @@ RSpec.describe Location, type: :model do
expect { location.save! }
.to raise_error(ActiveRecord::RecordInvalid, "Validation failed: Postcode #{I18n.t('validations.postcode')}")
end
it "does add an error when the postcode is missing" do
location.postcode = nil
expect { location.save! }
.to raise_error(ActiveRecord::RecordInvalid, "Validation failed: Postcode #{I18n.t('validations.postcode')}")
end
end
describe "#units" do
@ -56,6 +62,16 @@ RSpec.describe Location, type: :model do
end
end
describe "#mobility_type" do
let(:location) { FactoryBot.build(:location) }
it "does add an error when the mobility type is invalid" do
location.mobility_type = nil
expect { location.save! }
.to raise_error(ActiveRecord::RecordInvalid, "Validation failed: Mobility type #{I18n.t('activerecord.errors.models.location.attributes.mobility_type.blank')}")
end
end
describe "paper trail" do
let(:location) { FactoryBot.create(:location) }
let!(:name) { location.name }

Loading…
Cancel
Save