mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 10:45:58 +02:00
Attach nameservers to domain
This commit is contained in:
parent
f6ce3b4c4e
commit
d01944fe21
5 changed files with 22 additions and 3 deletions
|
@ -3,7 +3,7 @@ module Epp::DomainsHelper
|
|||
@domain = Domain.new(domain_create_params)
|
||||
|
||||
Domain.transaction do
|
||||
if @domain.save && @domain.attach_contacts(domain_contacts)
|
||||
if @domain.save && @domain.attach_contacts(domain_contacts) && @domain.attach_nameservers(domain_nameservers)
|
||||
render '/epp/domains/create'
|
||||
else
|
||||
handle_errors
|
||||
|
@ -50,6 +50,11 @@ module Epp::DomainsHelper
|
|||
res
|
||||
end
|
||||
|
||||
def domain_nameservers
|
||||
ph = params_hash['epp']['command']['create']['create']['ns']
|
||||
ph[:hostObj]
|
||||
end
|
||||
|
||||
def handle_errors
|
||||
super({
|
||||
'2302' => [:epp_domain_taken, :epp_domain_reserved],
|
||||
|
|
|
@ -61,6 +61,13 @@ class Domain < ActiveRecord::Base
|
|||
)
|
||||
end
|
||||
|
||||
def attach_nameservers(nameservers)
|
||||
nameservers.each do |x|
|
||||
self.nameservers << Nameserver.find_or_create_by(hostname: x)
|
||||
end
|
||||
save!
|
||||
end
|
||||
|
||||
def validate_admin_contacts_count
|
||||
errors.add(:admin_contacts, :blank) if admin_contacts.empty?
|
||||
end
|
||||
|
|
5
db/migrate/20140801140249_rename_nameserver_name.rb
Normal file
5
db/migrate/20140801140249_rename_nameserver_name.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class RenameNameserverName < ActiveRecord::Migration
|
||||
def change
|
||||
rename_column :nameservers, :name, :hostname
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20140731081816) do
|
||||
ActiveRecord::Schema.define(version: 20140801140249) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -102,7 +102,7 @@ ActiveRecord::Schema.define(version: 20140731081816) do
|
|||
end
|
||||
|
||||
create_table "nameservers", force: true do |t|
|
||||
t.string "name"
|
||||
t.string "hostname"
|
||||
t.string "ip"
|
||||
t.integer "ns_set_id"
|
||||
t.datetime "created_at"
|
||||
|
|
|
@ -41,6 +41,8 @@ describe 'EPP Domain', epp: true do
|
|||
expect(Domain.first.registrar.name).to eq('Zone Media OÜ')
|
||||
expect(Domain.first.tech_contacts.count).to eq 2
|
||||
expect(Domain.first.admin_contacts.count).to eq 1
|
||||
|
||||
expect(Domain.first.nameservers.count).to eq(2)
|
||||
end
|
||||
|
||||
it 'does not create duplicate domain' do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue