Skip to content

Commit

Permalink
formatted refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Hasjanov committed Apr 6, 2021
1 parent 73a0b40 commit ce49c01
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ module Domains
module CancelForceDelete
class RemoveForceDeleteStatuses < Base
def execute
domain.statuses.delete(DomainStatus::FORCE_DELETE)
domain.statuses.delete(DomainStatus::SERVER_RENEW_PROHIBITED)
domain.statuses.delete(DomainStatus::SERVER_TRANSFER_PROHIBITED)
domain.statuses.delete(DomainStatus::CLIENT_HOLD)
domain_statuses = [DomainStatus::FORCE_DELETE,
DomainStatus::SERVER_RENEW_PROHIBITED,
DomainStatus::SERVER_TRANSFER_PROHIBITED,
DomainStatus::CLIENT_HOLD]
rejected_statuses = domain.statuses.reject { |a| domain_statuses.include? a } - domain_statuses
domain.statuses = rejected_statuses
domain.save(validate: false)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ module Domains
module CancelForceDelete
class RestoreStatusesBeforeForceDelete < Base
def execute
domain.statuses = domain.statuses_before_force_delete
# domain.statuses = domain.statuses_before_force_delete
domain.statuses = domain.force_delete_domain_statuses_history
domain.statuses_before_force_delete = nil
domain.force_delete_domain_statuses_history = nil
domain.save(validate: false)
end
end
Expand Down
1 change: 1 addition & 0 deletions app/interactions/domains/force_delete/prepare_domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class PrepareDomain < Base
DomainStatus::SERVER_TRANSFER_PROHIBITED].freeze

def execute
domain.force_delete_domain_statuses_history = domain.statuses
domain.statuses_before_force_delete = domain.statuses
domain.statuses |= STATUSES_TO_SET
domain.save(validate: false)
Expand Down
3 changes: 1 addition & 2 deletions app/models/concerns/domain/force_delete.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Domain::ForceDelete # rubocop:disable Metrics/ModuleLength

FORCE_DELETE_STATUSES = [DomainStatus::FORCE_DELETE,
DomainStatus::SERVER_RENEW_PROHIBITED,
DomainStatus::SERVER_TRANSFER_PROHIBITED]
DomainStatus::SERVER_TRANSFER_PROHIBITED].freeze

included do
store_accessor :force_delete_data,
Expand Down Expand Up @@ -60,7 +60,6 @@ def schedule_force_delete(type: :fast_track, notify_by_email: false, reason: nil

def cancel_force_delete
Domains::CancelForceDelete::CancelForceDelete.run(domain: self)
self.force_delete_domain_statuses_history = nil
end

def outzone_date
Expand Down
8 changes: 4 additions & 4 deletions app/models/concerns/domain/registry_lockable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def apply_registry_lock
return unless registry_lockable?
return if locked_by_registrant?

put_statuses_to_json_history_before_locked
save_statuses_history

transaction do
self.statuses |= LOCK_STATUSES
Expand Down Expand Up @@ -38,7 +38,7 @@ def remove_registry_lock

transaction do
LOCK_STATUSES.each do |domain_status|
delete_domain_statuses_which_not_declared_before domain_status
remove_predetermined_statuses domain_status
end
self.locked_by_registrant_at = nil
clear_locked_domain_statuses_history
Expand All @@ -60,13 +60,13 @@ def alert_registrar_lock_changes!(lock: true)

private

def put_statuses_to_json_history_before_locked
def save_statuses_history
self.locked_domain_statuses_history = statuses.map do |status|
status if LOCK_STATUSES.include? status
end
end

def delete_domain_statuses_which_not_declared_before(domain_status)
def remove_predetermined_statuses(domain_status)
statuses.delete(domain_status) unless locked_domain_statuses_history.include? domain_status
end

Expand Down

0 comments on commit ce49c01

Please sign in to comment.