Merge branch 'osw-adjust-flaky-rails-logger-call' into 'master'

Adjust flaky Rails logger call test

See merge request gitlab-org/gitlab-ce!23916
This commit is contained in:
Rémy Coutable 2018-12-19 12:17:20 +00:00
commit fd86e74327
2 changed files with 7 additions and 2 deletions

View file

@ -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

View file

@ -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