Project

General

Profile

« Previous | Next » 

Revision a5dc3e23

Added by Daniel Lobato Garcia about 9 years ago

Fixes #10111 - Use a dummy primary interface for unmanaged hosts

Unmanaged hosts require a host interface due to delegation of networking
attributes, and some others like 'name'. Since unmanaged hosts do not
necessarily have an interface associated (unless created through puppet
facts importer), we provide a dummy interface to prevent errors.

Ideally this should go away as soon as unmanaged hosts are a different
class or Host::Base, moving validations and other particularities
to Host::Managed.

View differences:

test/unit/host_test.rb
end
end
test 'unmanaged hosts name does not rely on primary interface' do
host = FactoryGirl.build(:host, :managed)
host.managed = false
host.interfaces = []
# A dummy primary interface is created here
host.update_attributes(:name => 'foounmanaged')
assert_equal 'foounmanaged', host.name
end
test 'updating host domain should validate domain exists' do
host = FactoryGirl.create(:host, :managed)
last_domain_id = Domain.order(:id).last.id

Also available in: Unified diff