mirror of
https://github.com/internetee/registry.git
synced 2025-08-03 00:12:03 +02:00
Add tests & fixes for epp contact
This commit is contained in:
parent
860c3c8008
commit
7163695ad1
10 changed files with 84 additions and 29 deletions
24
app/models/concerns/roids.rb
Normal file
24
app/models/concerns/roids.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
module Roids
|
||||
extend ActiveSupport::Concern
|
||||
ID_CHAR_LIMIT = 8
|
||||
|
||||
included do
|
||||
def roid
|
||||
id_size = id.to_s.size
|
||||
if id_size <= ID_CHAR_LIMIT
|
||||
"EIS-#{id}"
|
||||
else
|
||||
roid_with_prefix(id_size)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def roid_with_prefix(id_size)
|
||||
id_delta = id_size - ID_CHAR_LIMIT
|
||||
id_prefix = id.to_s.split(//).first(id_delta).join('').to_s
|
||||
id_postfix = id.to_s.split(//).last(id_size - id_delta).join('').to_s
|
||||
"EIS#{id_prefix}-#{id_postfix}"
|
||||
end
|
||||
end
|
||||
end
|
|
@ -21,7 +21,7 @@ module UserEvents
|
|||
Registrar.find(cr_registrar_id).code
|
||||
else
|
||||
# cr_id optional for domain, but required for contact; but we want something here anyway
|
||||
self.creator_str # Fallback if we failed, maybe we can find a string here
|
||||
self.creator_str || self.registrar.code # Fallback
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,6 +2,7 @@ require 'deserializers/xml/legal_document'
|
|||
|
||||
class Contact < ApplicationRecord
|
||||
include Versions # version/contact_version.rb
|
||||
include Roids
|
||||
include EppErrors
|
||||
include UserEvents
|
||||
include Contact::Transferable
|
||||
|
@ -259,10 +260,6 @@ class Contact < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def roid
|
||||
"EIS-#{id}"
|
||||
end
|
||||
|
||||
# kind of decorator in order to always return statuses
|
||||
# if we use separate decorator, then we should add it
|
||||
# to too many places
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
class Domain < ApplicationRecord
|
||||
include UserEvents
|
||||
include Roids
|
||||
include Versions # version/domain_version.rb
|
||||
include Domain::Expirable
|
||||
include Domain::Activatable
|
||||
|
@ -33,8 +34,6 @@ class Domain < ApplicationRecord
|
|||
has_many :tech_domain_contacts
|
||||
accepts_nested_attributes_for :tech_domain_contacts, allow_destroy: true, reject_if: :tech_change_prohibited?
|
||||
|
||||
ID_CHAR_LIMIT = 8
|
||||
|
||||
def registrant_change_prohibited?
|
||||
statuses.include? DomainStatus::SERVER_REGISTRANT_CHANGE_PROHIBITED
|
||||
end
|
||||
|
@ -332,15 +331,6 @@ class Domain < ApplicationRecord
|
|||
domain
|
||||
end
|
||||
|
||||
def roid
|
||||
id_size = id.to_s.size
|
||||
if id_size <= ID_CHAR_LIMIT
|
||||
"EIS-#{id}"
|
||||
else
|
||||
roid_with_prefix(id_size)
|
||||
end
|
||||
end
|
||||
|
||||
def puny_label
|
||||
name_puny.to_s.split('.').first
|
||||
end
|
||||
|
@ -741,13 +731,4 @@ class Domain < ApplicationRecord
|
|||
def self.uses_zone?(zone)
|
||||
exists?(["name ILIKE ?", "%.#{zone.origin}"])
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def roid_with_prefix(id_size)
|
||||
id_delta = id_size - ID_CHAR_LIMIT
|
||||
id_prefix = id.to_s.split(//).first(id_delta).join('').to_s
|
||||
id_postfix = id.to_s.split(//).last(id_size - id_delta).join('').to_s
|
||||
"EIS#{id_prefix}-#{id_postfix}"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue