Project

General

Profile

« Previous | Next » 

Revision f2d5f955

Added by Marek Hulán about 9 years ago

Fixes #9618 - make identifier uniq per host

View differences:

test/unit/host_test.rb
assert_kind_of Nic::Managed, host.interfaces.find_by_identifier('eth1')
end
test "host can't have more interfaces with the same identifier" do
host = FactoryGirl.build(:host, :managed)
host.primary_interface.identifier = 'eth0'
nic = host.interfaces.build(:identifier => 'eth0')
refute host.valid?
assert_present nic.errors[:identifier]
assert_present host.errors[:interfaces]
nic.identifier = 'eth1'
host.valid?
refute_includes nic.errors.keys, :identifier
refute_includes host.errors.keys, :interfaces
end
# Token tests
test "built should clean tokens" do
......
end
h = FactoryGirl.create(:host, :managed)
assert h.interfaces.create :mac => "cabbccddeeff", :host => h, :type => 'Nic::BMC',
:provider => "IPMI", :username => "root", :password => "secret", :ip => "10.35.19.35"
:provider => "IPMI", :username => "root", :password => "secret", :ip => "10.35.19.35",
:identifier => 'eth2'
as_user :one do
assert h.update_attributes!("interfaces_attributes" => {"0" => {"mac"=>"59:52:10:1e:45:16"}})
end

Also available in: Unified diff