1 changed files with 27 additions and 0 deletions
@ -0,0 +1,27 @@
|
||||
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" |
||||
location.save |
||||
expect(location.errors).not_to be_empty |
||||
expect(location.errors["postcode"]).to include(match I18n.t("validations.postcode")) |
||||
end |
||||
end |
||||
end |
Loading…
Reference in new issue