mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Duplicate domain validation
This commit is contained in:
parent
1f29925004
commit
b6ef81fe31
3 changed files with 20 additions and 2 deletions
|
@ -1,7 +1,16 @@
|
|||
module Epp::DomainsHelper
|
||||
def create_domain
|
||||
domain = Domain.create!(domain_create_params)
|
||||
domain = Domain.new(domain_create_params)
|
||||
|
||||
if domain.save
|
||||
render '/epp/domains/create'
|
||||
else
|
||||
if domain.errors.added?(:name_dirty, :taken)
|
||||
@code = '2302'
|
||||
@msg = 'Domain name already exists'
|
||||
end
|
||||
render '/epp/error'
|
||||
end
|
||||
end
|
||||
|
||||
def check_domain
|
||||
|
|
|
@ -9,6 +9,7 @@ class Domain < ActiveRecord::Base
|
|||
belongs_to :admin_contact, class_name: 'Contact'
|
||||
|
||||
validates :name, domain_name: true
|
||||
validates :name_dirty, uniqueness: true
|
||||
validates :name_puny, domain_name: true
|
||||
|
||||
def name=(value)
|
||||
|
|
|
@ -15,6 +15,14 @@ describe 'EPP Domain', epp: true do
|
|||
expect(Domain.first.registrar.name).to eq('Zone Media OÜ')
|
||||
end
|
||||
|
||||
it 'does not create duplicate domain' do
|
||||
epp_request('domains/create.xml')
|
||||
response = epp_request('domains/create.xml')
|
||||
expect(response[:result_code]).to eq('2302')
|
||||
expect(response[:msg]).to eq('Domain name already exists')
|
||||
expect(response[:clTRID]).to eq('ABC-12345')
|
||||
end
|
||||
|
||||
it 'checks a domain' do
|
||||
response = epp_request('domains/check.xml')
|
||||
expect(response[:result_code]).to eq('1000')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue