Merge remote-tracking branch 'origin/registry-791' into registry-791

This commit is contained in:
Artur Beljajev 2018-06-15 16:56:27 +03:00
commit 96b02ed8d5
4 changed files with 26 additions and 14 deletions

View file

@ -11,6 +11,7 @@ module Concerns::Domain::ForceDelete
self.force_delete_at = (Time.zone.now + (Setting.redemption_grace_period.days + 1.day)).utc
.beginning_of_day
stop_all_pending_actions
allow_deletion
save(validate: false)
end
@ -26,8 +27,6 @@ module Concerns::Domain::ForceDelete
private
def stop_all_pending_actions
statuses.delete(DomainStatus::CLIENT_DELETE_PROHIBITED)
statuses.delete(DomainStatus::SERVER_DELETE_PROHIBITED)
statuses.delete(DomainStatus::PENDING_UPDATE)
statuses.delete(DomainStatus::PENDING_TRANSFER)
statuses.delete(DomainStatus::PENDING_RENEW)
@ -63,4 +62,9 @@ module Concerns::Domain::ForceDelete
statuses.delete(DomainStatus::PENDING_DELETE)
statuses.delete(DomainStatus::SERVER_MANUAL_INZONE)
end
def allow_deletion
statuses.delete(DomainStatus::CLIENT_DELETE_PROHIBITED)
statuses.delete(DomainStatus::SERVER_DELETE_PROHIBITED)
end
end

View file

@ -617,6 +617,7 @@ class Domain < ActiveRecord::Base
hash = super
hash['auth_info'] = hash.delete('transfer_code') # API v1 requirement
hash['valid_from'] = hash['registered_at'] # API v1 requirement
hash.delete('statuses_before_force_delete')
hash
end

View file

@ -63,10 +63,7 @@ Content-Type: application/json
],
"reserved": false,
"status_notes": {
},
"statuses_backup": [
]
}
}
],
"total_number_of_records": 2

View file

@ -21,7 +21,7 @@ class DomainForceDeleteTest < ActiveSupport::TestCase
end
def test_scheduling_force_delete_adds_corresponding_statuses
statuses = [
statuses_to_be_added = [
DomainStatus::FORCE_DELETE,
DomainStatus::SERVER_RENEW_PROHIBITED,
DomainStatus::SERVER_TRANSFER_PROHIBITED,
@ -31,23 +31,33 @@ class DomainForceDeleteTest < ActiveSupport::TestCase
@domain.schedule_force_delete
@domain.reload
assert (@domain.statuses & statuses) == statuses
assert (@domain.statuses & statuses_to_be_added) == statuses_to_be_added
end
def test_scheduling_force_delete_allows_domain_deletion
statuses_to_be_removed = [
DomainStatus::CLIENT_DELETE_PROHIBITED,
DomainStatus::SERVER_DELETE_PROHIBITED,
]
@domain.statuses = statuses_to_be_removed + %w[other-status]
@domain.schedule_force_delete
@domain.reload
assert_empty @domain.statuses & statuses_to_be_removed
end
def test_scheduling_force_delete_stops_pending_actions
statuses = [
DomainStatus::CLIENT_DELETE_PROHIBITED,
DomainStatus::SERVER_DELETE_PROHIBITED,
statuses_to_be_removed = [
DomainStatus::PENDING_UPDATE,
DomainStatus::PENDING_TRANSFER,
DomainStatus::PENDING_RENEW,
DomainStatus::PENDING_CREATE,
]
@domain.statuses = statuses + %w[other-status]
@domain.statuses = statuses_to_be_removed + %w[other-status]
@domain.schedule_force_delete
@domain.reload
assert_not (@domain.statuses & statuses).any?, 'Pending actions should be stopped'
assert_empty @domain.statuses & statuses_to_be_removed, 'Pending actions should be stopped'
end
def test_scheduling_force_delete_preserves_current_statuses
@ -103,7 +113,7 @@ class DomainForceDeleteTest < ActiveSupport::TestCase
@domain.cancel_force_delete
@domain.reload
assert (@domain.statuses & statuses).empty?
assert_empty @domain.statuses & statuses
end
def test_cancelling_force_delete_restores_statuses_that_a_domain_had_before_force_delete