Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[V2V] Fix allowing address to be blank for the ConversionHost model, and update spec. #18690

Merged
merged 1 commit into from
Apr 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/conversion_host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions spec/models/conversion_host_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down