mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 19:20:37 +02:00
Merge branch 'master' into registry-661
This commit is contained in:
commit
03b6f1df91
18 changed files with 147 additions and 224 deletions
6
.reek
6
.reek
|
@ -144,7 +144,6 @@ DuplicateMethodCall:
|
||||||
- Admin::DomainsController#build_associations
|
- Admin::DomainsController#build_associations
|
||||||
- Admin::DomainsController#index
|
- Admin::DomainsController#index
|
||||||
- Admin::DomainsController#normalize_search_parameters
|
- Admin::DomainsController#normalize_search_parameters
|
||||||
- Admin::DomainsController#schedule_force_delete
|
|
||||||
- Admin::EppLogsController#index
|
- Admin::EppLogsController#index
|
||||||
- Admin::EppLogsController#set_default_dates
|
- Admin::EppLogsController#set_default_dates
|
||||||
- Admin::LegalDocumentsController#show
|
- Admin::LegalDocumentsController#show
|
||||||
|
@ -474,7 +473,6 @@ IrresponsibleModule:
|
||||||
- Registrar::ApplicationHelper
|
- Registrar::ApplicationHelper
|
||||||
- DomainDeleteConfirmEmailJob
|
- DomainDeleteConfirmEmailJob
|
||||||
- DomainDeleteConfirmJob
|
- DomainDeleteConfirmJob
|
||||||
- DomainDeleteForcedEmailJob
|
|
||||||
- DomainDeleteJob
|
- DomainDeleteJob
|
||||||
- DomainExpireEmailJob
|
- DomainExpireEmailJob
|
||||||
- DomainUpdateConfirmJob
|
- DomainUpdateConfirmJob
|
||||||
|
@ -623,7 +621,6 @@ TooManyStatements:
|
||||||
- Admin::DomainVersionsController#show
|
- Admin::DomainVersionsController#show
|
||||||
- Admin::DomainsController#index
|
- Admin::DomainsController#index
|
||||||
- Admin::DomainsController#normalize_search_parameters
|
- Admin::DomainsController#normalize_search_parameters
|
||||||
- Admin::DomainsController#schedule_force_delete
|
|
||||||
- Admin::DomainsController#update
|
- Admin::DomainsController#update
|
||||||
- Admin::EppLogsController#index
|
- Admin::EppLogsController#index
|
||||||
- Admin::InvoicesController#create
|
- Admin::InvoicesController#create
|
||||||
|
@ -852,7 +849,6 @@ UtilityFunction:
|
||||||
- ApplicationHelper#plain_username
|
- ApplicationHelper#plain_username
|
||||||
- ApplicationHelper#unstable_env
|
- ApplicationHelper#unstable_env
|
||||||
- DomainDeleteConfirmEmailJob#logger
|
- DomainDeleteConfirmEmailJob#logger
|
||||||
- DomainDeleteForcedEmailJob#logger
|
|
||||||
- DomainExpireEmailJob#run
|
- DomainExpireEmailJob#run
|
||||||
- RegenerateRegistrarWhoisesJob#run
|
- RegenerateRegistrarWhoisesJob#run
|
||||||
- RegistrantChangeConfirmEmailJob#logger
|
- RegistrantChangeConfirmEmailJob#logger
|
||||||
|
@ -891,8 +887,6 @@ FeatureEnvy:
|
||||||
- DomainDeleteConfirmEmailJob#run
|
- DomainDeleteConfirmEmailJob#run
|
||||||
- DomainDeleteConfirmJob#raise_errors!
|
- DomainDeleteConfirmJob#raise_errors!
|
||||||
- DomainDeleteConfirmJob#run
|
- DomainDeleteConfirmJob#run
|
||||||
- DomainDeleteForcedEmailJob#log
|
|
||||||
- DomainDeleteForcedEmailJob#run
|
|
||||||
- DomainDeleteJob#run
|
- DomainDeleteJob#run
|
||||||
- DomainUpdateConfirmJob#raise_errors!
|
- DomainUpdateConfirmJob#raise_errors!
|
||||||
- DomainUpdateConfirmJob#run
|
- DomainUpdateConfirmJob#run
|
||||||
|
|
13
app/assets/javascripts/admin/domains/force_delete.js
Normal file
13
app/assets/javascripts/admin/domains/force_delete.js
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
(function() {
|
||||||
|
let container = document.querySelector('.domain-edit-force-delete-dialog');
|
||||||
|
let toggle = container.querySelector('[data-dependent-content-toggle]');
|
||||||
|
let dependentContent = container.querySelector('.email-template-row');
|
||||||
|
|
||||||
|
if (!toggle) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
toggle.addEventListener('change', function() {
|
||||||
|
dependentContent.hidden = !this.checked;
|
||||||
|
});
|
||||||
|
})();
|
39
app/controllers/admin/domains/force_delete_controller.rb
Normal file
39
app/controllers/admin/domains/force_delete_controller.rb
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
module Admin
|
||||||
|
module Domains
|
||||||
|
class ForceDeleteController < BaseController
|
||||||
|
def create
|
||||||
|
authorize! :manage, domain
|
||||||
|
|
||||||
|
domain.transaction do
|
||||||
|
domain.schedule_force_delete
|
||||||
|
domain.registrar.messages.create!(body: t('force_delete_set_on_domain', domain_name: domain.name))
|
||||||
|
|
||||||
|
if notify_by_email?
|
||||||
|
DomainDeleteMailer.forced(domain: domain,
|
||||||
|
registrar: domain.registrar,
|
||||||
|
registrant: domain.registrant,
|
||||||
|
template_name: params[:template_name]).deliver_now
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
redirect_to edit_admin_domain_url(domain), notice: t('.scheduled')
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
authorize! :manage, domain
|
||||||
|
domain.cancel_force_delete
|
||||||
|
redirect_to edit_admin_domain_url(domain), notice: t('.cancelled')
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def domain
|
||||||
|
@domain ||= Domain.find(params[:domain_id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def notify_by_email?
|
||||||
|
ActiveRecord::Type::Boolean.new.type_cast_from_user(params[:notify_by_email])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -62,28 +62,6 @@ module Admin
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def schedule_force_delete
|
|
||||||
raise 'Template param cannot be empty' if params[:template_name].blank?
|
|
||||||
|
|
||||||
@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])
|
|
||||||
end
|
|
||||||
|
|
||||||
redirect_to edit_admin_domain_path(@domain), notice: t('.scheduled')
|
|
||||||
end
|
|
||||||
|
|
||||||
def cancel_force_delete
|
|
||||||
if @domain.cancel_force_delete
|
|
||||||
flash[:notice] = t('.cancelled')
|
|
||||||
else
|
|
||||||
flash.now[:alert] = I18n.t('failed_to_update_domain')
|
|
||||||
end
|
|
||||||
|
|
||||||
redirect_to edit_admin_domain_path(@domain)
|
|
||||||
end
|
|
||||||
|
|
||||||
def versions
|
def versions
|
||||||
@domain = Domain.where(id: params[:domain_id]).includes({ versions: :item }).first
|
@domain = Domain.where(id: params[:domain_id]).includes({ versions: :item }).first
|
||||||
@versions = @domain.versions
|
@versions = @domain.versions
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
class DomainDeleteForcedEmailJob < Que::Job
|
|
||||||
def run(domain_id, template_name)
|
|
||||||
domain = Domain.find(domain_id)
|
|
||||||
|
|
||||||
log(domain)
|
|
||||||
DomainDeleteMailer.forced(domain: domain,
|
|
||||||
registrar: domain.registrar,
|
|
||||||
registrant: domain.registrant,
|
|
||||||
template_name: template_name).deliver_now
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def log(domain)
|
|
||||||
message = "Send DomainDeleteMailer#forced email for domain #{domain.name} (##{domain.id})" \
|
|
||||||
" to #{domain.primary_contact_emails.join(', ')}"
|
|
||||||
logger.info(message)
|
|
||||||
end
|
|
||||||
|
|
||||||
def logger
|
|
||||||
Rails.logger
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -41,7 +41,7 @@ class DomainPresenter
|
||||||
def force_delete_toggle_btn
|
def force_delete_toggle_btn
|
||||||
if !domain.force_delete_scheduled?
|
if !domain.force_delete_scheduled?
|
||||||
view.content_tag(:a, view.t('admin.domains.force_delete_toggle_btn.schedule'),
|
view.content_tag(:a, view.t('admin.domains.force_delete_toggle_btn.schedule'),
|
||||||
class: 'btn btn-danger',
|
class: 'btn btn-default',
|
||||||
data: {
|
data: {
|
||||||
toggle: 'modal',
|
toggle: 'modal',
|
||||||
target: '.domain-edit-force-delete-dialog',
|
target: '.domain-edit-force-delete-dialog',
|
||||||
|
@ -49,9 +49,9 @@ class DomainPresenter
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
view.link_to(view.t('admin.domains.force_delete_toggle_btn.cancel'),
|
view.link_to(view.t('admin.domains.force_delete_toggle_btn.cancel'),
|
||||||
view.cancel_force_delete_admin_domain_path(domain),
|
view.admin_domain_force_delete_path(domain),
|
||||||
method: :patch,
|
method: :delete,
|
||||||
data: { confirm: view.t('admin.domains.force_delete_toggle_btn.cancel_confim') },
|
data: { confirm: view.t('admin.domains.force_delete_toggle_btn.cancel_confirm') },
|
||||||
class: 'btn btn-primary')
|
class: 'btn btn-primary')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,19 +8,27 @@
|
||||||
<h4 class="modal-title"><%= t '.title' %></h4>
|
<h4 class="modal-title"><%= t '.title' %></h4>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="modal-body">
|
<%= form_tag admin_domain_force_delete_path(domain), id: 'domain-force-delete-form',
|
||||||
<div class="row">
|
class: 'modal-body form-horizontal' do %>
|
||||||
<%= form_tag schedule_force_delete_admin_domain_path, method: :patch,
|
|
||||||
id: 'domain-force-delete-form', class: 'form-horizontal' do %>
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-2 control-label"><%= t '.template' %>:</label>
|
<div class="col-md-9">
|
||||||
<div class="col-sm-9">
|
<div class="checkbox">
|
||||||
|
<label>
|
||||||
|
<%= check_box_tag 'notify_by_email', 1, true,
|
||||||
|
data: { dependent_content_toggle: true } %>
|
||||||
|
<%= t '.notify_by_email' %>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group email-template-row">
|
||||||
|
<label class="col-md-3 control-label"><%= t '.email_template' %></label>
|
||||||
|
<div class="col-md-9">
|
||||||
<%= select_tag 'template_name', options_for_select(templates), class: 'form-control' %>
|
<%= select_tag 'template_name', options_for_select(templates), class: 'form-control' %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-default" data-dismiss="modal"><%= t '.close_btn' %></button>
|
<button type="button" class="btn btn-default" data-dismiss="modal"><%= t '.close_btn' %></button>
|
||||||
|
|
|
@ -17,4 +17,4 @@
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<%= render 'form' %>
|
<%= render 'form' %>
|
||||||
<%= render 'force_delete_dialog', templates: force_delete_templates %>
|
<%= render 'force_delete_dialog', domain: @domain, templates: force_delete_templates %>
|
||||||
|
|
|
@ -14,16 +14,11 @@ en:
|
||||||
|
|
||||||
force_delete_dialog:
|
force_delete_dialog:
|
||||||
title: Force delete
|
title: Force delete
|
||||||
template: Template
|
notify_by_email: Notify registrant and administrative contacts by email
|
||||||
|
email_template: Email template
|
||||||
close_btn: Close dialog
|
close_btn: Close dialog
|
||||||
submit_btn: Force delete domain
|
submit_btn: Force delete domain
|
||||||
|
|
||||||
schedule_force_delete:
|
|
||||||
scheduled: Force delete procedure has been scheduled
|
|
||||||
|
|
||||||
cancel_force_delete:
|
|
||||||
cancelled: Force delete procedure has been cancelled
|
|
||||||
|
|
||||||
versions:
|
versions:
|
||||||
time: Time
|
time: Time
|
||||||
registrant: Registrant
|
registrant: Registrant
|
||||||
|
@ -48,4 +43,4 @@ en:
|
||||||
force_delete_toggle_btn:
|
force_delete_toggle_btn:
|
||||||
schedule: Schedule force delete
|
schedule: Schedule force delete
|
||||||
cancel: Cancel force delete
|
cancel: Cancel force delete
|
||||||
cancel_confim: Are you sure you want cancel force delete procedure?
|
cancel_confirm: Are you sure you want cancel force delete procedure?
|
||||||
|
|
9
config/locales/admin/domains/force_delete.en.yml
Normal file
9
config/locales/admin/domains/force_delete.en.yml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
en:
|
||||||
|
admin:
|
||||||
|
domains:
|
||||||
|
force_delete:
|
||||||
|
create:
|
||||||
|
scheduled: Force delete procedure has been scheduled
|
||||||
|
|
||||||
|
destroy:
|
||||||
|
cancelled: Force delete procedure has been cancelled
|
|
@ -297,16 +297,12 @@ en:
|
||||||
add_another: 'Add another'
|
add_another: 'Add another'
|
||||||
domain_updated: 'Domain updated!'
|
domain_updated: 'Domain updated!'
|
||||||
failed_to_update_domain: 'Failed to update domain'
|
failed_to_update_domain: 'Failed to update domain'
|
||||||
failed_to_create_contact: 'Failed to create contact'
|
|
||||||
contact_deleted: 'Contact deleted'
|
|
||||||
failed_to_delete_contact: 'Failed to delete contact'
|
|
||||||
edit_contact: 'Edit contact'
|
edit_contact: 'Edit contact'
|
||||||
failed_to_update_contact: 'Failed to update contact'
|
failed_to_update_contact: 'Failed to update contact'
|
||||||
contact_updated: 'Contact updated'
|
contact_updated: 'Contact updated'
|
||||||
search: 'Search'
|
search: 'Search'
|
||||||
reg_no: 'Reg. no'
|
reg_no: 'Reg. no'
|
||||||
status: 'Status'
|
status: 'Status'
|
||||||
eedirekt: 'EEDirekt'
|
|
||||||
contact: 'Contact'
|
contact: 'Contact'
|
||||||
credit_balance: 'Credit balance'
|
credit_balance: 'Credit balance'
|
||||||
starting_balance: 'Starting balance'
|
starting_balance: 'Starting balance'
|
||||||
|
@ -317,8 +313,6 @@ en:
|
||||||
|
|
||||||
welcome: 'Welcome!'
|
welcome: 'Welcome!'
|
||||||
edit_statuses: 'Edit statuses'
|
edit_statuses: 'Edit statuses'
|
||||||
contact_list: 'Contact list'
|
|
||||||
create_new_contact: 'Create new contact'
|
|
||||||
history: 'History'
|
history: 'History'
|
||||||
|
|
||||||
new_registrar: 'New registrar'
|
new_registrar: 'New registrar'
|
||||||
|
@ -331,14 +325,11 @@ en:
|
||||||
|
|
||||||
users: 'Users'
|
users: 'Users'
|
||||||
user_details: 'User details'
|
user_details: 'User details'
|
||||||
edit_user: 'Edit user'
|
|
||||||
back_to_user: 'Back to user'
|
back_to_user: 'Back to user'
|
||||||
|
|
||||||
certificate_signing_req: 'Certificate signing request'
|
certificate_signing_req: 'Certificate signing request'
|
||||||
csr: 'CSR'
|
csr: 'CSR'
|
||||||
crt: 'CRT'
|
crt: 'CRT'
|
||||||
api_user_details: 'API user details'
|
|
||||||
edit_api_user: 'Edit API user'
|
|
||||||
back_to_api_user: 'Back to API user'
|
back_to_api_user: 'Back to API user'
|
||||||
|
|
||||||
dnskey: 'DNS key'
|
dnskey: 'DNS key'
|
||||||
|
@ -359,16 +350,12 @@ en:
|
||||||
|
|
||||||
transfer_requested: 'Transfer requested.'
|
transfer_requested: 'Transfer requested.'
|
||||||
message_was_not_found: 'Message was not found'
|
message_was_not_found: 'Message was not found'
|
||||||
host_obj_is_not_allowed: 'hostObj object is not allowed'
|
|
||||||
zonefile: 'Zonefile'
|
zonefile: 'Zonefile'
|
||||||
only_one_parameter_allowed: 'Only one parameter allowed: %{param_1} or %{param_2}'
|
only_one_parameter_allowed: 'Only one parameter allowed: %{param_1} or %{param_2}'
|
||||||
exactly_one_parameter_required: 'Exactly one parameter required: %{params}'
|
exactly_one_parameter_required: 'Exactly one parameter required: %{params}'
|
||||||
required_parameter_missing_choice: 'Required parameter missing: %{param_1} or %{param_2}'
|
|
||||||
ds_data_with_key_allowed: 'Allow DS data with key'
|
ds_data_with_key_allowed: 'Allow DS data with key'
|
||||||
key_data_allowed: 'Allow key data'
|
key_data_allowed: 'Allow key data'
|
||||||
ds_digest_type: 'DS digest type'
|
ds_digest_type: 'DS digest type'
|
||||||
background_jobs: Background jobs
|
|
||||||
domains_history: Domains history
|
|
||||||
role: 'Role'
|
role: 'Role'
|
||||||
user: 'User'
|
user: 'User'
|
||||||
customer_service: 'Customer service'
|
customer_service: 'Customer service'
|
||||||
|
@ -387,7 +374,6 @@ en:
|
||||||
admin_contacts_max_count: 'Admin contacts maximum count'
|
admin_contacts_max_count: 'Admin contacts maximum count'
|
||||||
tech_contacts_min_count: 'Tech contacts minimum count'
|
tech_contacts_min_count: 'Tech contacts minimum count'
|
||||||
tech_contacts_max_count: 'Tech contacts maximum count'
|
tech_contacts_max_count: 'Tech contacts maximum count'
|
||||||
action_failed_due_to_server_error: 'Action failed due to server error'
|
|
||||||
transfer_can_be_rejected_only_by_current_registrar: 'Transfer can be rejected only by current registrar'
|
transfer_can_be_rejected_only_by_current_registrar: 'Transfer can be rejected only by current registrar'
|
||||||
request_command: 'Request command'
|
request_command: 'Request command'
|
||||||
request_object: 'Request object'
|
request_object: 'Request object'
|
||||||
|
@ -441,8 +427,6 @@ en:
|
||||||
sim_error: 'SIM application error'
|
sim_error: 'SIM application error'
|
||||||
internal_error: 'Internal error'
|
internal_error: 'Internal error'
|
||||||
client_side_status_editing_error: 'Parameter value policy error. Client-side object status management not supported'
|
client_side_status_editing_error: 'Parameter value policy error. Client-side object status management not supported'
|
||||||
switch_to: Switch to
|
|
||||||
admin_menu: Admin
|
|
||||||
business_registry_service_not_available: "Business Registry service Ärireg is not available"
|
business_registry_service_not_available: "Business Registry service Ärireg is not available"
|
||||||
|
|
||||||
# DEPP
|
# DEPP
|
||||||
|
|
|
@ -204,11 +204,7 @@ Rails.application.routes.draw do
|
||||||
resources :domain_versions, controller: 'domains', action: 'versions'
|
resources :domain_versions, controller: 'domains', action: 'versions'
|
||||||
resources :pending_updates
|
resources :pending_updates
|
||||||
resources :pending_deletes
|
resources :pending_deletes
|
||||||
|
resource :force_delete, controller: 'domains/force_delete', only: %i[create destroy]
|
||||||
member do
|
|
||||||
patch 'schedule_force_delete'
|
|
||||||
patch 'cancel_force_delete'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :domain_versions do
|
resources :domain_versions do
|
||||||
|
|
|
@ -11,11 +11,6 @@ FactoryBot.define do
|
||||||
domain.tech_domain_contacts << FactoryBot.build(:tech_domain_contact)
|
domain.tech_domain_contacts << FactoryBot.build(:tech_domain_contact)
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :domain_without_force_delete do
|
|
||||||
force_delete_time nil
|
|
||||||
statuses []
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :domain_discarded do
|
factory :domain_discarded do
|
||||||
statuses [DomainStatus::DELETE_CANDIDATE]
|
statuses [DomainStatus::DELETE_CANDIDATE]
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.feature 'Force delete' do
|
|
||||||
context 'when domain has no force delete procedure' do
|
|
||||||
given!(:domain) { create(:domain_without_force_delete) }
|
|
||||||
|
|
||||||
scenario 'schedule' do
|
|
||||||
sign_in_to_admin_area
|
|
||||||
|
|
||||||
visit edit_admin_domain_url(domain)
|
|
||||||
click_link_or_button 'Force delete domain'
|
|
||||||
|
|
||||||
expect(page).to have_text('Force delete procedure has been scheduled')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when domain has force delete procedure' do
|
|
||||||
given!(:domain) { create(:domain_without_force_delete) }
|
|
||||||
|
|
||||||
background do
|
|
||||||
domain.schedule_force_delete
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'cancel' do
|
|
||||||
sign_in_to_admin_area
|
|
||||||
|
|
||||||
visit edit_admin_domain_url(domain)
|
|
||||||
click_link_or_button 'Cancel force delete'
|
|
||||||
|
|
||||||
expect(page).to have_text('Force delete procedure has been cancelled')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,42 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe DomainDeleteForcedEmailJob do
|
|
||||||
describe '#run' do
|
|
||||||
let(:domain) { instance_double(Domain) }
|
|
||||||
let(:message) { instance_double(ActionMailer::MessageDelivery) }
|
|
||||||
|
|
||||||
before :example do
|
|
||||||
expect(Domain).to receive(:find).and_return(domain)
|
|
||||||
allow(domain).to receive_messages(
|
|
||||||
id: 1,
|
|
||||||
name: 'test.com',
|
|
||||||
registrar: 'registrar',
|
|
||||||
registrant: 'registrant',
|
|
||||||
primary_contact_emails: %w(test@test.com test@test.com))
|
|
||||||
end
|
|
||||||
|
|
||||||
after :example do
|
|
||||||
domain_id = 1
|
|
||||||
template_name = 'removed_company'
|
|
||||||
described_class.enqueue(domain_id, template_name)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'creates log record' do
|
|
||||||
log_message = 'Send DomainDeleteMailer#forced email for domain test.com (#1) to test@test.com, test@test.com'
|
|
||||||
|
|
||||||
allow(DomainDeleteMailer).to receive(:forced).and_return(message)
|
|
||||||
allow(message).to receive(:deliver_now)
|
|
||||||
|
|
||||||
expect(Rails.logger).to receive(:info).with(log_message)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'sends email' do
|
|
||||||
expect(DomainDeleteMailer).to receive(:forced).with(domain: domain,
|
|
||||||
registrar: 'registrar',
|
|
||||||
registrant: 'registrant',
|
|
||||||
template_name: 'removed_company')
|
|
||||||
.and_return(message)
|
|
||||||
expect(message).to receive(:deliver_now)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -114,41 +114,6 @@ RSpec.describe DomainPresenter do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#force_delete_toggle_btn' do
|
|
||||||
let(:domain) { build_stubbed(:domain) }
|
|
||||||
|
|
||||||
context 'when force delete is not scheduled' do
|
|
||||||
before :example do
|
|
||||||
expect(domain).to receive(:force_delete_scheduled?).and_return(false)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns schedule button' do
|
|
||||||
html = view.content_tag(:a, 'Schedule force delete',
|
|
||||||
class: 'btn btn-danger',
|
|
||||||
data: {
|
|
||||||
toggle: 'modal',
|
|
||||||
target: '.domain-edit-force-delete-dialog',
|
|
||||||
})
|
|
||||||
expect(presenter.force_delete_toggle_btn).to eq(html)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when force delete is scheduled' do
|
|
||||||
before :example do
|
|
||||||
expect(domain).to receive(:force_delete_scheduled?).and_return(true)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns cancel button' do
|
|
||||||
html = link_to('Cancel force delete',
|
|
||||||
view.cancel_force_delete_admin_domain_path(domain),
|
|
||||||
method: :patch,
|
|
||||||
data: { confirm: 'Are you sure you want cancel force delete procedure?' },
|
|
||||||
class: 'btn btn-primary')
|
|
||||||
expect(presenter.force_delete_toggle_btn).to eq(html)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
domain_delegatable_attributes = %i(
|
domain_delegatable_attributes = %i(
|
||||||
name
|
name
|
||||||
transfer_code
|
transfer_code
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe Admin::DomainsController do
|
|
||||||
describe 'routing' do
|
|
||||||
it 'routes to #schedule_force_delete' do
|
|
||||||
expect(patch: '/admin/domains/1/schedule_force_delete').to route_to('admin/domains#schedule_force_delete', id: '1')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'routes to #cancel_force_delete' do
|
|
||||||
expect(patch: '/admin/domains/1/cancel_force_delete').to route_to('admin/domains#cancel_force_delete', id: '1')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
58
test/integration/admin/domains/force_delete_test.rb
Normal file
58
test/integration/admin/domains/force_delete_test.rb
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class AdminAreaDomainForceDeleteTest < ActionDispatch::IntegrationTest
|
||||||
|
include ActionMailer::TestHelper
|
||||||
|
|
||||||
|
def setup
|
||||||
|
login_as users(:admin)
|
||||||
|
@domain = domains(:shop)
|
||||||
|
ActionMailer::Base.deliveries.clear
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_schedules_domain_force_delete
|
||||||
|
refute @domain.force_delete_scheduled?
|
||||||
|
|
||||||
|
visit edit_admin_domain_url(@domain)
|
||||||
|
click_link_or_button 'Force delete domain'
|
||||||
|
@domain.reload
|
||||||
|
|
||||||
|
assert @domain.force_delete_scheduled?
|
||||||
|
assert_current_path edit_admin_domain_path(@domain)
|
||||||
|
assert_text 'Force delete procedure has been scheduled'
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_notifies_registrar
|
||||||
|
assert_difference '@domain.registrar.messages.size' do
|
||||||
|
visit edit_admin_domain_url(@domain)
|
||||||
|
click_link_or_button 'Force delete domain'
|
||||||
|
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
|
||||||
|
@domain.update_attribute(:statuses, [DomainStatus::FORCE_DELETE])
|
||||||
|
assert @domain.force_delete_scheduled?
|
||||||
|
|
||||||
|
visit edit_admin_domain_url(@domain)
|
||||||
|
click_link_or_button 'Cancel force delete'
|
||||||
|
@domain.reload
|
||||||
|
|
||||||
|
refute @domain.force_delete_scheduled?
|
||||||
|
assert_current_path edit_admin_domain_path(@domain)
|
||||||
|
assert_text 'Force delete procedure has been cancelled'
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue