diff --git a/lib/insights_cloud/async/connector_playbook_execution_reporter_task.rb b/lib/insights_cloud/async/connector_playbook_execution_reporter_task.rb index b0fd5d1a..098ccfcd 100644 --- a/lib/insights_cloud/async/connector_playbook_execution_reporter_task.rb +++ b/lib/insights_cloud/async/connector_playbook_execution_reporter_task.rb @@ -46,6 +46,10 @@ def done?(current_status = invocation_status) ActiveModel::Type::Boolean.new.cast(current_status[:task_state][:task_done_reported]) end + def job_finished? + job_invocation.finished? + end + # noop, we don't want to do anything when the polling task starts def invoke_external_task poll_external_task diff --git a/test/jobs/connector_playbook_execution_reporter_task_test.rb b/test/jobs/connector_playbook_execution_reporter_task_test.rb index 2111bc24..dc3e7173 100644 --- a/test/jobs/connector_playbook_execution_reporter_task_test.rb +++ b/test/jobs/connector_playbook_execution_reporter_task_test.rb @@ -71,7 +71,7 @@ def send_report(report) host1_task.state = 'running' host1_task.save! - JobInvocation.any_instance.stubs(:finished?).returns(false) + ArrangeTestHost.any_instance.stubs(:job_finished?).returns(false, true) actual = ForemanTasks.sync_task(ArrangeTestHost, @job_invocation)