mirror of
https://github.com/internetee/registry.git
synced 2025-05-30 09:30:03 +02:00
parent
524854451a
commit
be057656e8
4 changed files with 15 additions and 1 deletions
|
@ -104,6 +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, presence: true, numericality: { only_integer: true }
|
validates :period, presence: true, numericality: { only_integer: true }
|
||||||
|
validates :transfer_code, presence: true
|
||||||
|
|
||||||
validate :validate_reservation
|
validate :validate_reservation
|
||||||
def validate_reservation
|
def validate_reservation
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class ChangeDomainsTransferCodeToNotNull < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
change_column_null :domains, :transfer_code, false
|
||||||
|
end
|
||||||
|
end
|
|
@ -998,7 +998,7 @@ CREATE TABLE domains (
|
||||||
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 NOT NULL,
|
registrant_id integer NOT NULL,
|
||||||
transfer_code character varying,
|
transfer_code character varying NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone,
|
||||||
updated_at timestamp without time zone,
|
updated_at timestamp without time zone,
|
||||||
name_dirty character varying,
|
name_dirty character varying,
|
||||||
|
@ -5048,3 +5048,5 @@ INSERT INTO schema_migrations (version) VALUES ('20180120183441');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20180121165304');
|
INSERT INTO schema_migrations (version) VALUES ('20180121165304');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20180122105335');
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,12 @@ class DomainTest < ActiveSupport::TestCase
|
||||||
assert @domain.valid?
|
assert @domain.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_rejects_absent_transfer_code
|
||||||
|
@domain.transfer_code = nil
|
||||||
|
@domain.validate
|
||||||
|
assert @domain.invalid?
|
||||||
|
end
|
||||||
|
|
||||||
def test_generates_random_transfer_code_if_new
|
def test_generates_random_transfer_code_if_new
|
||||||
domain = Domain.new
|
domain = Domain.new
|
||||||
another_domain = Domain.new
|
another_domain = Domain.new
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue