You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
776 B
28 lines
776 B
2 years ago
|
require "rails_helper"
|
||
|
|
||
|
RSpec.describe Location, type: :model do
|
||
|
describe "#new" do
|
||
|
let(:location) { FactoryBot.build(:location) }
|
||
|
|
||
|
it "belongs to an organisation" do
|
||
|
expect(location.scheme).to be_a(Scheme)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
describe "#validate_postcode" do
|
||
|
let(:location) { FactoryBot.build(:location) }
|
||
|
|
||
|
it "does not add an error if postcode is valid" do
|
||
|
location.postcode = "M1 1AE"
|
||
|
location.save!
|
||
|
expect(location.errors).to be_empty
|
||
|
end
|
||
|
|
||
|
it "does add an error when the postcode is invalid" do
|
||
|
location.postcode = "invalid"
|
||
|
expect { location.save! }
|
||
|
.to raise_error(ActiveRecord::RecordInvalid, "Validation failed: Postcode Enter a postcode in the correct format, for example AA1 1AA")
|
||
|
end
|
||
|
end
|
||
|
end
|