diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-09 12:09:24 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-09 12:09:24 +0000 |
commit | a9ced7da447785c57477b3d8dbccc73a78cface1 (patch) | |
tree | 5179d27ab9d801748ee4ed1c64c985974e799812 /spec/workers/gitlab/jira_import/stage/start_import_worker_spec.rb | |
parent | ad0265eead72a624ce7a020847db4f0f0c877e57 (diff) | |
download | gitlab-ce-a9ced7da447785c57477b3d8dbccc73a78cface1.tar.gz |
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 | 46 |
1 files changed, 15 insertions, 31 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 index d5e10a950bb..9cffe6e4ff7 100644 --- a/spec/workers/gitlab/jira_import/stage/start_import_worker_spec.rb +++ b/spec/workers/gitlab/jira_import/stage/start_import_worker_spec.rb @@ -3,16 +3,16 @@ require 'spec_helper' describe Gitlab::JiraImport::Stage::StartImportWorker do - let(:project) { create(:project, import_type: 'jira') } + let_it_be(:project) { create(:project, import_type: 'jira') } + let_it_be(:jid) { '12345678' } 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 + context 'when feature flag not disabled' do before do stub_feature_flags(jira_issue_import: false) end @@ -25,19 +25,13 @@ describe Gitlab::JiraImport::Stage::StartImportWorker do end context 'when feature flag enabled' do - let(:symbol_keys_project) do - { key: 'AA', scheduled_at: 2.days.ago.strftime('%Y-%m-%d %H:%M:%S'), scheduled_by: { 'user_id' => 1, 'name' => 'tester1' } } - end - let(:import_data) { JiraImportData.new( data: { 'jira' => { JiraImportData::FORCE_IMPORT_KEY => true, projects: [symbol_keys_project] } }) } + let_it_be(:jira_import, reload: true) { create(:jira_import_state, project: project, jid: jid) } before do stub_feature_flags(jira_issue_import: true) end context 'when import is not scheduled' do - let(:project) { create(:project, import_type: 'jira') } - 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) @@ -46,32 +40,21 @@ describe Gitlab::JiraImport::Stage::StartImportWorker do end context 'when import is scheduled' do - let(:import_state) { create(:import_state, status: :scheduled, jid: jid) } - let(:project) { create(:project, import_type: 'jira', import_state: import_state) } - - context 'when this is a mirror sync in a jira imported project' do - it 'exits early' do - expect(Gitlab::Import::SetAsyncJid).not_to receive(:set_jid) - expect(Gitlab::JiraImport::Stage::ImportLabelsWorker).not_to receive(:perform_async) - - worker.perform(project.id) - end + before do + jira_import.schedule! end - context 'when scheduled import is a hard triggered jira import and not a mirror' do - let!(:project) { create(:project, import_type: 'jira', import_data: import_data, import_state: import_state) } - - it 'advances to importing labels' do - expect(Gitlab::JiraImport::Stage::ImportLabelsWorker).to receive(:perform_async) + it 'advances to importing labels' do + expect(Gitlab::JiraImport::Stage::ImportLabelsWorker).to receive(:perform_async) - worker.perform(project.id) - end + worker.perform(project.id) end end context 'when import is started' do - let!(:import_state) { create(:import_state, status: :started, jid: jid) } - let!(:project) { create(:project, import_type: 'jira', import_data: import_data, import_state: import_state) } + before do + jira_import.update!(status: :started) + end context 'when this is the same worker that stated import' do it 'advances to importing labels' do @@ -93,8 +76,9 @@ describe Gitlab::JiraImport::Stage::StartImportWorker do end context 'when import is finished' do - let!(:import_state) { create(:import_state, status: :finished, jid: jid) } - let!(:project) { create(:project, import_type: 'jira', import_data: import_data, import_state: import_state) } + before do + jira_import.update!(status: :finished) + end it 'advances to importing labels' do allow(worker).to receive(:jid).and_return(jid) |