mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Added domain crID
This commit is contained in:
parent
17386c0010
commit
05ed8a45a1
3 changed files with 70 additions and 8 deletions
|
@ -20,6 +20,20 @@ module Versions
|
|||
true
|
||||
end
|
||||
|
||||
# needs refactoring
|
||||
# TODO: optimization work
|
||||
# belongs_to :api_creator, class_name: 'ApiUser', foreign_key: :creator_str
|
||||
# belongs_to :creator, class_name: 'User', foreign_key: :creator_str
|
||||
def creator
|
||||
return nil if creator_str.blank?
|
||||
|
||||
if creator_str =~ /^\d-api-/
|
||||
ApiUser.find(creator_str)
|
||||
else
|
||||
User.find(creator_str)
|
||||
end
|
||||
end
|
||||
|
||||
# callbacks
|
||||
def touch_domain_version
|
||||
domain.try(:touch_with_version)
|
||||
|
|
|
@ -36,7 +36,7 @@ xml.epp_head do
|
|||
|
||||
xml.tag!('domain:clID', @domain.registrar_name)
|
||||
|
||||
xml.tag!('domain:crID', @domain.versions.first.try(:reify).try(:registrar) || @domain.registrar) #TODO Registrar has to be specified
|
||||
xml.tag!('domain:crID', @domain.creator.try(:registrar))
|
||||
|
||||
xml.tag!('domain:crDate', @domain.created_at)
|
||||
|
||||
|
|
|
@ -51,15 +51,63 @@ describe Domain do
|
|||
@domain.errors.full_messages.should match_array([])
|
||||
end
|
||||
|
||||
context 'with versioning' do
|
||||
it 'should not have one version' do
|
||||
with_versioning do
|
||||
@domain.versions.should == []
|
||||
@domain.versions.size.should == 0
|
||||
@domain.name = 'new-test-name.ee'
|
||||
@domain.save
|
||||
@domain.errors.full_messages.should match_array([])
|
||||
@domain.versions.size.should == 1
|
||||
end
|
||||
end
|
||||
|
||||
it 'should return api_creator when created by api user' do
|
||||
with_versioning do
|
||||
@user = Fabricate(:user)
|
||||
@api_user = Fabricate(:api_user)
|
||||
@user.id.should == 1
|
||||
@api_user.id.should == 1
|
||||
::PaperTrail.whodunnit = '1-api-testuser'
|
||||
|
||||
@domain = Fabricate(:domain)
|
||||
@domain.creator_str.should == '1-api-testuser'
|
||||
|
||||
@domain.creator.should == @api_user
|
||||
@domain.creator.should_not == @user
|
||||
end
|
||||
end
|
||||
|
||||
it 'should return api_creator when created by api user' do
|
||||
with_versioning do
|
||||
@user = Fabricate(:user)
|
||||
@api_user = Fabricate(:api_user)
|
||||
@user.id.should == 2
|
||||
@api_user.id.should == 2
|
||||
::PaperTrail.whodunnit = '2-testuser'
|
||||
|
||||
@domain = Fabricate(:domain)
|
||||
@domain.creator_str.should == '2-testuser'
|
||||
|
||||
@domain.creator.should == @user
|
||||
@domain.creator.should_not == @api_user
|
||||
end
|
||||
end
|
||||
|
||||
it 'should not find api creator when created by user' do
|
||||
with_versioning do
|
||||
# @api_user = Fabricate(:api_user)
|
||||
# @api_user.id.should == 1
|
||||
# ::PaperTrail.whodunnit = '1-testuser'
|
||||
|
||||
# @domain = Fabricate(:domain)
|
||||
# @domain.creator_str.should == '1-testuser'
|
||||
|
||||
# @domain.api_creator.should == nil
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
# it 'validates domain name', skip: true do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue