mirror of
https://github.com/internetee/registry.git
synced 2025-08-05 17:28:18 +02:00
parent
0f352cab24
commit
d520b5b157
50 changed files with 2462 additions and 323 deletions
33
spec/models/contact/contact_phone_spec.rb
Normal file
33
spec/models/contact/contact_phone_spec.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
require 'rails_helper'
|
||||
require 'lib/validators/e164'
|
||||
|
||||
RSpec.describe Contact do
|
||||
let(:contact) { described_class.new }
|
||||
|
||||
describe 'phone', db: false do
|
||||
it_behaves_like 'e164' do
|
||||
let(:model) { contact }
|
||||
let(:attribute) { :phone }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'phone validation', db: false do
|
||||
it 'rejects absent' do
|
||||
contact.phone = nil
|
||||
contact.validate
|
||||
expect(contact.errors).to be_added(:phone, :blank)
|
||||
end
|
||||
|
||||
it 'rejects all zeros in country code' do
|
||||
contact.phone = '+000.1'
|
||||
contact.validate
|
||||
expect(contact.errors).to be_added(:phone, :invalid)
|
||||
end
|
||||
|
||||
it 'rejects all zeros in subscriber number' do
|
||||
contact.phone = '+123.0'
|
||||
contact.validate
|
||||
expect(contact.errors).to be_added(:phone, :invalid)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue