diff --git a/app/models/domain.rb b/app/models/domain.rb index 8bac1c2dc..8aa3bcc6e 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -345,7 +345,8 @@ class Domain < ActiveRecord::Base end - # state change shouln't be + # state changes may be done low-level - no validation + # in this metod we still save PaperTrail log. def clean_pendings_lowlevel statuses.delete(DomainStatus::PENDING_DELETE_CONFIRMATION) statuses.delete(DomainStatus::PENDING_UPDATE) @@ -354,13 +355,23 @@ class Domain < ActiveRecord::Base status_notes[DomainStatus::PENDING_UPDATE] = '' status_notes[DomainStatus::PENDING_DELETE] = '' - update_columns( + hash = { registrant_verification_token: nil, registrant_verification_asked_at: nil, pending_json: {}, status_notes: status_notes, - statuses: statuses.presence || [DomainStatus::OK] - ) + statuses: statuses.presence || [DomainStatus::OK], + # need this column in order to update PaperTrail version properly + updated_at: Time.now.utc + } + + # PaperTrail + self.attributes = hash + record_update + clear_version_instance! + reset_transaction_id + + update_columns(hash) end def pending_update! @@ -384,6 +395,7 @@ class Domain < ActiveRecord::Base self.registrant_verification_token = token self.registrant_verification_asked_at = asked_at set_pending_update + touch_always_version pending_json['new_registrant_id'] = new_registrant_id pending_json['new_registrant_email'] = new_registrant_email pending_json['new_registrant_name'] = new_registrant_name