diff --git a/app/workers/stuck_merge_jobs_worker.rb b/app/workers/stuck_merge_jobs_worker.rb index 98c81956cba..f34ed6c4844 100644 --- a/app/workers/stuck_merge_jobs_worker.rb +++ b/app/workers/stuck_merge_jobs_worker.rb @@ -4,6 +4,10 @@ class StuckMergeJobsWorker include ApplicationWorker include CronjobQueue + def self.logger + Rails.logger + end + # rubocop: disable CodeReuse/ActiveRecord def perform stuck_merge_requests.find_in_batches(batch_size: 100) do |group| @@ -35,7 +39,7 @@ class StuckMergeJobsWorker # We rely on state machine callbacks to update head_pipeline_id merge_requests_to_reopen.each(&:unlock_mr) - Rails.logger.info("Updated state of locked merge jobs. JIDs: #{completed_jids.join(', ')}") + self.class.logger.info("Updated state of locked merge jobs. JIDs: #{completed_jids.join(', ')}") end # rubocop: enable CodeReuse/ActiveRecord diff --git a/spec/workers/stuck_merge_jobs_worker_spec.rb b/spec/workers/stuck_merge_jobs_worker_spec.rb index c2c2a5f9121..5aaff27a6b2 100644 --- a/spec/workers/stuck_merge_jobs_worker_spec.rb +++ b/spec/workers/stuck_merge_jobs_worker_spec.rb @@ -38,7 +38,8 @@ describe StuckMergeJobsWorker do create(:merge_request, :locked, merge_jid: '123') create(:merge_request, :locked, merge_jid: '456') - expect(Rails).to receive_message_chain(:logger, :info).with('Updated state of locked merge jobs. JIDs: 123, 456') + expect(described_class).to receive_message_chain(:logger, :info) + .with('Updated state of locked merge jobs. JIDs: 123, 456') worker.perform end