mirror of
https://github.com/internetee/registry.git
synced 2025-06-11 23:24:48 +02:00
Merge pull request #2232 from internetee/2218-fd-prohibit-settings-serverdeleteprohibited
ForceDelete prohibit settings serverDeleteProhibited
This commit is contained in:
commit
ee1c7303e1
3 changed files with 37 additions and 2 deletions
|
@ -3,6 +3,7 @@ module Admin
|
|||
before_action :set_domain, only: %i[show edit update keep]
|
||||
authorize_resource
|
||||
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
def index
|
||||
params[:q] ||= {}
|
||||
domains = if params[:statuses_contains]
|
||||
|
@ -30,6 +31,7 @@ module Admin
|
|||
|
||||
render_by_format('admin/domains/index', 'domains')
|
||||
end
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
|
||||
def show
|
||||
# Validation is needed to warn users
|
||||
|
@ -40,7 +42,9 @@ module Admin
|
|||
build_associations
|
||||
end
|
||||
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
def update
|
||||
rollback_history = @domain.json_statuses_history&.[]('admin_store_statuses_history')
|
||||
dp = ignore_empty_statuses
|
||||
@domain.is_admin = true
|
||||
@domain.admin_status_update dp[:statuses]
|
||||
|
@ -49,11 +53,14 @@ module Admin
|
|||
flash[:notice] = I18n.t('domain_updated')
|
||||
redirect_to [:admin, @domain]
|
||||
else
|
||||
@domain.reload
|
||||
@domain.admin_status_update rollback_history
|
||||
build_associations
|
||||
flash.now[:alert] = "#{I18n.t('failed_to_update_domain')} #{@domain.errors.full_messages.join(', ')}"
|
||||
render 'edit'
|
||||
end
|
||||
end
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
|
||||
def versions
|
||||
@domain = Domain.where(id: params[:domain_id]).includes({ versions: :item }).first
|
||||
|
|
|
@ -121,8 +121,8 @@ class Domain < ApplicationRecord
|
|||
validate :status_is_consistant
|
||||
def status_is_consistant
|
||||
has_error = (hold_status? && statuses.include?(DomainStatus::SERVER_MANUAL_INZONE))
|
||||
if !has_error && (statuses & DELETE_STATUSES).any?
|
||||
has_error = statuses.include? DomainStatus::SERVER_DELETE_PROHIBITED unless locked_by_registrant?
|
||||
if !has_error && statuses.include?(DomainStatus::PENDING_DELETE)
|
||||
has_error = statuses.include? DomainStatus::SERVER_DELETE_PROHIBITED
|
||||
end
|
||||
errors.add(:domains, I18n.t(:object_status_prohibits_operation)) if has_error
|
||||
end
|
||||
|
@ -592,6 +592,8 @@ class Domain < ApplicationRecord
|
|||
def admin_status_update(update)
|
||||
update_unless_locked_by_registrant(update)
|
||||
update_not_by_locked_statuses(update)
|
||||
return unless update
|
||||
|
||||
# check for deleted status
|
||||
statuses.each do |s|
|
||||
unless update.include? s
|
||||
|
|
|
@ -21,6 +21,32 @@ class AdminAreaDomainForceDeleteTest < ApplicationSystemTestCase
|
|||
assert_text 'Force delete procedure has been scheduled'
|
||||
end
|
||||
|
||||
def test_force_delete_prohibit_adding_deleteprohibited_status
|
||||
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'
|
||||
|
||||
click_link_or_button 'Add new status'
|
||||
last_input = page.all(:id, 'domain_statuses_').last
|
||||
last_input.find(:xpath, 'option[10]').select_option
|
||||
click_link_or_button 'Save'
|
||||
assert_text 'Domain updated!'
|
||||
|
||||
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
|
||||
|
||||
def test_notifies_registrar
|
||||
assert_difference '@domain.registrar.notifications.size' do
|
||||
visit edit_admin_domain_url(@domain)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue