Fix error if domain name was nil.

Used for some old history entries
Closes #1663
This commit is contained in:
Alex Sherman 2020-08-27 13:04:43 +05:00
parent 76e4e32dc9
commit a0029d0a80
2 changed files with 9 additions and 2 deletions

View file

@ -260,8 +260,8 @@ class Domain < ApplicationRecord
end end
def name=(value) def name=(value)
value.strip! value&.strip!
value.downcase! value&.downcase!
self[:name] = SimpleIDN.to_unicode(value) self[:name] = SimpleIDN.to_unicode(value)
self[:name_puny] = SimpleIDN.to_ascii(value) self[:name_puny] = SimpleIDN.to_ascii(value)
self[:name_dirty] = value self[:name_dirty] = value

View file

@ -270,6 +270,13 @@ class DomainTest < ActiveSupport::TestCase
assert_equal 'shop.test', domain.domain_name.to_s assert_equal 'shop.test', domain.domain_name.to_s
end end
def test_nil_name_doesnt_throw_error
domain = Domain.new(name: 'shop.test')
assert_nothing_raised do
domain.name = nil
end
end
def test_returns_registrant_user_domains_by_registrant def test_returns_registrant_user_domains_by_registrant
registrant = contacts(:john).becomes(Registrant) registrant = contacts(:john).becomes(Registrant)
assert_equal registrant, @domain.registrant assert_equal registrant, @domain.registrant