Revert "Revert "Registry 569""

This reverts commit 4786dbb
This commit is contained in:
Artur Beljajev 2017-10-22 23:57:11 +03:00
parent 0f352cab24
commit d520b5b157
50 changed files with 2462 additions and 323 deletions

View 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