mirror of
https://github.com/internetee/registry.git
synced 2025-06-07 21:25:39 +02:00
parent
a49b592fac
commit
b5870d3eb5
4 changed files with 34 additions and 2 deletions
|
@ -68,7 +68,7 @@ module Admin
|
||||||
@domain.transaction do
|
@domain.transaction do
|
||||||
@domain.schedule_force_delete
|
@domain.schedule_force_delete
|
||||||
@domain.registrar.messages.create!(body: I18n.t('force_delete_set_on_domain', domain_name: @domain.name))
|
@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
|
end
|
||||||
|
|
||||||
redirect_to edit_admin_domain_url(@domain), notice: t('.scheduled')
|
redirect_to edit_admin_domain_url(@domain), notice: t('.scheduled')
|
||||||
|
@ -132,5 +132,9 @@ module Admin
|
||||||
def force_delete_templates
|
def force_delete_templates
|
||||||
%w(removed_company death)
|
%w(removed_company death)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def notify_by_email?
|
||||||
|
ActiveRecord::Type::Boolean.new.type_cast_from_user(params[:notify_by_email])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,6 +12,17 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<%= form_tag schedule_force_delete_admin_domain_path, method: :patch,
|
<%= form_tag schedule_force_delete_admin_domain_path, method: :patch,
|
||||||
id: 'domain-force-delete-form', class: 'form-horizontal' do %>
|
id: 'domain-force-delete-form', class: 'form-horizontal' do %>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-9 col-md-offset-2">
|
||||||
|
<div class="checkbox">
|
||||||
|
<label>
|
||||||
|
<%= check_box_tag 'notify_by_email', 1, true %>
|
||||||
|
<%= t '.notify_by_email' %>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-2 control-label"><%= t '.template' %>:</label>
|
<label class="col-sm-2 control-label"><%= t '.template' %>:</label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
|
|
|
@ -14,6 +14,7 @@ en:
|
||||||
|
|
||||||
force_delete_dialog:
|
force_delete_dialog:
|
||||||
title: Force delete
|
title: Force delete
|
||||||
|
notify_by_email: Notify registrant and administrative contacts by email
|
||||||
template: Template
|
template: Template
|
||||||
close_btn: Close dialog
|
close_btn: Close dialog
|
||||||
submit_btn: Force delete domain
|
submit_btn: Force delete domain
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class AdminAreaDomainForceDeleteTest < ActionDispatch::IntegrationTest
|
class AdminAreaDomainForceDeleteTest < ActionDispatch::IntegrationTest
|
||||||
|
include ActionMailer::TestHelper
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
login_as users(:admin)
|
login_as users(:admin)
|
||||||
@domain = domains(:shop)
|
@domain = domains(:shop)
|
||||||
|
@ -19,11 +21,25 @@ class AdminAreaDomainForceDeleteTest < ActionDispatch::IntegrationTest
|
||||||
@domain.reload
|
@domain.reload
|
||||||
|
|
||||||
assert @domain.force_delete_scheduled?
|
assert @domain.force_delete_scheduled?
|
||||||
assert_equal 1, ActionMailer::Base.deliveries.size
|
|
||||||
assert_current_path edit_admin_domain_path(@domain)
|
assert_current_path edit_admin_domain_path(@domain)
|
||||||
assert_text 'Force delete procedure has been scheduled'
|
assert_text 'Force delete procedure has been scheduled'
|
||||||
end
|
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
|
def test_cancels_scheduled_domain_force_delete
|
||||||
@domain.update_attribute(:statuses, [DomainStatus::FORCE_DELETE])
|
@domain.update_attribute(:statuses, [DomainStatus::FORCE_DELETE])
|
||||||
assert @domain.force_delete_scheduled?
|
assert @domain.force_delete_scheduled?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue