Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-10-19 15:57:54 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-10-19 15:57:54 +0300
commit419c53ec62de6e97a517abd5fdd4cbde3a942a34 (patch)
tree1f43a548b46bca8a5fb8fe0c31cef1883d49c5b6 /spec/lib/gitlab/bitbucket_import/importers/pull_request_notes_importer_spec.rb
parent1da20d9135b3ad9e75e65b028bffc921aaf8deb7 (diff)
Add latest changes from gitlab-org/gitlab@16-5-stable-eev16.5.0-rc42
Diffstat (limited to 'spec/lib/gitlab/bitbucket_import/importers/pull_request_notes_importer_spec.rb')
-rw-r--r--spec/lib/gitlab/bitbucket_import/importers/pull_request_notes_importer_spec.rb68
1 files changed, 68 insertions, 0 deletions
diff --git a/spec/lib/gitlab/bitbucket_import/importers/pull_request_notes_importer_spec.rb b/spec/lib/gitlab/bitbucket_import/importers/pull_request_notes_importer_spec.rb
new file mode 100644
index 00000000000..4a30f225d66
--- /dev/null
+++ b/spec/lib/gitlab/bitbucket_import/importers/pull_request_notes_importer_spec.rb
@@ -0,0 +1,68 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Gitlab::BitbucketImport::Importers::PullRequestNotesImporter, feature_category: :importers do
+ let_it_be(:project) do
+ create(:project, :import_started,
+ import_data_attributes: {
+ credentials: { 'base_uri' => 'http://bitbucket.org/', 'user' => 'bitbucket', 'password' => 'password' }
+ }
+ )
+ end
+
+ let_it_be(:merge_request) { create(:merge_request, source_project: project) }
+
+ let(:hash) { { iid: merge_request.iid } }
+ let(:importer_helper) { Gitlab::BitbucketImport::Importer.new(project) }
+
+ subject(:importer) { described_class.new(project, hash) }
+
+ before do
+ allow(Gitlab::BitbucketImport::Importer).to receive(:new).and_return(importer_helper)
+ end
+
+ describe '#execute' do
+ it 'calls Importer.import_pull_request_comments' do
+ expect(importer_helper).to receive(:import_pull_request_comments).once
+
+ importer.execute
+ end
+
+ context 'when the merge request does not exist' do
+ let(:hash) { { iid: 'nonexistent' } }
+
+ it 'does not call Importer.import_pull_request_comments' do
+ expect(importer_helper).not_to receive(:import_pull_request_comments)
+
+ importer.execute
+ end
+ end
+
+ context 'when the merge request exists but not for this project' do
+ let_it_be(:another_project) { create(:project) }
+
+ before do
+ merge_request.update!(source_project: another_project, target_project: another_project)
+ end
+
+ it 'does not call Importer.import_pull_request_comments' do
+ expect(importer_helper).not_to receive(:import_pull_request_comments)
+
+ importer.execute
+ end
+ end
+
+ context 'when an error is raised' do
+ before do
+ allow(importer_helper).to receive(:import_pull_request_comments).and_raise(StandardError)
+ end
+
+ it 'tracks the failure and does not fail' do
+ expect(Gitlab::Import::ImportFailureService).to receive(:track).once
+
+ importer.execute
+ end
+ end
+ end
+end