From e4ae71b30819af7558bd10ff6882de6e13e78771 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 2 Dec 2016 00:21:52 +0200 Subject: [PATCH] Add address processing to contact model #251 --- app/models/contact.rb | 14 ++++++++++++++ spec/models/contact_spec.rb | 23 +++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/app/models/contact.rb b/app/models/contact.rb index 822394d22..db9fc3dc1 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -257,6 +257,20 @@ class Contact < ActiveRecord::Base def emails pluck(:email) end + + def address_processing + Setting.address_processing + end + + def address_attributes + %i( + city + street + zip + country_code + state + ) + end end def roid diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index b20f4bf60..76c48f0ff 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -383,4 +383,27 @@ RSpec.describe Contact, db: false do expect(described_class.emails).to eq('emails') end end + + describe '::address_processing' do + before do + Setting.address_processing = 'test' + end + + it 'returns setting value' do + expect(described_class.address_processing).to eq('test') + end + end + + describe '::address_attributes', db: false do + it 'returns address attributes' do + attributes = %i( + city + street + zip + country_code + state + ) + expect(described_class.address_attributes).to eq(attributes) + end + end end