diff --git a/app/controllers/admin/domains_controller.rb b/app/controllers/admin/domains_controller.rb index fe183f15f..11af1af02 100644 --- a/app/controllers/admin/domains_controller.rb +++ b/app/controllers/admin/domains_controller.rb @@ -68,7 +68,7 @@ module Admin @domain.transaction do @domain.schedule_force_delete @domain.registrar.messages.create!(body: I18n.t('force_delete_set_on_domain', domain_name: @domain.name)) - DomainDeleteForcedEmailJob.enqueue(@domain.id, params[:template_name]) + DomainDeleteForcedEmailJob.enqueue(@domain.id, params[:template_name]) if notify_by_email? end redirect_to edit_admin_domain_url(@domain), notice: t('.scheduled') @@ -132,5 +132,9 @@ module Admin def force_delete_templates %w(removed_company death) end + + def notify_by_email? + ActiveRecord::Type::Boolean.new.type_cast_from_user(params[:notify_by_email]) + end end end diff --git a/app/views/admin/domains/_force_delete_dialog.html.erb b/app/views/admin/domains/_force_delete_dialog.html.erb index 3452883f2..d5863e0de 100644 --- a/app/views/admin/domains/_force_delete_dialog.html.erb +++ b/app/views/admin/domains/_force_delete_dialog.html.erb @@ -12,6 +12,17 @@
<%= form_tag schedule_force_delete_admin_domain_path, method: :patch, id: 'domain-force-delete-form', class: 'form-horizontal' do %> +
+
+
+ +
+
+
+
diff --git a/config/locales/admin/domains.en.yml b/config/locales/admin/domains.en.yml index be26a5542..f6f51eaa4 100644 --- a/config/locales/admin/domains.en.yml +++ b/config/locales/admin/domains.en.yml @@ -14,6 +14,7 @@ en: force_delete_dialog: title: Force delete + notify_by_email: Notify registrant and administrative contacts by email template: Template close_btn: Close dialog submit_btn: Force delete domain diff --git a/test/integration/admin/domains/force_delete_test.rb b/test/integration/admin/domains/force_delete_test.rb index 838b342b7..b52547ece 100644 --- a/test/integration/admin/domains/force_delete_test.rb +++ b/test/integration/admin/domains/force_delete_test.rb @@ -1,6 +1,8 @@ require 'test_helper' class AdminAreaDomainForceDeleteTest < ActionDispatch::IntegrationTest + include ActionMailer::TestHelper + def setup login_as users(:admin) @domain = domains(:shop) @@ -19,11 +21,25 @@ class AdminAreaDomainForceDeleteTest < ActionDispatch::IntegrationTest @domain.reload assert @domain.force_delete_scheduled? - assert_equal 1, ActionMailer::Base.deliveries.size assert_current_path edit_admin_domain_path(@domain) assert_text 'Force delete procedure has been scheduled' end + def test_notifies_registrant_and_admin_contacts_by_email_by_default + assert_emails 1 do + visit edit_admin_domain_url(@domain) + click_link_or_button 'Force delete domain' + end + end + + def test_allows_to_skip_notifying_registrant_and_admin_contacts_by_email + assert_no_emails do + visit edit_admin_domain_url(@domain) + uncheck 'notify_by_email' + click_link_or_button 'Force delete domain' + end + end + def test_cancels_scheduled_domain_force_delete @domain.update_attribute(:statuses, [DomainStatus::FORCE_DELETE]) assert @domain.force_delete_scheduled?