Update automatic statuses for domain pending #2731

This commit is contained in:
Priit Tark 2015-07-31 12:51:32 +03:00
parent a784eb4769
commit 19f61dd30f

View file

@ -62,19 +62,20 @@ class Domain < ActiveRecord::Base
before_create :generate_auth_info before_create :generate_auth_info
before_create :set_validity_dates before_create :set_validity_dates
before_create -> { self.reserved = in_reserved_list?; nil } before_create -> { self.reserved = in_reserved_list?; nil }
before_update :manage_statuses
def manage_statuses
return unless registrant_id_changed?
pending_update! if registrant_verification_asked?
true
end
before_save :manage_automatic_statuses before_save :manage_automatic_statuses
before_save :touch_always_version before_save :touch_always_version
def touch_always_version def touch_always_version
self.updated_at = Time.zone.now self.updated_at = Time.zone.now
end end
before_update :manage_statuses
def manage_statuses
return unless registrant_id_changed? # rollback has not yet happened
pending_update! if registrant_verification_asked?
true
end
after_save :update_whois_record after_save :update_whois_record
after_create :update_reserved_domains after_create :update_reserved_domains
@ -379,6 +380,12 @@ class Domain < ActiveRecord::Base
pending_json[:new_registrant_id] = new_registrant_id pending_json[:new_registrant_id] = new_registrant_id
pending_json[:new_registrant_email] = new_registrant_email pending_json[:new_registrant_email] = new_registrant_email
pending_json[:new_registrant_name] = new_registrant_name pending_json[:new_registrant_name] = new_registrant_name
# This pending_update! method is triggered by before_update
# Note, all before_save callbacks are excecuted before before_update,
# thus automatic statuses has already excectued by this point
# and we need to trigger automatic statuses manually (second time).
manage_automatic_statuses
end end
# rubocop: disable Metrics/CyclomaticComplexity # rubocop: disable Metrics/CyclomaticComplexity