From 5d5c2ed925edc58b257c220cb9cf0ede2b854190 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Fri, 10 May 2019 14:48:32 +0300 Subject: [PATCH] Notify registrar about domain deletion when auction feature is on Fixes #1196 --- app/models/concerns/domain/releasable.rb | 3 +++ test/models/domain/releasable/auctionable_test.rb | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/app/models/concerns/domain/releasable.rb b/app/models/concerns/domain/releasable.rb index 560d5a91fb..4aa5faa589 100644 --- a/app/models/concerns/domain/releasable.rb +++ b/app/models/concerns/domain/releasable.rb @@ -42,6 +42,9 @@ def release transaction do domain_name.sell_at_auction if domain_name.auctionable? destroy! + registrar.notifications.create!(text: "#{I18n.t(:domain_deleted)}: #{name}", + attached_obj_id: id, + attached_obj_type: self.class) end else discard diff --git a/test/models/domain/releasable/auctionable_test.rb b/test/models/domain/releasable/auctionable_test.rb index 3af0049dcf..c78a148bc4 100644 --- a/test/models/domain/releasable/auctionable_test.rb +++ b/test/models/domain/releasable/auctionable_test.rb @@ -58,6 +58,15 @@ def test_deletes_registered_domain end end + def test_notifies_registrar + @domain.update!(delete_date: '2010-07-04') + travel_to Time.zone.parse('2010-07-05') + + assert_difference -> { @domain.registrar.notifications.count } do + Domain.release_domains + end + end + def test_ignores_domains_with_delete_date_in_the_future @domain.update!(delete_date: '2010-07-06') travel_to Time.zone.parse('2010-07-05')