mirror of
https://github.com/internetee/registry.git
synced 2025-08-16 14:33:55 +02:00
Refactor pendings #2773
This commit is contained in:
parent
036cbbec6b
commit
8b527bb153
3 changed files with 109 additions and 11 deletions
|
@ -353,10 +353,6 @@ class Domain < ActiveRecord::Base
|
||||||
save
|
save
|
||||||
end
|
end
|
||||||
|
|
||||||
def pending_update?
|
|
||||||
statuses.include?(DomainStatus::PENDING_UPDATE)
|
|
||||||
end
|
|
||||||
|
|
||||||
def pending_update!
|
def pending_update!
|
||||||
return true if pending_update?
|
return true if pending_update?
|
||||||
self.epp_pending_update = true # for epp
|
self.epp_pending_update = true # for epp
|
||||||
|
@ -378,7 +374,7 @@ class Domain < ActiveRecord::Base
|
||||||
self.pending_json = pending_json_cache
|
self.pending_json = pending_json_cache
|
||||||
self.registrant_verification_token = token
|
self.registrant_verification_token = token
|
||||||
self.registrant_verification_asked_at = asked_at
|
self.registrant_verification_asked_at = asked_at
|
||||||
self.statuses = [DomainStatus::PENDING_UPDATE]
|
self.statuses = DomainStatus::PENDING_UPDATE
|
||||||
pending_json[:domain] = changes_cache
|
pending_json[:domain] = changes_cache
|
||||||
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
|
||||||
|
@ -422,16 +418,12 @@ class Domain < ActiveRecord::Base
|
||||||
self.registrant_verification_token = SecureRandom.hex(42)
|
self.registrant_verification_token = SecureRandom.hex(42)
|
||||||
end
|
end
|
||||||
|
|
||||||
def pending_delete?
|
|
||||||
statuses.include?(DomainStatus::PENDING_DELETE)
|
|
||||||
end
|
|
||||||
|
|
||||||
def pending_delete!
|
def pending_delete!
|
||||||
return true if pending_delete?
|
return true if pending_delete?
|
||||||
self.epp_pending_delete = true # for epp
|
self.epp_pending_delete = true # for epp
|
||||||
|
|
||||||
return true unless registrant_verification_asked?
|
return true unless registrant_verification_asked?
|
||||||
self.statuses = [DomainStatus::PENDING_DELETE]
|
self.statuses = DomainStatus::PENDING_DELETE
|
||||||
save(validate: false) # should check if this did succeed
|
save(validate: false) # should check if this did succeed
|
||||||
|
|
||||||
DomainMailer.pending_deleted(self).deliver_now
|
DomainMailer.pending_deleted(self).deliver_now
|
||||||
|
@ -570,6 +562,56 @@ class Domain < ActiveRecord::Base
|
||||||
save(validate: false)
|
save(validate: false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def pending_update?
|
||||||
|
statuses.include?(DomainStatus::PENDING_UPDATE)
|
||||||
|
end
|
||||||
|
|
||||||
|
# TODO: Review the list and disallow epp calls
|
||||||
|
def pending_update_prohibited?
|
||||||
|
(statuses & [
|
||||||
|
DomainStatus::CLIENT_UPDATE_PROHIBITED,
|
||||||
|
DomainStatus::SERVER_UPDATE_PROHIBITED,
|
||||||
|
DomainStatus::PENDING_CREATE,
|
||||||
|
DomainStatus::PENDING_UPDATE,
|
||||||
|
DomainStatus::PENDING_DELETE,
|
||||||
|
DomainStatus::PENDING_RENEW,
|
||||||
|
DomainStatus::PENDING_TRANSFER
|
||||||
|
]).present?
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_pending_update
|
||||||
|
if pending_update_prohibited?
|
||||||
|
logger.info "DOMAIN STATUS UPDATE ISSUE ##{id}: PENDING_UPDATE not allowed to set. [#{statuses}]"
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
statuses << DomainStatus::PENDING_UPDATE
|
||||||
|
end
|
||||||
|
|
||||||
|
def pending_delete?
|
||||||
|
statuses.include?(DomainStatus::PENDING_DELETE)
|
||||||
|
end
|
||||||
|
|
||||||
|
# TODO: Review the list and disallow epp calls
|
||||||
|
def pending_delete_prohibited?
|
||||||
|
(statuses & [
|
||||||
|
DomainStatus::CLIENT_DELETE_PROHIBITED,
|
||||||
|
DomainStatus::SERVER_DELETE_PROHIBITED,
|
||||||
|
DomainStatus::PENDING_CREATE,
|
||||||
|
DomainStatus::PENDING_UPDATE,
|
||||||
|
DomainStatus::PENDING_DELETE,
|
||||||
|
DomainStatus::PENDING_RENEW,
|
||||||
|
DomainStatus::PENDING_TRANSFER
|
||||||
|
]).present?
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_pending_delete
|
||||||
|
if pending_delete_prohibited?
|
||||||
|
logger.info "DOMAIN STATUS UPDATE ISSUE ##{id}: PENDING_DELETE not allowed to set. [#{statuses}]"
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
statuses << DomainStatus::PENDING_DELETE
|
||||||
|
end
|
||||||
|
|
||||||
def manage_automatic_statuses
|
def manage_automatic_statuses
|
||||||
# domain_statuses.create(value: DomainStatus::DELETE_CANDIDATE) if delete_candidateable?
|
# domain_statuses.create(value: DomainStatus::DELETE_CANDIDATE) if delete_candidateable?
|
||||||
if statuses.empty? && valid?
|
if statuses.empty? && valid?
|
||||||
|
|
|
@ -411,7 +411,9 @@ class Epp::Domain < Domain
|
||||||
|
|
||||||
# at[:statuses] += at_add[:domain_statuses_attributes]
|
# at[:statuses] += at_add[:domain_statuses_attributes]
|
||||||
|
|
||||||
if verify && frame.css('registrant').present? && frame.css('registrant').attr('verified').to_s.downcase != 'yes'
|
if verify &&
|
||||||
|
frame.css('registrant').present? &&
|
||||||
|
frame.css('registrant').attr('verified').to_s.downcase != 'yes'
|
||||||
registrant_verification_asked!(frame.to_s, current_user.id)
|
registrant_verification_asked!(frame.to_s, current_user.id)
|
||||||
end
|
end
|
||||||
self.deliver_emails = true # turn on email delivery for epp
|
self.deliver_emails = true # turn on email delivery for epp
|
||||||
|
|
|
@ -37,6 +37,22 @@ describe Domain do
|
||||||
it 'should not be registrant update confirm ready' do
|
it 'should not be registrant update confirm ready' do
|
||||||
@domain.registrant_update_confirmable?('123').should == false
|
@domain.registrant_update_confirmable?('123').should == false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should not have pending update' do
|
||||||
|
@domain.pending_update?.should == false
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should allow pending update' do
|
||||||
|
@domain.pending_update_prohibited?.should == false
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should not have pending delete' do
|
||||||
|
@domain.pending_delete?.should == false
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should allow pending delete' do
|
||||||
|
@domain.pending_delete_prohibited?.should == false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with valid attributes' do
|
context 'with valid attributes' do
|
||||||
|
@ -328,6 +344,44 @@ describe Domain do
|
||||||
domain.pricelist('renew').price.amount.should == 6.1
|
domain.pricelist('renew').price.amount.should == 6.1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should set pending update' do
|
||||||
|
@domain.statuses = DomainStatus::OK # restore
|
||||||
|
@domain.pending_update?.should == false
|
||||||
|
|
||||||
|
@domain.set_pending_update
|
||||||
|
@domain.pending_update?.should == true
|
||||||
|
@domain.statuses = DomainStatus::OK # restore
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should not set pending update' do
|
||||||
|
@domain.statuses = DomainStatus::OK # restore
|
||||||
|
@domain.statuses << DomainStatus::CLIENT_UPDATE_PROHIBITED
|
||||||
|
|
||||||
|
@domain.set_pending_update.should == nil # not updated
|
||||||
|
@domain.pending_update?.should == false
|
||||||
|
@domain.statuses = DomainStatus::OK # restore
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should set pending delete' do
|
||||||
|
@domain.statuses = DomainStatus::OK # restore
|
||||||
|
@domain.pending_delete?.should == false
|
||||||
|
|
||||||
|
@domain.set_pending_delete.should == ['pendingDelete']
|
||||||
|
@domain.pending_delete?.should == true
|
||||||
|
@domain.statuses = DomainStatus::OK # restore
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should not set pending delele' do
|
||||||
|
@domain.statuses = DomainStatus::OK # restore
|
||||||
|
@domain.pending_delete?.should == false
|
||||||
|
@domain.statuses << DomainStatus::CLIENT_DELETE_PROHIBITED
|
||||||
|
|
||||||
|
@domain.set_pending_delete.should == nil
|
||||||
|
|
||||||
|
@domain.pending_delete?.should == false
|
||||||
|
@domain.statuses = DomainStatus::OK # restore
|
||||||
|
end
|
||||||
|
|
||||||
context 'about registrant update confirm' do
|
context 'about registrant update confirm' do
|
||||||
before :all do
|
before :all do
|
||||||
@domain.registrant_verification_token = 123
|
@domain.registrant_verification_token = 123
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue