Skip to content

Commit 6c1571b

Browse files
committed
test preload passing an array
1 parent 13080b7 commit 6c1571b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

spec/lib/miq_preloader_spec.rb

+11
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,17 @@
100100
expect { expect(nodes.first.container_images).to eq([image]) }.to make_database_queries(:count => 1)
101101
end
102102

103+
104+
it "preloads association array" do
105+
host = FactoryBot.create(:host_vmware) # infra
106+
FactoryBot.create_list(:vm, 2, :ext_management_system => FactoryBot.create(:ems_infra), :host => host)
107+
emses = ExtManagementSystem.all
108+
expect { preload(emses, [:vms, :host]) }.to make_database_queries(:count => 2)
109+
110+
expect { expect(emses.first.vms.size).to eq(2) }.not_to make_database_queries
111+
expect { expect(emses.first.host).to eq(host) }.not_to make_database_queries
112+
end
113+
103114
def preload(*args, **kwargs)
104115
MiqPreloader.preload(*args, **kwargs)
105116
end

0 commit comments

Comments
 (0)