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:
Diffstat (limited to 'spec/lib/gitlab/github_import/importer/note_importer_spec.rb')
-rw-r--r--spec/lib/gitlab/github_import/importer/note_importer_spec.rb53
1 files changed, 17 insertions, 36 deletions
diff --git a/spec/lib/gitlab/github_import/importer/note_importer_spec.rb b/spec/lib/gitlab/github_import/importer/note_importer_spec.rb
index 5ac50578b6a..91311a8e90f 100644
--- a/spec/lib/gitlab/github_import/importer/note_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/note_importer_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Gitlab::GithubImport::Importer::NoteImporter do
+RSpec.describe Gitlab::GithubImport::Importer::NoteImporter, feature_category: :importers do
let(:client) { double(:client) }
let(:project) { create(:project) }
let(:user) { create(:user) }
@@ -12,13 +12,13 @@ RSpec.describe Gitlab::GithubImport::Importer::NoteImporter do
let(:github_note) do
Gitlab::GithubImport::Representation::Note.new(
+ note_id: 100,
noteable_id: 1,
noteable_type: 'Issue',
author: Gitlab::GithubImport::Representation::User.new(id: 4, login: 'alice'),
note: note_body,
created_at: created_at,
- updated_at: updated_at,
- github_id: 1
+ updated_at: updated_at
)
end
@@ -50,6 +50,7 @@ RSpec.describe Gitlab::GithubImport::Importer::NoteImporter do
noteable_type: 'Issue',
noteable_id: issue_row.id,
project_id: project.id,
+ namespace_id: project.project_namespace_id,
author_id: user.id,
note: 'This is my note',
discussion_id: match(/\A[0-9a-f]{40}\z/),
@@ -81,6 +82,7 @@ RSpec.describe Gitlab::GithubImport::Importer::NoteImporter do
noteable_type: 'Issue',
noteable_id: issue_row.id,
project_id: project.id,
+ namespace_id: project.project_namespace_id,
author_id: project.creator_id,
note: "*Created by: alice*\n\nThis is my note",
discussion_id: match(/\A[0-9a-f]{40}\z/),
@@ -126,34 +128,20 @@ RSpec.describe Gitlab::GithubImport::Importer::NoteImporter do
expect { importer.execute }.to raise_error(ActiveRecord::RecordInvalid)
end
end
- end
-
- context 'when the noteable does not exist' do
- it 'does not import the note' do
- expect(ApplicationRecord).not_to receive(:legacy_bulk_insert)
-
- importer.execute
- end
- end
-
- context 'when the import fails due to a foreign key error' do
- it 'does not raise any errors' do
- issue_row = create(:issue, project: project, iid: 1)
-
- allow(importer)
- .to receive(:find_noteable_id)
- .and_return(issue_row.id)
- allow(importer.user_finder)
- .to receive(:author_id_for)
- .with(github_note)
- .and_return([user.id, true])
-
- expect(ApplicationRecord)
- .to receive(:legacy_bulk_insert)
- .and_raise(ActiveRecord::InvalidForeignKey, 'invalid foreign key')
+ context 'when noteble_id can not be found' do
+ before do
+ allow(importer)
+ .to receive(:find_noteable_id)
+ .and_return(nil)
+ end
- expect { importer.execute }.not_to raise_error
+ it 'raises NoteableNotFound' do
+ expect { importer.execute }.to raise_error(
+ ::Gitlab::GithubImport::Exceptions::NoteableNotFound,
+ 'Error to find noteable_id for note'
+ )
+ end
end
end
@@ -173,13 +161,6 @@ RSpec.describe Gitlab::GithubImport::Importer::NoteImporter do
expect(project.notes.take).to be_valid
end
-
- # rubocop:disable RSpec/AnyInstanceOf
- it 'skips markdown field cache callback' do
- expect_any_instance_of(Note).not_to receive(:refresh_markdown_cache)
- importer.execute
- end
- # rubocop:enable RSpec/AnyInstanceOf
end
describe '#find_noteable_id' do