mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 05:34:46 +02:00
Merge pull request #1853 from internetee/1845-stop-servermanualinzone-at-clienthold
Set validation to prohibit ManualInzone with any of the *Hold statuses
This commit is contained in:
commit
f1eecdd80f
4 changed files with 34 additions and 6 deletions
|
@ -1,6 +1,12 @@
|
||||||
module Concerns::Domain::Deletable
|
module Concerns::Domain::Deletable
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
DELETE_STATUSES = [
|
||||||
|
DomainStatus::PENDING_DELETE_CONFIRMATION,
|
||||||
|
DomainStatus::PENDING_DELETE,
|
||||||
|
DomainStatus::FORCE_DELETE,
|
||||||
|
].freeze
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def delete_later
|
def delete_later
|
||||||
|
|
|
@ -11,6 +11,11 @@ module Concerns::Domain::ForceDelete # rubocop:disable Metrics/ModuleLength
|
||||||
lambda {
|
lambda {
|
||||||
where("(force_delete_data->>'contact_notification_sent_date') is null")
|
where("(force_delete_data->>'contact_notification_sent_date') is null")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HOLD_STATUSES = [
|
||||||
|
DomainStatus::SERVER_HOLD,
|
||||||
|
DomainStatus::CLIENT_HOLD,
|
||||||
|
].freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
class_methods do
|
class_methods do
|
||||||
|
@ -19,6 +24,10 @@ module Concerns::Domain::ForceDelete # rubocop:disable Metrics/ModuleLength
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def hold_status?
|
||||||
|
HOLD_STATUSES.any? { |status| statuses.include? status }
|
||||||
|
end
|
||||||
|
|
||||||
def notification_template(explicit: nil)
|
def notification_template(explicit: nil)
|
||||||
reason = explicit&.downcase
|
reason = explicit&.downcase
|
||||||
return reason if %w[invalid_email invalid_phone].include?(reason)
|
return reason if %w[invalid_email invalid_phone].include?(reason)
|
||||||
|
|
|
@ -107,13 +107,13 @@ class Domain < ApplicationRecord
|
||||||
|
|
||||||
validate :status_is_consistant
|
validate :status_is_consistant
|
||||||
def status_is_consistant
|
def status_is_consistant
|
||||||
has_error = (statuses.include?(DomainStatus::SERVER_HOLD) && statuses.include?(DomainStatus::SERVER_MANUAL_INZONE))
|
has_error = (hold_status? && statuses.include?(DomainStatus::SERVER_MANUAL_INZONE))
|
||||||
unless has_error
|
unless has_error
|
||||||
if (statuses & [DomainStatus::PENDING_DELETE_CONFIRMATION, DomainStatus::PENDING_DELETE, DomainStatus::FORCE_DELETE]).any?
|
if (statuses & DELETE_STATUSES).any?
|
||||||
has_error = statuses.include? DomainStatus::SERVER_DELETE_PROHIBITED
|
has_error = statuses.include? DomainStatus::SERVER_DELETE_PROHIBITED
|
||||||
end
|
|
||||||
end
|
end
|
||||||
errors.add(:domains, I18n.t(:object_status_prohibits_operation)) if has_error
|
end
|
||||||
|
errors.add(:domains, I18n.t(:object_status_prohibits_operation)) if has_error
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_accessor :is_admin
|
attr_accessor :is_admin
|
||||||
|
|
|
@ -234,6 +234,19 @@ class ForceDeleteTest < ActionMailer::TestCase
|
||||||
assert_includes(@domain.statuses, asserted_status)
|
assert_includes(@domain.statuses, asserted_status)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_client_hold_prohibits_manual_inzone
|
||||||
|
@domain.update(valid_to: Time.zone.parse('2012-08-05'))
|
||||||
|
@domain.update(template_name: 'legal_person')
|
||||||
|
travel_to Time.zone.parse('2010-07-05')
|
||||||
|
@domain.schedule_force_delete(type: :soft)
|
||||||
|
travel_to Time.zone.parse('2010-08-21')
|
||||||
|
Domains::ClientHold::SetClientHold.run!
|
||||||
|
@domain.reload
|
||||||
|
|
||||||
|
@domain.statuses << DomainStatus::SERVER_MANUAL_INZONE
|
||||||
|
assert_not @domain.valid?
|
||||||
|
end
|
||||||
|
|
||||||
def test_force_delete_soft_year_ahead_not_sets_client_hold_before_threshold
|
def test_force_delete_soft_year_ahead_not_sets_client_hold_before_threshold
|
||||||
asserted_status = DomainStatus::CLIENT_HOLD
|
asserted_status = DomainStatus::CLIENT_HOLD
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue