diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-15 00:09:20 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-15 00:09:20 +0300 |
commit | db2275b561bace34d90b901226d7f46d33e4cbd9 (patch) | |
tree | 7fde15815e18d0818b9be7ce61ddd90a13ea0f8c /spec/workers/gitlab/github_import | |
parent | 3c6cad91a1a9d8732e8cb998f83d32dc19373b7b (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers/gitlab/github_import')
4 files changed, 51 insertions, 99 deletions
diff --git a/spec/workers/gitlab/github_import/stage/import_attachments_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_attachments_worker_spec.rb index 015a2beed7e..33e2443d106 100644 --- a/spec/workers/gitlab/github_import/stage/import_attachments_worker_spec.rb +++ b/spec/workers/gitlab/github_import/stage/import_attachments_worker_spec.rb @@ -7,7 +7,12 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportAttachmentsWorker do let(:project) { create(:project) } let!(:group) { create(:group, projects: [project]) } - let(:feature_flag_state) { [group] } + let(:settings) { ::Gitlab::GithubImport::Settings.new(project) } + let(:stage_enabled) { true } + + before do + settings.write({ attachments_import: stage_enabled }) + end describe '#import' do let(:releases_importer) { instance_double('Gitlab::GithubImport::Importer::Attachments::ReleasesImporter') } @@ -16,10 +21,6 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportAttachmentsWorker do let(:releases_waiter) { Gitlab::JobWaiter.new(2, '123') } let(:notes_waiter) { Gitlab::JobWaiter.new(3, '234') } - before do - stub_feature_flags(github_importer_attachments_import: feature_flag_state) - end - it 'imports release attachments' do expect(Gitlab::GithubImport::Importer::Attachments::ReleasesImporter) .to receive(:new) @@ -40,8 +41,8 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportAttachmentsWorker do worker.import(client, project) end - context 'when feature flag is disabled' do - let(:feature_flag_state) { false } + context 'when stage is disabled' do + let(:stage_enabled) { false } it 'skips release attachments import and calls next stage' do expect(Gitlab::GithubImport::Importer::Attachments::ReleasesImporter).not_to receive(:new) diff --git a/spec/workers/gitlab/github_import/stage/import_issue_events_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_issue_events_worker_spec.rb index 932152c0764..199d1b9a3ca 100644 --- a/spec/workers/gitlab/github_import/stage/import_issue_events_worker_spec.rb +++ b/spec/workers/gitlab/github_import/stage/import_issue_events_worker_spec.rb @@ -7,23 +7,21 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportIssueEventsWorker do let(:project) { create(:project) } let!(:group) { create(:group, projects: [project]) } - let(:feature_flag_state) { [group] } - let(:single_endpoint_feature_flag_state) { [group] } + let(:settings) { ::Gitlab::GithubImport::Settings.new(project) } + let(:stage_enabled) { true } + + before do + settings.write({ single_endpoint_issue_events_import: stage_enabled }) + end describe '#import' do let(:importer) { instance_double('Gitlab::GithubImport::Importer::SingleEndpointIssueEventsImporter') } let(:client) { instance_double('Gitlab::GithubImport::Client') } - before do - stub_feature_flags(github_importer_single_endpoint_issue_events_import: single_endpoint_feature_flag_state) - stub_feature_flags(github_importer_issue_events_import: feature_flag_state) - end - - context 'when single endpoint feature flag enabled' do - it 'imports all the issue events' do + context 'when stage is enabled' do + it 'imports issue events' do waiter = Gitlab::JobWaiter.new(2, '123') - expect(Gitlab::GithubImport::Importer::IssueEventsImporter).not_to receive(:new) expect(Gitlab::GithubImport::Importer::SingleEndpointIssueEventsImporter) .to receive(:new) .with(project, client) @@ -39,35 +37,11 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportIssueEventsWorker do end end - context 'when import issue events feature flag enabled' do - let(:single_endpoint_feature_flag_state) { false } - - it 'imports the issue events partly' do - waiter = Gitlab::JobWaiter.new(2, '123') - - expect(Gitlab::GithubImport::Importer::SingleEndpointIssueEventsImporter).not_to receive(:new) - expect(Gitlab::GithubImport::Importer::IssueEventsImporter) - .to receive(:new) - .with(project, client) - .and_return(importer) - - expect(importer).to receive(:execute).and_return(waiter) - - expect(Gitlab::GithubImport::AdvanceStageWorker) - .to receive(:perform_async) - .with(project.id, { '123' => 2 }, :notes) - - worker.import(client, project) - end - end - - context 'when feature flags are disabled' do - let(:feature_flag_state) { false } - let(:single_endpoint_feature_flag_state) { false } + context 'when stage is disabled' do + let(:stage_enabled) { false } it 'skips issue events import and calls next stage' do expect(Gitlab::GithubImport::Importer::SingleEndpointIssueEventsImporter).not_to receive(:new) - expect(Gitlab::GithubImport::Importer::IssueEventsImporter).not_to receive(:new) expect(Gitlab::GithubImport::AdvanceStageWorker).to receive(:perform_async).with(project.id, {}, :notes) worker.import(client, project) diff --git a/spec/workers/gitlab/github_import/stage/import_issues_and_diff_notes_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_issues_and_diff_notes_worker_spec.rb index a88256b3cae..beef0864715 100644 --- a/spec/workers/gitlab/github_import/stage/import_issues_and_diff_notes_worker_spec.rb +++ b/spec/workers/gitlab/github_import/stage/import_issues_and_diff_notes_worker_spec.rb @@ -6,6 +6,13 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportIssuesAndDiffNotesWorker do let(:project) { create(:project) } let(:worker) { described_class.new } + let(:settings) { ::Gitlab::GithubImport::Settings.new(project) } + let(:single_endpoint_optional_stage) { true } + + before do + settings.write({ single_endpoint_notes_import: single_endpoint_optional_stage }) + end + describe '#import' do it 'imports the issues and diff notes' do client = double(:client) @@ -33,37 +40,18 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportIssuesAndDiffNotesWorker do end describe '#importers' do - context 'when project group is present' do - let_it_be(:project) { create(:project) } - let_it_be(:group) { create(:group, projects: [project]) } - - context 'when feature flag github_importer_single_endpoint_notes_import is enabled' do - it 'includes single endpoint diff notes importer' do - project = create(:project) - group = create(:group, projects: [project]) - - stub_feature_flags(github_importer_single_endpoint_notes_import: group) - - expect(worker.importers(project)).to contain_exactly( - Gitlab::GithubImport::Importer::IssuesImporter, - Gitlab::GithubImport::Importer::SingleEndpointDiffNotesImporter - ) - end - end - - context 'when feature flag github_importer_single_endpoint_notes_import is disabled' do - it 'includes default diff notes importer' do - stub_feature_flags(github_importer_single_endpoint_notes_import: false) - - expect(worker.importers(project)).to contain_exactly( - Gitlab::GithubImport::Importer::IssuesImporter, - Gitlab::GithubImport::Importer::DiffNotesImporter - ) - end + context 'when optional stage single_endpoint_notes_import is enabled' do + it 'includes single endpoint diff notes importer' do + expect(worker.importers(project)).to contain_exactly( + Gitlab::GithubImport::Importer::IssuesImporter, + Gitlab::GithubImport::Importer::SingleEndpointDiffNotesImporter + ) end end - context 'when project group is missing' do + context 'when optional stage single_endpoint_notes_import is disabled' do + let(:single_endpoint_optional_stage) { false } + it 'includes default diff notes importer' do expect(worker.importers(project)).to contain_exactly( Gitlab::GithubImport::Importer::IssuesImporter, diff --git a/spec/workers/gitlab/github_import/stage/import_notes_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_notes_worker_spec.rb index adf20d24a7e..dbcf2083ec1 100644 --- a/spec/workers/gitlab/github_import/stage/import_notes_worker_spec.rb +++ b/spec/workers/gitlab/github_import/stage/import_notes_worker_spec.rb @@ -6,6 +6,13 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportNotesWorker do let(:project) { create(:project) } let(:worker) { described_class.new } + let(:settings) { ::Gitlab::GithubImport::Settings.new(project) } + let(:single_endpoint_optional_stage) { true } + + before do + settings.write({ single_endpoint_notes_import: single_endpoint_optional_stage }) + end + describe '#import' do it 'imports all the notes' do client = double(:client) @@ -33,37 +40,19 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportNotesWorker do end describe '#importers' do - context 'when project group is present' do - let_it_be(:project) { create(:project) } - let_it_be(:group) { create(:group, projects: [project]) } - - context 'when feature flag github_importer_single_endpoint_notes_import is enabled' do - it 'includes single endpoint mr and issue notes importers' do - project = create(:project) - group = create(:group, projects: [project]) - - stub_feature_flags(github_importer_single_endpoint_notes_import: group) - - expect(worker.importers(project)).to contain_exactly( - Gitlab::GithubImport::Importer::SingleEndpointMergeRequestNotesImporter, - Gitlab::GithubImport::Importer::SingleEndpointIssueNotesImporter - ) - end - end - - context 'when feature flag github_importer_single_endpoint_notes_import is disabled' do - it 'includes default notes importer' do - stub_feature_flags(github_importer_single_endpoint_notes_import: false) - - expect(worker.importers(project)).to contain_exactly( - Gitlab::GithubImport::Importer::NotesImporter - ) - end + context 'when settings single_endpoint_notes_import is enabled' do + it 'includes single endpoint mr and issue notes importers' do + expect(worker.importers(project)).to contain_exactly( + Gitlab::GithubImport::Importer::SingleEndpointMergeRequestNotesImporter, + Gitlab::GithubImport::Importer::SingleEndpointIssueNotesImporter + ) end end - context 'when project group is missing' do - it 'includes default diff notes importer' do + context 'when settings single_endpoint_notes_import is disabled' do + let(:single_endpoint_optional_stage) { false } + + it 'includes default notes importer' do expect(worker.importers(project)).to contain_exactly( Gitlab::GithubImport::Importer::NotesImporter ) |