mirror of
https://github.com/internetee/registry.git
synced 2025-06-05 04:07:33 +02:00
Inherit all the interactors from base one
This commit is contained in:
parent
f97dff6002
commit
3c7fa88463
11 changed files with 35 additions and 47 deletions
|
@ -1,16 +1,13 @@
|
|||
class Domain
|
||||
module ForceDeleteInteractor
|
||||
class Base
|
||||
include Interactor::Organizer
|
||||
include Interactor
|
||||
|
||||
# As per https://github.com/collectiveidea/interactor#organizers
|
||||
private
|
||||
|
||||
organize Domain::ForceDeleteInteractor::CheckDiscarded,
|
||||
Domain::ForceDeleteInteractor::PrepareDomain,
|
||||
Domain::ForceDeleteInteractor::SetStatus,
|
||||
Domain::ForceDeleteInteractor::PostSetProcess,
|
||||
Domain::ForceDeleteInteractor::NotifyRegistrar,
|
||||
Domain::ForceDeleteInteractor::NotifyByEmail
|
||||
def domain
|
||||
@domain ||= context.domain
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
class Domain
|
||||
module ForceDeleteInteractor
|
||||
class CheckDiscarded
|
||||
include Interactor
|
||||
|
||||
class CheckDiscarded < Base
|
||||
def call
|
||||
return unless context.domain.discarded?
|
||||
return unless domain.discarded?
|
||||
|
||||
message = 'Force delete procedure cannot be scheduled while a domain is discarded'
|
||||
context.fail!(message: message)
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
class Domain
|
||||
module ForceDeleteInteractor
|
||||
class NotifyByEmail
|
||||
include Interactor
|
||||
|
||||
class NotifyByEmail < Base
|
||||
def call
|
||||
return unless context.notify_by_email
|
||||
|
||||
|
@ -14,12 +12,6 @@ class Domain
|
|||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def domain
|
||||
@domain ||= context.domain
|
||||
end
|
||||
|
||||
def send_email
|
||||
DomainDeleteMailer.forced(domain: domain,
|
||||
registrar: domain.registrar,
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
class Domain
|
||||
module ForceDeleteInteractor
|
||||
class NotifyRegistrar
|
||||
include Interactor
|
||||
|
||||
class NotifyRegistrar < Base
|
||||
def call
|
||||
domain = context.domain
|
||||
|
||||
domain.registrar.notifications.create!(text: I18n.t('force_delete_set_on_domain',
|
||||
domain_name: domain.name,
|
||||
outzone_date: domain.outzone_date,
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
class Domain
|
||||
module ForceDeleteInteractor
|
||||
class PostSetProcess
|
||||
include Interactor
|
||||
|
||||
class PostSetProcess < Base
|
||||
def call
|
||||
statuses = context.domain.statuses
|
||||
statuses = domain.statuses
|
||||
# Stop all pending actions
|
||||
statuses.delete(DomainStatus::PENDING_UPDATE)
|
||||
statuses.delete(DomainStatus::PENDING_TRANSFER)
|
||||
|
@ -14,7 +12,7 @@ class Domain
|
|||
# Allow deletion
|
||||
statuses.delete(DomainStatus::CLIENT_DELETE_PROHIBITED)
|
||||
statuses.delete(DomainStatus::SERVER_DELETE_PROHIBITED)
|
||||
context.domain.save(validate: false)
|
||||
domain.save(validate: false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
class Domain
|
||||
module ForceDeleteInteractor
|
||||
class PrepareDomain
|
||||
include Interactor
|
||||
|
||||
class PrepareDomain < Base
|
||||
STATUSES_TO_SET = [DomainStatus::FORCE_DELETE,
|
||||
DomainStatus::SERVER_RENEW_PROHIBITED,
|
||||
DomainStatus::SERVER_TRANSFER_PROHIBITED].freeze
|
||||
|
||||
def call
|
||||
domain = context.domain
|
||||
domain.statuses_before_force_delete = domain.statuses
|
||||
domain.statuses |= STATUSES_TO_SET
|
||||
domain.save(validate: false)
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
class Domain
|
||||
module ForceDeleteInteractor
|
||||
class SetForceDelete
|
||||
include Interactor::Organizer
|
||||
|
||||
# As per https://github.com/collectiveidea/interactor#organizers
|
||||
|
||||
organize Domain::ForceDeleteInteractor::CheckDiscarded,
|
||||
Domain::ForceDeleteInteractor::PrepareDomain,
|
||||
Domain::ForceDeleteInteractor::SetStatus,
|
||||
Domain::ForceDeleteInteractor::PostSetProcess,
|
||||
Domain::ForceDeleteInteractor::NotifyRegistrar,
|
||||
Domain::ForceDeleteInteractor::NotifyByEmail
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,18 +1,12 @@
|
|||
class Domain
|
||||
module ForceDeleteInteractor
|
||||
class SetStatus
|
||||
include Interactor
|
||||
|
||||
class SetStatus < Base
|
||||
def call
|
||||
domain.force_delete_type = context.type
|
||||
context.type == :fast_track ? force_delete_fast_track : force_delete_soft
|
||||
domain.save(validate: false)
|
||||
end
|
||||
|
||||
def domain
|
||||
@domain ||= context.domain
|
||||
end
|
||||
|
||||
def force_delete_fast_track
|
||||
domain.force_delete_date = Time.zone.today +
|
||||
expire_warning_period_days +
|
||||
|
|
|
@ -53,9 +53,9 @@ module Concerns::Domain::ForceDelete # rubocop:disable Metrics/ModuleLength
|
|||
end
|
||||
|
||||
def schedule_force_delete(type: :fast_track, notify_by_email: false)
|
||||
Domain::ForceDeleteInteractor::Base.call(domain: self,
|
||||
type: type,
|
||||
notify_by_email: notify_by_email)
|
||||
Domain::ForceDeleteInteractor::SetForceDelete.call(domain: self,
|
||||
type: type,
|
||||
notify_by_email: notify_by_email)
|
||||
end
|
||||
|
||||
def clear_force_delete_data
|
||||
|
|
|
@ -111,7 +111,7 @@ class NewDomainForceDeleteTest < ActiveSupport::TestCase
|
|||
|
||||
def test_force_delete_cannot_be_scheduled_when_a_domain_is_discarded
|
||||
@domain.update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
||||
context = Domain::ForceDeleteInteractor::Base.call(domain: @domain, type: :fast_track)
|
||||
context = Domain::ForceDeleteInteractor::SetForceDelete.call(domain: @domain, type: :fast_track)
|
||||
|
||||
assert_not context.success?
|
||||
assert_equal 'Force delete procedure cannot be scheduled while a domain is discarded', context.message
|
||||
|
|
|
@ -414,7 +414,7 @@ class DomainTest < ActiveSupport::TestCase
|
|||
force_delete_date: nil)
|
||||
@domain.update(template_name: 'legal_person')
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
Domain::ForceDeleteInteractor::Base.call(domain: @domain, type: :fast_track)
|
||||
Domain::ForceDeleteInteractor::SetForceDelete.call(domain: @domain, type: :fast_track)
|
||||
assert(@domain.force_delete_scheduled?)
|
||||
other_registrant = Registrant.find_by(code: 'jane-001')
|
||||
@domain.pending_json['new_registrant_id'] = other_registrant.id
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue