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=1565248
  • Loading branch information
gmcculloug authored and simaishi committed Apr 9, 2018
1 parent 1efe7a4 commit 76497ff
Show file tree
Hide file tree
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
Expand Up @@ -232,7 +232,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
Expand Down
6 changes: 6 additions & 0 deletions spec/models/miq_provision_virt_workflow_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 76497ff

Please sign in to comment.