diff options
Diffstat (limited to 'spec/workers/gitlab/github_import/stage')
-rw-r--r-- | spec/workers/gitlab/github_import/stage/import_issues_and_diff_notes_worker_spec.rb | 43 | ||||
-rw-r--r-- | spec/workers/gitlab/github_import/stage/import_notes_worker_spec.rb | 60 |
2 files changed, 93 insertions, 10 deletions
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 f2a28ec40b8..c0dd4f488cc 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 @@ -10,7 +10,7 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportIssuesAndDiffNotesWorker do it 'imports the issues and diff notes' do client = double(:client) - described_class::IMPORTERS.each do |klass| + worker.importers(project).each do |klass| importer = double(:importer) waiter = Gitlab::JobWaiter.new(2, '123') @@ -31,4 +31,45 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportIssuesAndDiffNotesWorker do worker.import(client, project) end 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 + end + end + + context 'when project group is missing' do + it 'includes default diff notes importer' do + expect(worker.importers(project)).to contain_exactly( + Gitlab::GithubImport::Importer::IssuesImporter, + Gitlab::GithubImport::Importer::DiffNotesImporter + ) + end + end + end end 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 73b19239f4a..f9f21e4dfa2 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 @@ -8,18 +8,21 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportNotesWorker do describe '#import' do it 'imports all the notes' do - importer = double(:importer) client = double(:client) - waiter = Gitlab::JobWaiter.new(2, '123') - expect(Gitlab::GithubImport::Importer::NotesImporter) - .to receive(:new) - .with(project, client) - .and_return(importer) + worker.importers(project).each do |klass| + importer = double(:importer) + waiter = Gitlab::JobWaiter.new(2, '123') - expect(importer) - .to receive(:execute) - .and_return(waiter) + expect(klass) + .to receive(:new) + .with(project, client) + .and_return(importer) + + expect(importer) + .to receive(:execute) + .and_return(waiter) + end expect(Gitlab::GithubImport::AdvanceStageWorker) .to receive(:perform_async) @@ -28,4 +31,43 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportNotesWorker do worker.import(client, project) end 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 + end + end + + context 'when project group is missing' do + it 'includes default diff notes importer' do + expect(worker.importers(project)).to contain_exactly( + Gitlab::GithubImport::Importer::NotesImporter + ) + end + end + end end |