From 03b58f738612f418c4263b860105029c875c1d03 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Mon, 14 Mar 2016 17:56:31 +0200 Subject: [PATCH 1/4] Story#115405945 - clean_pendings_lowlevel saves history --- app/models/domain.rb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index ff51f6f08..27c061770 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,21 @@ 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] - ) + } + + # papertrail + self.attributes = hash + record_create + clear_version_instance! + reset_transaction_id + + update_columns(hash) end def pending_update! From d703cac62dae4f9c0d346416a1a26f4dc144a983 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Tue, 15 Mar 2016 15:20:08 +0200 Subject: [PATCH 2/4] Story#115405945 - on remove pending state create update history record --- app/models/domain.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index 27c061770..28cf46041 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -365,7 +365,7 @@ class Domain < ActiveRecord::Base # papertrail self.attributes = hash - record_create + record_update clear_version_instance! reset_transaction_id From 92bc47adfa9488e82f6f6aafe81e6278863607eb Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Thu, 17 Mar 2016 12:49:00 +0200 Subject: [PATCH 3/4] Story#115405945 - papertrail saves new time as record itself --- app/models/domain.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index 28cf46041..a71a06467 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -360,10 +360,12 @@ class Domain < ActiveRecord::Base 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 + # PaperTrail self.attributes = hash record_update clear_version_instance! From ee36333640b4f588ad1b3b68722614699b35ab02 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Mon, 4 Apr 2016 14:59:09 +0300 Subject: [PATCH 4/4] Story#115405945 - setting pending update should update updated_at --- app/models/domain.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/domain.rb b/app/models/domain.rb index a71a06467..3c7ad14e2 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -395,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