Merge pull request #2197 from internetee/2195-setting-fd-to-locked-domains-remove-delete-prohibited-status

2195 setting fd to locked domains remove delete prohibited status
This commit is contained in:
Timo Võhmar 2021-10-25 09:34:37 +03:00 committed by GitHub
commit d67af520b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 3 deletions

View file

@ -10,6 +10,7 @@ module Domains
DomainStatus::SERVER_OBJ_UPDATE_PROHIBITED,
DomainStatus::SERVER_DELETE_PROHIBITED
] if domain.locked_by_registrant?
domain.admin_store_statuses_history -= domain_statuses unless domain.admin_store_statuses_history.nil?
rejected_statuses = domain.statuses.reject { |a| domain_statuses.include? a }
domain.statuses = rejected_statuses

View file

@ -11,7 +11,6 @@ module Domains
# Allow deletion
statuses.delete(DomainStatus::CLIENT_DELETE_PROHIBITED)
statuses.delete(DomainStatus::SERVER_DELETE_PROHIBITED)
domain.save(validate: false)
end
end

View file

@ -53,14 +53,23 @@ module Domain::RegistryLockable
end
end
def restore_statuses_if_domain_had_fd
self.statuses = self.statuses | Domain::FORCE_DELETE_STATUSES
save!
end
def remove_statuses_from_locked_domain
fd_flag = force_delete_scheduled?
LOCK_STATUSES.each do |domain_status|
statuses.delete([domain_status])
end
self.force_delete_domain_statuses_history -= LOCK_STATUSES if force_delete_domain_statuses_history.present?
statuses.delete([EXTENSIONS_STATUS]) if statuses.include? EXTENSIONS_STATUS
self.locked_by_registrant_at = nil
self.statuses = admin_store_statuses_history || []
self.statuses = self.statuses | Domain::FORCE_DELETE_STATUSES if fd_flag
alert_registrar_lock_changes!(lock: false)
save!

View file

@ -102,8 +102,7 @@ class ForceDeleteTest < ActionMailer::TestCase
def test_scheduling_force_delete_allows_domain_deletion
statuses_to_be_removed = [
DomainStatus::CLIENT_DELETE_PROHIBITED,
DomainStatus::SERVER_DELETE_PROHIBITED
DomainStatus::CLIENT_DELETE_PROHIBITED
]
@domain.statuses = statuses_to_be_removed + %w[other-status]

View file

@ -17,6 +17,18 @@ class DomainRegistryLockableTest < ActiveSupport::TestCase
assert(@domain.locked_by_registrant?)
end
def test_if_set_fd_to_lockable_domain_deleteProhibited_should_not_removed
@domain.apply_registry_lock(extensions_prohibited: false)
assert @domain.locked_by_registrant?
assert_equal @domain.statuses.sort, Domain::RegistryLockable::LOCK_STATUSES.sort
@domain.schedule_force_delete(type: :soft)
@domain.reload
assert @domain.force_delete_scheduled?
assert @domain.statuses.include? DomainStatus::SERVER_DELETE_PROHIBITED
end
def test_remove_lockalable_statuses_after_admin_intervention
@domain.apply_registry_lock(extensions_prohibited: false)
assert @domain.locked_by_registrant?