Revision a525db23
Added by Stephen Benjamin almost 6 years ago
test/models/nic_test.rb | ||
---|---|---|
nic_name = 'hostname.sub.bigdomain'
|
||
interface = FactoryBot.build_stubbed(:nic_managed, :name => nic_name)
|
||
subdomain = FactoryBot.create(:domain, :name => 'sub.bigdomain')
|
||
Domain.expects(:find_by).with(:name => subdomain.name).returns(subdomain)
|
||
interface.send(:normalize_name)
|
||
assert_equal subdomain, interface.domain
|
||
end
|
||
... | ... | |
nic_name = 'hostname.undefined-subdomain.bigdomain'
|
||
FactoryBot.create(:domain, :name => 'bigdomain')
|
||
interface = FactoryBot.build_stubbed(:nic_managed, :name => nic_name)
|
||
Domain.expects(:find_by).
|
||
with(:name => 'undefined-subdomain.bigdomain').
|
||
returns(nil)
|
||
interface.send(:normalize_name)
|
||
refute interface.domain
|
||
end
|
Also available in: Unified diff
fixes #23232 - fix error when domain not in taxonomy
This ensures that if domain_id is set, but domain not found (for example
when domain is in another taxonomy), the shortname still removes the
domain from the host's FQDN.