Skip to content

Commit

Permalink
Merge pull request #16702 from lfu/allowed_vlans_1510069
Browse files Browse the repository at this point in the history
Fix allowed_vlans to call preload correctly.
(cherry picked from commit 09a566a)

https://bugzilla.redhat.com/show_bug.cgi?id=1530674
  • Loading branch information
gmcculloug authored and simaishi committed Jan 3, 2018
1 parent d881b20 commit 2c9776e
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/miq_provision_virt_workflow.rb
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions spec/models/miq_provision_virt_workflow_spec.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2c9776e

Please sign in to comment.