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

Fixed call that build list of Storages to build Host file drop down #5952

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/controllers/mixins/actions/vm_actions/reconfigure.rb
Expand Up @@ -233,8 +233,8 @@ def get_vlan_options(host_id)
def get_iso_options(vm)
iso_options = []

datastore_ids = vm.storages.pluck(:id)
# determine available iso files for the datastaores
datastore_ids = vm.host.storages.pluck(:id)
# determine available iso files for the datastores
Rbac.filtered(StorageFile.where("storage_id IN (?) and ext_name = 'iso'", datastore_ids)).each do |sf|
iso_options << [sf.name, sf.name + ',' + sf.storage_id.to_s]
end
Expand Down
27 changes: 27 additions & 0 deletions spec/controllers/mixins/actions/vm_actions/reconfigure_spec.rb
@@ -0,0 +1,27 @@
describe Mixins::Actions::VmActions::Reconfigure do
describe '#get_iso_options' do
before do
@host = FactoryBot.create(:host, :name =>'hostname1')
@datastore = FactoryBot.create(:storage, :name => 'storage_name')
@vm = FactoryBot.create(:vm_vmware, :host => @host)
FactoryBot.create(:storage_file, :storage_id => @datastore.id, :ext_name => 'iso', :base_name => "good-stuff.iso")
FactoryBot.create(:storage_file, :storage_id => 1, :ext_name => 'iso', :base_name => "some_other_storage.iso")
end

context 'populate list of Host files' do
let(:controller) { VmInfraController.new }

it "gets list of VM's host storages that have iso files" do
@host.storages << @datastore
storage_list = controller.send(:get_iso_options, @vm)
expect(storage_list.count).to be(1)
end

it "gets empty list for VM's storage" do
@vm.storages << @datastore
storage_list = controller.send(:get_iso_options, @vm)
expect(storage_list.count).to be(0)
end
end
end
end