diff --git a/app/models/conversion_host.rb b/app/models/conversion_host.rb index 92fa69e3e1b..774e085424a 100644 --- a/app/models/conversion_host.rb +++ b/app/models/conversion_host.rb @@ -21,7 +21,7 @@ class ConversionHost < ApplicationRecord :uniqueness => true, :format => { :with => Resolv::AddressRegex }, :inclusion => { :in => ->(conversion_host) { conversion_host.resource.ipaddresses } }, - :unless => ->(conversion_host) { conversion_host.resource.blank? || conversion_host.resource.ipaddresses.blank? }, + :unless => ->(conversion_host) { conversion_host.address.blank? || conversion_host.resource.blank? || conversion_host.resource.ipaddresses.blank? }, :presence => false validate :resource_supports_conversion_host diff --git a/spec/models/conversion_host_spec.rb b/spec/models/conversion_host_spec.rb index 4e733185262..93c158cb8a9 100644 --- a/spec/models/conversion_host_spec.rb +++ b/spec/models/conversion_host_spec.rb @@ -309,6 +309,7 @@ end it "is valid if an address is not provided" do + allow(vm).to receive(:ipaddresses).and_return(['127.0.0.1']) conversion_host = ConversionHost.new(:name => "test", :resource => vm) expect(conversion_host.valid?).to be(true) end