Always require domain#transfer_code

#660
This commit is contained in:
Artur Beljajev 2018-01-22 13:03:34 +02:00
parent 524854451a
commit be057656e8
4 changed files with 15 additions and 1 deletions

View file

@ -104,6 +104,7 @@ class Domain < ActiveRecord::Base
validates :name_dirty, domain_name: true, uniqueness: true
validates :puny_label, length: { maximum: 63 }
validates :period, presence: true, numericality: { only_integer: true }
validates :transfer_code, presence: true
validate :validate_reservation
def validate_reservation

View file

@ -0,0 +1,5 @@
class ChangeDomainsTransferCodeToNotNull < ActiveRecord::Migration
def change
change_column_null :domains, :transfer_code, false
end
end

View file

@ -998,7 +998,7 @@ CREATE TABLE domains (
valid_from timestamp without time zone,
valid_to timestamp without time zone,
registrant_id integer NOT NULL,
transfer_code character varying,
transfer_code character varying NOT NULL,
created_at timestamp without time zone,
updated_at timestamp without time zone,
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 ('20180122105335');

View file

@ -9,6 +9,12 @@ class DomainTest < ActiveSupport::TestCase
assert @domain.valid?
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
domain = Domain.new
another_domain = Domain.new