2020-06-23 00:09:42 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe ::Gitlab::JiraImport::StuckJiraImportJobsWorker do
|
2020-06-23 00:09:42 +05:30
|
|
|
let_it_be(:current_user) { create(:user) }
|
|
|
|
let_it_be(:project) { create(:project) }
|
|
|
|
let(:worker) { described_class.new }
|
|
|
|
|
|
|
|
describe 'with scheduled Jira import' do
|
|
|
|
it_behaves_like 'stuck import job detection' do
|
|
|
|
let(:import_state) { create(:jira_import_state, :scheduled, project: project) }
|
|
|
|
|
|
|
|
before do
|
2020-10-24 23:57:45 +05:30
|
|
|
import_state.update!(jid: '123')
|
2020-06-23 00:09:42 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'with started jira import' do
|
|
|
|
it_behaves_like 'stuck import job detection' do
|
|
|
|
let(:import_state) { create(:jira_import_state, :started, project: project) }
|
|
|
|
|
|
|
|
before do
|
2020-10-24 23:57:45 +05:30
|
|
|
import_state.update!(jid: '123')
|
2020-06-23 00:09:42 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'with failed jira import' do
|
|
|
|
let(:import_state) { create(:jira_import_state, :failed, project: project) }
|
|
|
|
|
|
|
|
it 'detects no stuck jobs' do
|
|
|
|
expect(worker).to receive(:track_metrics).with(0, 0)
|
|
|
|
|
|
|
|
worker.perform
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|