From 55ae0dc0b785e1a3fd3c514e215dd353039ab59a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Mon, 10 Aug 2020 14:05:22 +0300 Subject: [PATCH] Remove redundant functions --- app/models/contact.rb | 6 ++---- test/models/contact_test.rb | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/contact.rb b/app/models/contact.rb index e91dab3b5..a2057f229 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -511,14 +511,12 @@ class Contact < ApplicationRecord def clear_address_modifications return unless modifies_address? - addr_fields = %i[city street zip state country_code] - addr_fields.each { |field| self[field] = nil } + remove_address end def modifies_address? - addr_fields = %i[city street zip state country_code] modified = false - addr_fields.each { |field| modified = true if changes.key?(field) } + self.class.address_attribute_names.each { |field| modified = true if changes.key?(field) } modified end diff --git a/test/models/contact_test.rb b/test/models/contact_test.rb index f833011c6..48b98a0d2 100644 --- a/test/models/contact_test.rb +++ b/test/models/contact_test.rb @@ -152,6 +152,8 @@ class ContactTest < ActiveSupport::TestCase end def test_address + Setting.address_processing = true + address = Contact::Address.new('new street', '83746', 'new city', 'new state', 'EE') @contact.address = address @contact.save!