From c83b99b6de4f9537008aa9b06f7f1dfb19c6866d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergei=20Ts=C3=B5ganov?= Date: Wed, 12 Jan 2022 10:41:56 +0200 Subject: [PATCH] Did small refactoring --- app/models/domain.rb | 20 ++++++++++++------- test/mailers/registrant_change_mailer_test.rb | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index 487c701a9..873216cf1 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -469,6 +469,7 @@ class Domain < ApplicationRecord return false unless pending_update? return false unless registrant_verification_asked? return false unless registrant_verification_token == token + true end @@ -476,6 +477,7 @@ class Domain < ApplicationRecord return false unless pending_delete? return false unless registrant_verification_asked? return false unless registrant_verification_token == token + true end @@ -492,10 +494,12 @@ class Domain < ApplicationRecord def pending_delete! return true if pending_delete? + self.epp_pending_delete = true # for epp # TODO: if this were to ever return true, that would be wrong. EPP would report sucess pending return true unless registrant_verification_asked? + pending_delete_confirmation! save(validate: false) # should check if this did succeed @@ -560,6 +564,7 @@ class Domain < ApplicationRecord def pending_registrant return '' if pending_json.blank? return '' if pending_json['new_registrant_id'].blank? + Registrant.find_by(id: pending_json['new_registrant_id']) end @@ -590,11 +595,12 @@ class Domain < ApplicationRecord # special handling for admin changing status def admin_status_update(update) + return unless update + PaperTrail.request(enabled: false) do update_unless_locked_by_registrant(update) update_not_by_locked_statuses(update) end - return unless update # check for deleted status statuses.each do |s| @@ -660,7 +666,7 @@ class Domain < ApplicationRecord end def manage_automatic_statuses - if !self.class.nameserver_required? + unless self.class.nameserver_required? deactivate if nameservers.reject(&:marked_for_destruction?).empty? activate if nameservers.reject(&:marked_for_destruction?).size >= Setting.ns_min_count end @@ -681,11 +687,11 @@ class Domain < ApplicationRecord def children_log log = HashWithIndifferentAccess.new log[:admin_contacts] = admin_contact_ids - log[:tech_contacts] = tech_contact_ids - log[:nameservers] = nameserver_ids - log[:dnskeys] = dnskey_ids - log[:legal_documents]= [legal_document_id] - log[:registrant] = [registrant_id] + log[:tech_contacts] = tech_contact_ids + log[:nameservers] = nameserver_ids + log[:dnskeys] = dnskey_ids + log[:legal_documents] = [legal_document_id] + log[:registrant] = [registrant_id] log end diff --git a/test/mailers/registrant_change_mailer_test.rb b/test/mailers/registrant_change_mailer_test.rb index 5ddfc76db..21150ea7e 100644 --- a/test/mailers/registrant_change_mailer_test.rb +++ b/test/mailers/registrant_change_mailer_test.rb @@ -13,7 +13,7 @@ class RegistrantChangeMailerTest < ActionMailer::TestCase registrar: @domain.registrar, current_registrant: @domain.registrant, new_registrant: @domain.registrant) - .deliver_now + .deliver_now assert_emails 1 assert_equal ['john@inbox.test'], email.to