mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 14:44:47 +02:00
parent
00041df311
commit
80327d3447
4 changed files with 17 additions and 2 deletions
|
@ -5,7 +5,7 @@ class Nameserver < ActiveRecord::Base
|
|||
belongs_to :domain, required: true
|
||||
|
||||
# rubocop: disable Metrics/LineLength
|
||||
validates :hostname, format: { with: /\A(([a-zA-Z0-9]|[a-zA-ZäöüõšžÄÖÜÕŠŽ0-9][a-zA-ZäöüõšžÄÖÜÕŠŽ0-9\-]*[a-zA-ZäöüõšžÄÖÜÕŠŽ0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])\z/ }
|
||||
validates :hostname, presence: true, format: { with: /\A(([a-zA-Z0-9]|[a-zA-ZäöüõšžÄÖÜÕŠŽ0-9][a-zA-ZäöüõšžÄÖÜÕŠŽ0-9\-]*[a-zA-ZäöüõšžÄÖÜÕŠŽ0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])\z/ }
|
||||
validate :val_ipv4
|
||||
validate :val_ipv6
|
||||
# rubocop: enable Metrics/LineLength
|
||||
|
@ -40,6 +40,8 @@ class Nameserver < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def check_label_length
|
||||
return unless hostname
|
||||
|
||||
hostname_puny.split('.').each do |label|
|
||||
errors.add(:hostname, :puny_to_long) if label.length > 63
|
||||
end
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class ChangeNameserversHostnameToNotNull < ActiveRecord::Migration
|
||||
def change
|
||||
change_column_null :nameservers, :hostname, false
|
||||
end
|
||||
end
|
|
@ -2221,7 +2221,7 @@ ALTER SEQUENCE messages_id_seq OWNED BY messages.id;
|
|||
|
||||
CREATE TABLE nameservers (
|
||||
id integer NOT NULL,
|
||||
hostname character varying,
|
||||
hostname character varying NOT NULL,
|
||||
ipv4 character varying[] DEFAULT '{}'::character varying[],
|
||||
created_at timestamp without time zone,
|
||||
updated_at timestamp without time zone,
|
||||
|
@ -5082,3 +5082,5 @@ INSERT INTO schema_migrations (version) VALUES ('20180129143538');
|
|||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20180129232054');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20180129233223');
|
||||
|
||||
|
|
|
@ -14,4 +14,10 @@ class NameserverTest < ActiveSupport::TestCase
|
|||
@nameserver.validate
|
||||
assert @nameserver.invalid?
|
||||
end
|
||||
|
||||
def test_invalid_without_hostname
|
||||
@nameserver.hostname = nil
|
||||
@nameserver.validate
|
||||
assert @nameserver.invalid?
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue