Revision 2c3cd215
Added by Marek Hulán over 8 years ago
app/models/nic/bmc.rb | ||
---|---|---|
class BMC < Managed
|
||
PROVIDERS = %w(IPMI)
|
||
before_validation :ensure_physical
|
||
before_validation { |nic| nic.provider.upcase! }
|
||
before_validation { |nic| nic.provider.try(:upcase!) }
|
||
validates :provider, :presence => true, :inclusion => { :in => PROVIDERS }
|
||
validates :mac, :presence => true, :if => :managed?
|
||
validate :validate_bmc_proxy
|
test/unit/nics/bmc_test.rb | ||
---|---|---|
assert FactoryGirl.build(:nic_bmc, :host => host, :provider => 'ipmi').valid?
|
||
end
|
||
|
||
test 'upcasing provider does not fail if provider is not present' do
|
||
host = FactoryGirl.build(:host, :managed)
|
||
assert_nothing_raised do
|
||
FactoryGirl.build(:nic_bmc, :host => host, :provider => nil).valid?
|
||
end
|
||
end
|
||
|
||
context "no BMC smart proxy exists" do
|
||
def setup
|
||
SmartProxy.with_features('BMC').destroy_all
|
Also available in: Unified diff
Fixes #11258 - validation handles blank provider
(cherry picked from commit 3b27c173467c3ab4b53e844913cfd559b78d44ac)