mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 09:57:23 +02:00
parent
b20e31f3c8
commit
930a59ae67
4 changed files with 34 additions and 17 deletions
|
@ -19,8 +19,8 @@ class Domain < ActiveRecord::Base
|
||||||
# TODO: whois requests ip whitelist for full info for own domains and partial info for other domains
|
# TODO: whois requests ip whitelist for full info for own domains and partial info for other domains
|
||||||
# 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, required: true
|
||||||
belongs_to :registrant
|
belongs_to :registrant, required: true
|
||||||
# TODO: should we user validates_associated :registrant here?
|
# TODO: should we user validates_associated :registrant here?
|
||||||
|
|
||||||
has_many :admin_domain_contacts
|
has_many :admin_domain_contacts
|
||||||
|
@ -104,8 +104,7 @@ class Domain < ActiveRecord::Base
|
||||||
|
|
||||||
validates :name_dirty, domain_name: true, uniqueness: true
|
validates :name_dirty, domain_name: true, uniqueness: true
|
||||||
validates :puny_label, length: { maximum: 63 }
|
validates :puny_label, length: { maximum: 63 }
|
||||||
validates :period, numericality: { only_integer: true }
|
validates :period, presence: true, numericality: { only_integer: true }
|
||||||
validates :registrant, :registrar, presence: true
|
|
||||||
|
|
||||||
validate :validate_reservation
|
validate :validate_reservation
|
||||||
def validate_reservation
|
def validate_reservation
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
class ChangeDomainRegistrarAndRegistrantToNotNull < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
change_column :domains, :registrar_id, :integer, null: false
|
||||||
|
change_column :domains, :registrant_id, :integer, null: false
|
||||||
|
end
|
||||||
|
end
|
|
@ -1033,12 +1033,12 @@ ALTER SEQUENCE domain_transfers_id_seq OWNED BY domain_transfers.id;
|
||||||
CREATE TABLE domains (
|
CREATE TABLE domains (
|
||||||
id integer NOT NULL,
|
id integer NOT NULL,
|
||||||
name character varying,
|
name character varying,
|
||||||
registrar_id integer,
|
registrar_id integer NOT NULL,
|
||||||
registered_at timestamp without time zone,
|
registered_at timestamp without time zone,
|
||||||
status character varying,
|
status character varying,
|
||||||
valid_from timestamp without time zone,
|
valid_from timestamp without time zone,
|
||||||
valid_to timestamp without time zone,
|
valid_to timestamp without time zone,
|
||||||
registrant_id integer,
|
registrant_id integer NOT NULL,
|
||||||
auth_info character varying,
|
auth_info character varying,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone,
|
||||||
updated_at timestamp without time zone,
|
updated_at timestamp without time zone,
|
||||||
|
@ -5154,3 +5154,5 @@ INSERT INTO schema_migrations (version) VALUES ('20170509215614');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20170606133501');
|
INSERT INTO schema_migrations (version) VALUES ('20170606133501');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20170606150352');
|
||||||
|
|
||||||
|
|
|
@ -33,16 +33,6 @@ RSpec.describe Domain do
|
||||||
@domain = Domain.new
|
@domain = Domain.new
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not be valid' do
|
|
||||||
@domain.valid?
|
|
||||||
@domain.errors.full_messages.should match_array([
|
|
||||||
"Admin domain contacts Admin contacts count must be between 1-10",
|
|
||||||
"Period Period is not a number",
|
|
||||||
"Registrant Registrant is missing",
|
|
||||||
"Registrar Registrar is missing"
|
|
||||||
])
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should not have any versions' do
|
it 'should not have any versions' do
|
||||||
@domain.versions.should == []
|
@domain.versions.should == []
|
||||||
end
|
end
|
||||||
|
@ -599,10 +589,30 @@ RSpec.describe Domain do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
RSpec.describe Domain, db: false do
|
RSpec.describe Domain do
|
||||||
it { is_expected.to alias_attribute(:on_hold_time, :outzone_at) }
|
it { is_expected.to alias_attribute(:on_hold_time, :outzone_at) }
|
||||||
it { is_expected.to alias_attribute(:outzone_time, :outzone_at) }
|
it { is_expected.to alias_attribute(:outzone_time, :outzone_at) }
|
||||||
|
|
||||||
|
describe 'registrar validation', db: false do
|
||||||
|
let(:domain) { described_class.new }
|
||||||
|
|
||||||
|
it 'rejects absent' do
|
||||||
|
domain.registrar = nil
|
||||||
|
domain.validate
|
||||||
|
expect(domain.errors).to have_key(:registrar)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'registrant validation', db: false do
|
||||||
|
let(:domain) { described_class.new }
|
||||||
|
|
||||||
|
it 'rejects absent' do
|
||||||
|
domain.registrant = nil
|
||||||
|
domain.validate
|
||||||
|
expect(domain.errors).to have_key(:registrant)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'nameserver validation', db: true do
|
describe 'nameserver validation', db: true do
|
||||||
let(:domain) { described_class.new }
|
let(:domain) { described_class.new }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue