mirror of
https://github.com/internetee/registry.git
synced 2025-05-16 17:37:17 +02:00
parent
8a04fa793d
commit
1ae00382cd
2 changed files with 30 additions and 0 deletions
|
@ -55,6 +55,16 @@ class Contact::Ident
|
|||
Country.new(country_code)
|
||||
end
|
||||
|
||||
def ==(other_ident)
|
||||
if other_ident.is_a?(self.class)
|
||||
(code == other_ident.code) &&
|
||||
(type == other_ident.type) &&
|
||||
(country_code == other_ident.country_code)
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# https://github.com/rails/rails/issues/1513
|
||||
|
|
|
@ -204,4 +204,24 @@ RSpec.describe Contact::Ident, db: false do
|
|||
expect(ident.country).to eq(Country.new('US'))
|
||||
end
|
||||
end
|
||||
|
||||
describe '#==' do
|
||||
let(:ident) { described_class.new(code: 'test', type: 'test', country_code: 'US') }
|
||||
|
||||
context 'when code, type and country code are the same' do
|
||||
let(:another_ident) { described_class.new(code: 'test', type: 'test', country_code: 'US') }
|
||||
|
||||
it 'returns true' do
|
||||
expect(ident).to eq(another_ident)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when code, type and country code are not the same' do
|
||||
let(:another_ident) { described_class.new(code: 'another-test', type: 'test', country_code: 'US') }
|
||||
|
||||
it 'returns false' do
|
||||
expect(ident).to_not eq(another_ident)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue