Merge pull request #1667 from internetee/1663-fix-history-error

Fix error if domain name was nil
This commit is contained in:
Timo Võhmar 2020-08-27 15:31:24 +03:00 committed by GitHub
commit 46c7ec5b5d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View file

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

View file

@ -270,6 +270,13 @@ class DomainTest < ActiveSupport::TestCase
assert_equal 'shop.test', domain.domain_name.to_s
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
registrant = contacts(:john).becomes(Registrant)
assert_equal registrant, @domain.registrant