diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-18 15:09:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-18 15:09:13 +0300 |
commit | 1363ca12f1f07c634647cf55c4c16b7401098673 (patch) | |
tree | d932caf09c8148322edb51ae954ed159ff7d00f8 /spec/workers/gitlab/jira_import/stage/start_import_worker_spec.rb | |
parent | 6763d2787670bc03a36a8eb601703e88fc70dece (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers/gitlab/jira_import/stage/start_import_worker_spec.rb')
-rw-r--r-- | spec/workers/gitlab/jira_import/stage/start_import_worker_spec.rb | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/spec/workers/gitlab/jira_import/stage/start_import_worker_spec.rb b/spec/workers/gitlab/jira_import/stage/start_import_worker_spec.rb new file mode 100644 index 00000000000..cc70277384d --- /dev/null +++ b/spec/workers/gitlab/jira_import/stage/start_import_worker_spec.rb @@ -0,0 +1,86 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Gitlab::JiraImport::Stage::StartImportWorker do + let(:project) { create(:project) } + let(:worker) { described_class.new } + let(:jid) { '12345678' } + + describe 'modules' do + it_behaves_like 'include import workers modules' + end + + describe '#perform' do + context 'when feature flag not enabled' do + before do + stub_feature_flags(jira_issue_import: false) + end + + it 'exits because import not allowed' do + expect(Gitlab::JiraImport::Stage::ImportLabelsWorker).not_to receive(:perform_async) + + worker.perform(project.id) + end + end + + context 'when feature flag not enabled' do + before do + stub_feature_flags(jira_issue_import: true) + end + + context 'when import is not scheudled' do + let!(:import_state) { create(:import_state, project: project, status: :none, jid: jid) } + + it 'exits because import not started' do + expect(Gitlab::JiraImport::Stage::ImportLabelsWorker).not_to receive(:perform_async) + + worker.perform(project.id) + end + end + + context 'when import is scheduled' do + let!(:import_state) { create(:import_state, project: project, status: :scheduled, jid: jid) } + + it 'advances to importing labels' do + expect(Gitlab::JiraImport::Stage::ImportLabelsWorker).to receive(:perform_async) + + worker.perform(project.id) + end + end + + context 'when import is started' do + let!(:import_state) { create(:import_state, project: project, status: :started, jid: jid) } + + context 'when this is the same worker that stated import' do + it 'advances to importing labels' do + allow(worker).to receive(:jid).and_return(jid) + expect(Gitlab::JiraImport::Stage::ImportLabelsWorker).to receive(:perform_async) + + worker.perform(project.id) + end + end + + context 'when this is a different worker that stated import' do + it 'advances to importing labels' do + allow(worker).to receive(:jid).and_return('87654321') + expect(Gitlab::JiraImport::Stage::ImportLabelsWorker).not_to receive(:perform_async) + + worker.perform(project.id) + end + end + end + + context 'when import is finished' do + let!(:import_state) { create(:import_state, project: project, status: :finished, jid: jid) } + + it 'advances to importing labels' do + allow(worker).to receive(:jid).and_return(jid) + expect(Gitlab::JiraImport::Stage::ImportLabelsWorker).not_to receive(:perform_async) + + worker.perform(project.id) + end + end + end + end +end |