added test and saving statuses into histroy field

This commit is contained in:
olegphenomenon 2021-09-23 11:01:34 +03:00
parent 622dba4f1c
commit 09eab21d2b
9 changed files with 34 additions and 183 deletions

View file

@ -12,11 +12,11 @@ module Domain::RegistryLockable
end
def apply_registry_lock
# binding.pry
return unless registry_lockable?
return if locked_by_registrant?
transaction do
self.admin_store_statuses_history = self.statuses
self.statuses |= LOCK_STATUSES
self.locked_by_registrant_at = Time.zone.now
alert_registrar_lock_changes!(lock: true)
@ -29,7 +29,7 @@ module Domain::RegistryLockable
(statuses & [DomainStatus::PENDING_DELETE_CONFIRMATION,
DomainStatus::PENDING_CREATE, DomainStatus::PENDING_UPDATE,
DomainStatus::PENDING_DELETE, DomainStatus::PENDING_RENEW,
DomainStatus::PENDING_TRANSFER, DomainStatus::FORCE_DELETE]).empty?
DomainStatus::PENDING_TRANSFER]).empty?
end
def locked_by_registrant?

View file

@ -122,7 +122,7 @@ class Domain < ApplicationRecord
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
has_error = statuses.include? DomainStatus::SERVER_DELETE_PROHIBITED unless locked_by_registrant?
end
errors.add(:domains, I18n.t(:object_status_prohibits_operation)) if has_error
end

View file

@ -17,13 +17,12 @@ class RegistrantUser < User
Country.new(alpha2_code)
end
def companies(company_register = nil)
def companies(company_register = CompanyRegister::Client.new)
return [] if ident.include?('-')
[OpenStruct.new(registration_number: '43344412', company_name: 'TestFirma'),
OpenStruct.new(registration_number: '12345678', company_name: 'SuperFirma OU')]
company_register.representation_rights(citizen_personal_code: ident,
citizen_country_code: country.alpha3)
end
def contacts(representable: true)
Contact.registrant_user_contacts(self, representable: representable)