mirror of
https://github.com/internetee/registry.git
synced 2025-06-04 11:47:30 +02:00
implement domain statuses restore after domain locked, added test
This commit is contained in:
parent
90cb154d15
commit
28a54d6612
6 changed files with 645 additions and 885 deletions
|
@ -1,6 +1,8 @@
|
|||
module Domain::RegistryLockable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
# status_notes public.hstore,
|
||||
|
||||
LOCK_STATUSES = [DomainStatus::SERVER_UPDATE_PROHIBITED,
|
||||
DomainStatus::SERVER_DELETE_PROHIBITED,
|
||||
DomainStatus::SERVER_TRANSFER_PROHIBITED].freeze
|
||||
|
@ -9,6 +11,12 @@ module Domain::RegistryLockable
|
|||
return unless registry_lockable?
|
||||
return if locked_by_registrant?
|
||||
|
||||
self.locked_domain_statuses_history = self.statuses.map do |status|
|
||||
if LOCK_STATUSES.include? status
|
||||
status
|
||||
end
|
||||
end
|
||||
|
||||
transaction do
|
||||
self.statuses |= LOCK_STATUSES
|
||||
self.locked_by_registrant_at = Time.zone.now
|
||||
|
@ -36,7 +44,9 @@ module Domain::RegistryLockable
|
|||
|
||||
transaction do
|
||||
LOCK_STATUSES.each do |domain_status|
|
||||
statuses.delete(domain_status)
|
||||
unless self.locked_domain_statuses_history.include? domain_status
|
||||
statuses.delete(domain_status)
|
||||
end
|
||||
end
|
||||
self.locked_by_registrant_at = nil
|
||||
alert_registrar_lock_changes!(lock: false)
|
||||
|
|
|
@ -16,6 +16,9 @@ class Domain < ApplicationRecord
|
|||
|
||||
attr_accessor :legal_document_id
|
||||
|
||||
# serialize :json_statuses_history, HashSerializer
|
||||
store_accessor :json_statuses_history, :force_delete_domain_statuses_history, :locked_domain_statuses_history
|
||||
|
||||
alias_attribute :on_hold_time, :outzone_at
|
||||
alias_attribute :outzone_time, :outzone_at
|
||||
alias_attribute :auth_info, :transfer_code # Old attribute name; for PaperTrail
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
class AddJsonStatusesHistoryFieldToDomain < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
add_column :domains, :json_statuses_history, :jsonb
|
||||
add_index :domains, :json_statuses_history, using: :gin
|
||||
end
|
||||
end
|
1489
db/structure.sql
1489
db/structure.sql
File diff suppressed because it is too large
Load diff
|
@ -33,6 +33,16 @@ class DomainRegistryLockableTest < ActiveSupport::TestCase
|
|||
assert_not(@domain.locked_by_registrant?)
|
||||
end
|
||||
|
||||
def test_restore_domain_statuses_after_unlock
|
||||
@domain.update(statuses: [DomainStatus::SERVER_UPDATE_PROHIBITED])
|
||||
@domain.apply_registry_lock
|
||||
assert @domain.locked_by_registrant?
|
||||
assert_equal @domain.statuses.sort, Domain::RegistryLockable::LOCK_STATUSES.sort
|
||||
|
||||
@domain.remove_registry_lock
|
||||
assert @domain.statuses.include? DomainStatus::SERVER_UPDATE_PROHIBITED
|
||||
end
|
||||
|
||||
def test_registry_lock_on_lockable_domain
|
||||
refute(@domain.locked_by_registrant?)
|
||||
@domain.apply_registry_lock
|
||||
|
|
|
@ -27,6 +27,16 @@ class DomainTest < ActiveSupport::TestCase
|
|||
assert domains(:invalid).invalid?
|
||||
end
|
||||
|
||||
def test_valid_domain_statuses_history
|
||||
@domain.force_delete_domain_statuses_history = [DomainStatus::SERVER_UPDATE_PROHIBITED, DomainStatus::SERVER_TRANSFER_PROHIBITED]
|
||||
@domain.locked_domain_statuses_history = [DomainStatus::SERVER_UPDATE_PROHIBITED]
|
||||
assert @domain.valid?
|
||||
|
||||
assert @domain.json_statuses_history['force_delete_domain_statuses_history'].include? 'serverUpdateProhibited'
|
||||
assert @domain.json_statuses_history['force_delete_domain_statuses_history'].include? 'serverTransferProhibited'
|
||||
assert_equal @domain.json_statuses_history['locked_domain_statuses_history'], ['serverUpdateProhibited']
|
||||
end
|
||||
|
||||
# https://www.internet.ee/domeenid/ee-domeenireeglid#domeeninimede-registreerimine
|
||||
def test_validates_name_format
|
||||
assert_equal dns_zones(:one).origin, 'test'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue