2019-07-07 11:18:12 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-03 12:29:30 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe UpdateMergeRequestsWorker do
|
|
|
|
include RepoHelpers
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
let(:project) { create(:project, :repository) }
|
2016-11-03 12:29:30 +05:30
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
subject { described_class.new }
|
|
|
|
|
|
|
|
describe '#perform' do
|
|
|
|
let(:oldrev) { "123456" }
|
|
|
|
let(:newrev) { "789012" }
|
|
|
|
let(:ref) { "refs/heads/test" }
|
|
|
|
|
|
|
|
def perform
|
|
|
|
subject.perform(project.id, user.id, oldrev, newrev, ref)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'executes MergeRequests::RefreshService with expected values' do
|
2018-11-08 19:23:39 +05:30
|
|
|
expect_next_instance_of(MergeRequests::RefreshService, project, user) do |refresh_service|
|
|
|
|
expect(refresh_service).to receive(:execute).with(oldrev, newrev, ref)
|
|
|
|
end
|
2016-11-03 12:29:30 +05:30
|
|
|
|
|
|
|
perform
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
context 'when slow' do
|
|
|
|
before do
|
|
|
|
stub_const("UpdateMergeRequestsWorker::LOG_TIME_THRESHOLD", -1)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'logs debug info' do
|
|
|
|
expect(Rails.logger).to receive(:info).with(a_string_matching(/\AUpdateMergeRequestsWorker#perform.*project_id=#{project.id},user_id=#{user.id},oldrev=#{oldrev},newrev=#{newrev},ref=#{ref}/))
|
|
|
|
|
|
|
|
perform
|
|
|
|
end
|
|
|
|
end
|
2016-11-03 12:29:30 +05:30
|
|
|
end
|
|
|
|
end
|