From 9c94f30b232d09be49b6d0952bf25f0243573bb1 Mon Sep 17 00:00:00 2001 From: Lucy Fu Date: Wed, 20 Dec 2017 09:50:58 -0500 Subject: [PATCH] Fix allowed_vlans to call preload correctly. https://bugzilla.redhat.com/show_bug.cgi?id=1510069 --- app/models/miq_provision_virt_workflow.rb | 2 +- spec/models/miq_provision_virt_workflow_spec.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/models/miq_provision_virt_workflow.rb b/app/models/miq_provision_virt_workflow.rb index b0a1d130713..e758e62f536 100644 --- a/app/models/miq_provision_virt_workflow.rb +++ b/app/models/miq_provision_virt_workflow.rb @@ -230,7 +230,7 @@ def available_vlans_and_hosts(options = {}) unless @vlan_options[:vlans] == false rails_logger('allowed_vlans', 0) # TODO: Use Active Record to preload this data? - MiqPreloader.preload(hosts, :switches => :lans) + MiqPreloader.preload(hosts, :lans => :switches) load_allowed_vlans(hosts, vlans) rails_logger('allowed_vlans', 1) end diff --git a/spec/models/miq_provision_virt_workflow_spec.rb b/spec/models/miq_provision_virt_workflow_spec.rb index b093e899376..7a61830692e 100644 --- a/spec/models/miq_provision_virt_workflow_spec.rb +++ b/spec/models/miq_provision_virt_workflow_spec.rb @@ -97,6 +97,12 @@ expect(vlans.keys).to match_array(lan_keys) expect(vlans.values).to match_array(lan_keys) end + + it '#load_hosts_vlans' do + hosts = [@host1] + MiqPreloader.preload(hosts, :lans => :switches) + expect { workflow.load_hosts_vlans(hosts, {}) }.not_to exceed_query_limit(0) + end end end