mirror of
https://github.com/internetee/registry.git
synced 2025-05-16 09:27:19 +02:00
Attach nameservers directly to domain
This commit is contained in:
parent
7a9988236e
commit
4396ec665c
6 changed files with 19 additions and 5 deletions
|
@ -3,7 +3,6 @@ class Domain < ActiveRecord::Base
|
||||||
#TODO most inputs should be trimmed before validatation, probably some global logic?
|
#TODO most inputs should be trimmed before validatation, probably some global logic?
|
||||||
|
|
||||||
belongs_to :registrar
|
belongs_to :registrar
|
||||||
belongs_to :ns_set
|
|
||||||
belongs_to :owner_contact, class_name: 'Contact'
|
belongs_to :owner_contact, class_name: 'Contact'
|
||||||
|
|
||||||
has_many :domain_contacts
|
has_many :domain_contacts
|
||||||
|
@ -16,6 +15,7 @@ class Domain < ActiveRecord::Base
|
||||||
where(domain_contacts: {contact_type: Contact::CONTACT_TYPE_ADMIN})
|
where(domain_contacts: {contact_type: Contact::CONTACT_TYPE_ADMIN})
|
||||||
}, through: :domain_contacts, source: :contact
|
}, through: :domain_contacts, source: :contact
|
||||||
|
|
||||||
|
has_and_belongs_to_many :nameservers
|
||||||
|
|
||||||
validates_presence_of :name
|
validates_presence_of :name
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
class Nameserver < ActiveRecord::Base
|
class Nameserver < ActiveRecord::Base
|
||||||
has_and_belongs_to_many :ns_sets
|
belongs_to :registrar
|
||||||
|
has_and_belongs_to_many :domains
|
||||||
end
|
end
|
||||||
|
|
8
db/migrate/20140731081816_add_nameservers_to_domain.rb
Normal file
8
db/migrate/20140731081816_add_nameservers_to_domain.rb
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
class AddNameserversToDomain < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :domains_nameservers do |t|
|
||||||
|
t.integer :domain_id
|
||||||
|
t.integer :nameserver_id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20140730141443) do
|
ActiveRecord::Schema.define(version: 20140731081816) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -74,6 +74,11 @@ ActiveRecord::Schema.define(version: 20140730141443) do
|
||||||
t.integer "period"
|
t.integer "period"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "domains_nameservers", force: true do |t|
|
||||||
|
t.integer "domain_id"
|
||||||
|
t.integer "nameserver_id"
|
||||||
|
end
|
||||||
|
|
||||||
create_table "epp_sessions", force: true do |t|
|
create_table "epp_sessions", force: true do |t|
|
||||||
t.string "session_id"
|
t.string "session_id"
|
||||||
t.text "data"
|
t.text "data"
|
||||||
|
|
|
@ -2,7 +2,7 @@ require "rails_helper"
|
||||||
|
|
||||||
describe Domain do
|
describe Domain do
|
||||||
it { should belong_to(:registrar) }
|
it { should belong_to(:registrar) }
|
||||||
it { should belong_to(:ns_set) }
|
it { should have_and_belong_to_many(:nameservers)}
|
||||||
it { should belong_to(:owner_contact) }
|
it { should belong_to(:owner_contact) }
|
||||||
it { should have_many(:tech_contacts) }
|
it { should have_many(:tech_contacts) }
|
||||||
it { should have_many(:admin_contacts) }
|
it { should have_many(:admin_contacts) }
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
||||||
describe Nameserver do
|
describe Nameserver do
|
||||||
it { should have_and_belong_to_many(:ns_sets) }
|
it { should have_and_belong_to_many(:domains) }
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue