diff --git a/app/interactions/domain_delete_interaction/delete.rb b/app/interactions/domain_delete_interaction/delete.rb index 181431ca1..1a74aae50 100644 --- a/app/interactions/domain_delete_interaction/delete.rb +++ b/app/interactions/domain_delete_interaction/delete.rb @@ -1,11 +1,11 @@ module DomainDeleteInteraction - class Delete < :Base + class Delete < Base def execute ::PaperTrail.request.whodunnit = "interaction - #{self.class.name}" WhoisRecord.where(domain_id: domain.id).destroy_all domain.destroy - compose(NotifyRegistrar, inputs) + compose(DomainDeleteInteraction::NotifyRegistrar, inputs) end end end diff --git a/app/interactions/domain_delete_interaction/nofity_registrar.rb b/app/interactions/domain_delete_interaction/notify_registrar.rb similarity index 90% rename from app/interactions/domain_delete_interaction/nofity_registrar.rb rename to app/interactions/domain_delete_interaction/notify_registrar.rb index 81a66e6b0..990f74de6 100644 --- a/app/interactions/domain_delete_interaction/nofity_registrar.rb +++ b/app/interactions/domain_delete_interaction/notify_registrar.rb @@ -1,5 +1,5 @@ module DomainDeleteInteraction - class NotifyRegistrar < Delete + class NotifyRegistrar < Base def execute bye_bye = domain.versions.last domain.registrar.notifications.create!( diff --git a/app/jobs/domain_delete_job.rb b/app/jobs/domain_delete_job.rb index a41a27f05..49ef23aa3 100644 --- a/app/jobs/domain_delete_job.rb +++ b/app/jobs/domain_delete_job.rb @@ -4,15 +4,5 @@ class DomainDeleteJob < Que::Job domain = Domain.find(domain_id) DomainDeleteInteraction::Delete.run(domain: domain) - # ::PaperTrail.request.whodunnit = "job - #{self.class.name}" - # WhoisRecord.where(domain_id: domain.id).destroy_all - # - # domain.destroy - # bye_bye = domain.versions.last - # domain.registrar.notifications.create!( - # text: "#{I18n.t(:domain_deleted)}: #{domain.name}", - # attached_obj_id: bye_bye.id, - # attached_obj_type: bye_bye.class.to_s - # ) end end diff --git a/test/interactions/domain_delete_interaction/domain_delete_interaction_delete_test.rb b/test/interactions/domain_delete_interaction/domain_delete_interaction_delete_test.rb new file mode 100644 index 000000000..a44140b34 --- /dev/null +++ b/test/interactions/domain_delete_interaction/domain_delete_interaction_delete_test.rb @@ -0,0 +1,25 @@ +require 'test_helper' + +class DomainDeleteInteractionDeleteTest < ActiveSupport::TestCase + setup do + @domain = domains(:shop) + end + + def test_discards_domains_with_past_delete_date + @domain.update!(delete_date: '2010-07-04') + travel_to Time.zone.parse('2010-07-05') + + DomainDeleteInteraction::Delete.run(domain: @domain) + + assert @domain.destroyed? + end + + def test_sends_notification + @domain.update!(delete_date: '2010-07-04') + travel_to Time.zone.parse('2010-07-05') + + assert_difference '@domain.registrar.notifications.count', 1 do + DomainDeleteInteraction::Delete.run(domain: @domain) + end + end +end