From bfbee65a4987cf22b230d140c83a5fa5b49e4095 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 6 Mar 2018 12:26:35 +0200 Subject: [PATCH] Remove duplicate method #746 --- .reek | 1 - app/models/contact.rb | 18 +++--------------- spec/models/contact_spec.rb | 4 ---- 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/.reek b/.reek index 6cdd58c75..0d5c66aa3 100644 --- a/.reek +++ b/.reek @@ -1066,7 +1066,6 @@ Attribute: - BankStatement#th6_file - Versions#version_loader - Contact#deliver_emails - - Contact#domains_present - Contact#legal_document_id - Counter#value - Deposit#amount diff --git a/app/models/contact.rb b/app/models/contact.rb index d01d42634..417c1f07b 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -70,10 +70,6 @@ class Contact < ActiveRecord::Base after_save :update_related_whois_records - - # for overwrite when doing children loop - attr_writer :domains_present - scope :current_registrars, ->(id) { where(registrar_id: id) } ORG = 'org' @@ -207,7 +203,7 @@ class Contact < ActiveRecord::Base ver_scope << "(children->'#{type}')::jsonb <@ json_build_array(#{contact.id})::jsonb" end next if DomainVersion.where("created_at > ?", Time.now - Setting.orphans_contacts_in_months.to_i.months).where(ver_scope.join(" OR ")).any? - next if contact.domains_present? + next if contact.used? contact.destroy counter.next @@ -280,7 +276,7 @@ class Contact < ActiveRecord::Base calculated.delete(Contact::OK) calculated.delete(Contact::LINKED) calculated << Contact::OK if calculated.empty?# && valid? - calculated << Contact::LINKED if domains_present? + calculated << Contact::LINKED if used? calculated.uniq end @@ -348,7 +344,7 @@ class Contact < ActiveRecord::Base # no need separate method # should use only in transaction def destroy_and_clean frame - if domains_present? + if used? errors.add(:domains, :exist) return false end @@ -406,14 +402,6 @@ class Contact < ActiveRecord::Base end end - # optimization under children loop, - # otherwise bullet will not be happy - def domains_present? - return @domains_present if @domains_present - domain_contacts.present? || registrant_domains.present? - end - - def search_name "#{code} #{name}" end diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index 1703bf90a..7c9a7c833 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -76,10 +76,6 @@ RSpec.describe Contact do end end - it 'should not have relation with domains' do - @contact.domains_present?.should == false - end - it 'should not overwrite code' do old_code = @contact.code @contact.code = 'CID:REG1:should-not-overwrite-old-code-12345'