Skip to content

Commit

Permalink
Specs for get_target_objects method with ManagerRefresh::Target
Browse files Browse the repository at this point in the history
Specs for get_target_objects method with ManagerRefresh::Target
  • Loading branch information
Ladas committed Mar 10, 2017
1 parent efc053f commit 28ba9e2
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion spec/models/ems_refresh_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def assert_queue_item(expected_targets)

context ".get_target_objects" do
it "array of class/ids pairs" do
ems1 = FactoryGirl.create(:ems_vmware, :name => "ems_vmware1")
ems1 = FactoryGirl.create(:ems_vmware, :name => "ems_vmware1")
ems2 = FactoryGirl.create(:ems_redhat, :name => "ems_redhat1")
pairs = [
[ems1.class, ems1.id],
Expand All @@ -102,6 +102,32 @@ def assert_queue_item(expected_targets)

expect(described_class.get_target_objects(pairs)).to match_array([ems1, ems2])
end

it "array of class/hash pairs for ManagerRefresh::Target objects" do
ems1 = FactoryGirl.create(:ems_vmware, :name => "ems_vmware1")
ems2 = FactoryGirl.create(:ems_redhat, :name => "ems_redhat1")

target1 = ManagerRefresh::Target.load(:manager_id => ems1.id,
:association => :vms,
:manager_ref => {:ems_ref => "vm1"})
target2 = ManagerRefresh::Target.load(:manager_id => ems2.id,
:association => :network_ports,
:manager_ref => {:ems_ref => "network_port_1"})
target3 = ManagerRefresh::Target.new(:manager_id => ems1.id,
:association => :vms,
:manager_ref => {:ems_ref => "vm2"})
target1_dup = ManagerRefresh::Target.load(:manager_id => ems1.id,
:association => :vms,
:manager_ref => {:ems_ref => "vm1"})
pairs = [
[target1.class, target1.id],
[target2.class, target2.id],
[target3.class, target3.id],
[target1_dup.class, target1_dup.id],
]

expect(described_class.get_target_objects(pairs).map(&:dump)).to match_array([target1, target2, target3].map(&:dump))
end
end

context ".refresh" do
Expand Down

0 comments on commit 28ba9e2

Please sign in to comment.