From d9d8aef813fdc99a529086da899a430d6af4e202 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Tue, 12 Jan 2016 18:27:29 +0200 Subject: [PATCH] Story#111503520 - custom lowlevel pending state rejection --- app/jobs/domain_update_confirm_job.rb | 3 +-- app/models/domain.rb | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/app/jobs/domain_update_confirm_job.rb b/app/jobs/domain_update_confirm_job.rb index f028b95f8..098b9853e 100644 --- a/app/jobs/domain_update_confirm_job.rb +++ b/app/jobs/domain_update_confirm_job.rb @@ -12,8 +12,7 @@ class DomainUpdateConfirmJob < Que::Job when RegistrantVerification::REJECTED domain.send_mail :pending_update_rejected_notification_for_new_registrant domain.poll_message!(:poll_pending_update_rejected_by_registrant) - domain.clean_pendings! - domain.save(validate: false) + domain.clean_pendings_lowlevel end destroy # it's best to destroy the job in the same transaction end diff --git a/app/models/domain.rb b/app/models/domain.rb index 05ffafc4d..baf7d0308 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -244,7 +244,7 @@ class Domain < ActiveRecord::Base if domain.pending_delete? || domain.pending_delete_confirmation? DomainMailer.pending_delete_expired_notification(domain.id, true).deliver end - domain.clean_pendings! + domain.clean_pendings_lowlevel unless Rails.env.test? STDOUT << "#{Time.zone.now.utc} Domain.clean_expired_pendings: ##{domain.id} (#{domain.name})\n" end @@ -439,6 +439,25 @@ class Domain < ActiveRecord::Base save end + + # state change shouln't be + def clean_pendings_lowlevel + statuses.delete(DomainStatus::PENDING_DELETE_CONFIRMATION) + statuses.delete(DomainStatus::PENDING_UPDATE) + statuses.delete(DomainStatus::PENDING_DELETE) + + status_notes[DomainStatus::PENDING_UPDATE] = '' + status_notes[DomainStatus::PENDING_DELETE] = '' + + update_columns( + registrant_verification_token: nil, + registrant_verification_asked_at: nil, + pending_json: {}, + status_notes: status_notes, + statuses: statuses.presence || [DomainStatus::OK] + ) + end + def pending_update! return true if pending_update? self.epp_pending_update = true # for epp