diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-15 21:10:04 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-15 21:10:04 +0300 |
commit | 5ff1f808adf841bca979cb2fac6bdfa9c449d028 (patch) | |
tree | c95cfbbcb400684b2bc89fee4fc7b614315ba909 /spec/workers/gitlab/github_import | |
parent | f8a5275c45ed2276daf843764113476749e680d2 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers/gitlab/github_import')
-rw-r--r-- | spec/workers/gitlab/github_import/stage/import_collaborators_worker_spec.rb | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/spec/workers/gitlab/github_import/stage/import_collaborators_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_collaborators_worker_spec.rb index 0eac9f21b77..33ecf848997 100644 --- a/spec/workers/gitlab/github_import/stage/import_collaborators_worker_spec.rb +++ b/spec/workers/gitlab/github_import/stage/import_collaborators_worker_spec.rb @@ -5,6 +5,8 @@ require 'spec_helper' RSpec.describe Gitlab::GithubImport::Stage::ImportCollaboratorsWorker, feature_category: :importers do let_it_be(:project) { create(:project) } let_it_be(:import_state) { create(:import_state, project: project) } + let(:settings) { Gitlab::GithubImport::Settings.new(project) } + let(:stage_enabled) { true } let(:worker) { described_class.new } let(:importer) { instance_double(Gitlab::GithubImport::Importer::CollaboratorsImporter) } @@ -14,12 +16,13 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportCollaboratorsWorker, feature_c let(:push_rights_granted) { true } before do + settings.write({ collaborators_import: stage_enabled }) allow(client).to receive(:repository).with(project.import_source) .and_return({ permissions: { push: push_rights_granted } }) end context 'when user has push access for this repo' do - it 'imports all the pull requests' do + it 'imports all collaborators' do waiter = Gitlab::JobWaiter.new(2, '123') expect(Gitlab::GithubImport::Importer::CollaboratorsImporter) @@ -52,6 +55,20 @@ RSpec.describe Gitlab::GithubImport::Stage::ImportCollaboratorsWorker, feature_c end end + context 'when stage is disabled' do + let(:stage_enabled) { false } + + it 'skips collaborators import and calls next stage' do + expect(Gitlab::GithubImport::Importer::CollaboratorsImporter).not_to receive(:new) + + expect(Gitlab::GithubImport::AdvanceStageWorker) + .to receive(:perform_async) + .with(project.id, {}, :pull_requests_merged_by) + + worker.import(client, project) + end + end + it 'raises an error' do exception = StandardError.new('_some_error_') |