Skip to content

Commit

Permalink
Extract queue message delivery into helper method
Browse files Browse the repository at this point in the history
  • Loading branch information
agrare committed Dec 19, 2017
1 parent b9309e7 commit c450468
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions spec/models/ext_management_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,7 @@
it "returns a task" do
task_id = ems.destroy_queue

queue_message = MiqQueue.first
status, message, result = queue_message.deliver
queue_message.delivered(status, message, result)
deliver_queue_message

task = MiqTask.find(task_id)
expect(task.state).to eq("Finished")
Expand All @@ -439,9 +437,7 @@

expect(MiqQueue.count).to eq(1)

queue_message = MiqQueue.first
status, message, result = queue_message.deliver
queue_message.delivered(status, message, result)
deliver_queue_message

expect(MiqQueue.count).to eq(1)
expect(MiqQueue.last.deliver_on).to_not be_nil
Expand All @@ -451,17 +447,13 @@
refresh_worker = FactoryGirl.create(:miq_ems_refresh_worker, :queue_name => ems.queue_name, :status => "started", :miq_server => server)
ems.destroy_queue

queue_message = MiqQueue.first
status, message, result = queue_message.deliver
queue_message.delivered(status, message, result)
deliver_queue_message

expect(ExtManagementSystem.count).to eq(1)

refresh_worker.destroy

queue_message = MiqQueue.first
status, message, result = queue_message.deliver
queue_message.delivered(status, message, result)
deliver_queue_message

expect(ExtManagementSystem.count).to eq(0)
end
Expand All @@ -478,6 +470,11 @@
expect(MiqQueue.pluck(:instance_id)).to include(ems.id, child_manager.id)
end
end

def deliver_queue_message(queue_message = MiqQueue.first)
status, message, result = queue_message.deliver
queue_message.delivered(status, message, result)
end
end

context "virtual column :supports_block_storage" do
Expand Down

0 comments on commit c450468

Please sign in to comment.