diff --git a/app/models/service.rb b/app/models/service.rb index a158ac642bd..0ff733d5789 100644 --- a/app/models/service.rb +++ b/app/models/service.rb @@ -392,14 +392,23 @@ def chargeback_yaml end def queue_chargeback_report_generation(options = {}) + task = MiqTask.create( + :name => "Generating chargeback report with id: #{id}", + :state => MiqTask::STATE_QUEUED, + :status => MiqTask::STATUS_OK, + :message => "Queueing Chargeback of #{self.class.name} with id: #{id}" + ) + MiqQueue.submit_job( :service => "reporting", :class_name => self.class.name, :instance_id => id, + :task_id => task.id, :method_name => "generate_chargeback_report", :args => options ) _log.info("Added to queue: generate_chargeback_report for service #{name}") + task end # diff --git a/spec/models/service_spec.rb b/spec/models/service_spec.rb index 312975c46f2..d7470cbeb66 100644 --- a/spec/models/service_spec.rb +++ b/spec/models/service_spec.rb @@ -453,7 +453,7 @@ :method_name => "generate_chargeback_report", :args => {:report_source => "Test Run"}) end - @service.queue_chargeback_report_generation(:report_source => "Test Run") + expect(@service.queue_chargeback_report_generation(:report_source => "Test Run")).to be_kind_of(MiqTask) end end