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-05-17 19:05:49 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-05-17 19:05:49 +0300
commit43a25d93ebdabea52f99b05e15b06250cd8f07d7 (patch)
treedceebdc68925362117480a5d672bcff122fb625b /spec/lib/gitlab/github_import/representation
parent20c84b99005abd1c82101dfeff264ac50d2df211 (diff)
Add latest changes from gitlab-org/gitlab@16-0-stable-eev16.0.0-rc42
Diffstat (limited to 'spec/lib/gitlab/github_import/representation')
-rw-r--r--spec/lib/gitlab/github_import/representation/collaborator_spec.rb50
-rw-r--r--spec/lib/gitlab/github_import/representation/diff_note_spec.rb2
-rw-r--r--spec/lib/gitlab/github_import/representation/issue_event_spec.rb6
-rw-r--r--spec/lib/gitlab/github_import/representation/issue_spec.rb3
-rw-r--r--spec/lib/gitlab/github_import/representation/lfs_object_spec.rb3
-rw-r--r--spec/lib/gitlab/github_import/representation/note_spec.rb24
-rw-r--r--spec/lib/gitlab/github_import/representation/note_text_spec.rb110
-rw-r--r--spec/lib/gitlab/github_import/representation/pull_request_review_spec.rb2
-rw-r--r--spec/lib/gitlab/github_import/representation/pull_request_spec.rb3
-rw-r--r--spec/lib/gitlab/github_import/representation/pull_requests/review_requests_spec.rb23
10 files changed, 189 insertions, 37 deletions
diff --git a/spec/lib/gitlab/github_import/representation/collaborator_spec.rb b/spec/lib/gitlab/github_import/representation/collaborator_spec.rb
new file mode 100644
index 00000000000..cc52c34ec74
--- /dev/null
+++ b/spec/lib/gitlab/github_import/representation/collaborator_spec.rb
@@ -0,0 +1,50 @@
+# frozen_string_literal: true
+
+require 'fast_spec_helper'
+
+RSpec.describe Gitlab::GithubImport::Representation::Collaborator, feature_category: :importers do
+ shared_examples 'a Collaborator' do
+ it 'returns an instance of Collaborator' do
+ expect(collaborator).to be_an_instance_of(described_class)
+ end
+
+ context 'with Collaborator' do
+ it 'includes the user ID' do
+ expect(collaborator.id).to eq(42)
+ end
+
+ it 'includes the username' do
+ expect(collaborator.login).to eq('alice')
+ end
+
+ it 'includes the role' do
+ expect(collaborator.role_name).to eq('maintainer')
+ end
+
+ describe '#github_identifiers' do
+ it 'returns a hash with needed identifiers' do
+ expect(collaborator.github_identifiers).to eq(
+ {
+ id: 42,
+ login: 'alice'
+ }
+ )
+ end
+ end
+ end
+ end
+
+ describe '.from_api_response' do
+ it_behaves_like 'a Collaborator' do
+ let(:response) { { id: 42, login: 'alice', role_name: 'maintainer' } }
+ let(:collaborator) { described_class.from_api_response(response) }
+ end
+ end
+
+ describe '.from_json_hash' do
+ it_behaves_like 'a Collaborator' do
+ let(:hash) { { 'id' => 42, 'login' => 'alice', role_name: 'maintainer' } }
+ let(:collaborator) { described_class.from_json_hash(hash) }
+ end
+ end
+end
diff --git a/spec/lib/gitlab/github_import/representation/diff_note_spec.rb b/spec/lib/gitlab/github_import/representation/diff_note_spec.rb
index 56fabe854f9..3e76b4ae698 100644
--- a/spec/lib/gitlab/github_import/representation/diff_note_spec.rb
+++ b/spec/lib/gitlab/github_import/representation/diff_note_spec.rb
@@ -131,7 +131,7 @@ RSpec.describe Gitlab::GithubImport::Representation::DiffNote, :clean_gitlab_red
describe '#github_identifiers' do
it 'returns a hash with needed identifiers' do
expect(note.github_identifiers).to eq(
- noteable_id: 42,
+ noteable_iid: 42,
noteable_type: 'MergeRequest',
note_id: 1
)
diff --git a/spec/lib/gitlab/github_import/representation/issue_event_spec.rb b/spec/lib/gitlab/github_import/representation/issue_event_spec.rb
index 0dd281cb3b0..6620dee0fd0 100644
--- a/spec/lib/gitlab/github_import/representation/issue_event_spec.rb
+++ b/spec/lib/gitlab/github_import/representation/issue_event_spec.rb
@@ -156,7 +156,11 @@ RSpec.describe Gitlab::GithubImport::Representation::IssueEvent do
describe '#github_identifiers' do
it 'returns a hash with needed identifiers' do
- expect(issue_event.github_identifiers).to eq({ id: 6501124486 })
+ expect(issue_event.github_identifiers).to eq(
+ id: 6501124486,
+ issuable_iid: 2,
+ event: 'closed'
+ )
end
end
end
diff --git a/spec/lib/gitlab/github_import/representation/issue_spec.rb b/spec/lib/gitlab/github_import/representation/issue_spec.rb
index 263ef8b1708..39447da0fac 100644
--- a/spec/lib/gitlab/github_import/representation/issue_spec.rb
+++ b/spec/lib/gitlab/github_import/representation/issue_spec.rb
@@ -192,7 +192,8 @@ RSpec.describe Gitlab::GithubImport::Representation::Issue do
it 'returns a hash with needed identifiers' do
github_identifiers = {
iid: 42,
- issuable_type: 'MergeRequest'
+ issuable_type: 'MergeRequest',
+ title: 'Implement cool feature'
}
other_attributes = { pull_request: true, something_else: '_something_else_' }
issue = described_class.new(github_identifiers.merge(other_attributes))
diff --git a/spec/lib/gitlab/github_import/representation/lfs_object_spec.rb b/spec/lib/gitlab/github_import/representation/lfs_object_spec.rb
index 6663a7366a5..799a77afb0c 100644
--- a/spec/lib/gitlab/github_import/representation/lfs_object_spec.rb
+++ b/spec/lib/gitlab/github_import/representation/lfs_object_spec.rb
@@ -6,7 +6,8 @@ RSpec.describe Gitlab::GithubImport::Representation::LfsObject do
describe '#github_identifiers' do
it 'returns a hash with needed identifiers' do
github_identifiers = {
- oid: 42
+ oid: 42,
+ size: 123456
}
other_attributes = { something_else: '_something_else_' }
lfs_object = described_class.new(github_identifiers.merge(other_attributes))
diff --git a/spec/lib/gitlab/github_import/representation/note_spec.rb b/spec/lib/gitlab/github_import/representation/note_spec.rb
index 49126dbe9c5..5c2cea3653f 100644
--- a/spec/lib/gitlab/github_import/representation/note_spec.rb
+++ b/spec/lib/gitlab/github_import/representation/note_spec.rb
@@ -43,6 +43,16 @@ RSpec.describe Gitlab::GithubImport::Representation::Note do
it 'includes the note ID' do
expect(note.note_id).to eq(1)
end
+
+ describe '#github_identifiers' do
+ it 'returns a hash with needed identifiers' do
+ expect(note.github_identifiers).to eq(
+ noteable_iid: 42,
+ noteable_type: 'Issue',
+ note_id: 1
+ )
+ end
+ end
end
end
@@ -103,18 +113,4 @@ RSpec.describe Gitlab::GithubImport::Representation::Note do
expect(note.author).to be_nil
end
end
-
- describe '#github_identifiers' do
- it 'returns a hash with needed identifiers' do
- github_identifiers = {
- noteable_id: 42,
- noteable_type: 'Issue',
- note_id: 1
- }
- other_attributes = { something_else: '_something_else_' }
- note = described_class.new(github_identifiers.merge(other_attributes))
-
- expect(note.github_identifiers).to eq(github_identifiers)
- end
- end
end
diff --git a/spec/lib/gitlab/github_import/representation/note_text_spec.rb b/spec/lib/gitlab/github_import/representation/note_text_spec.rb
index 8b57c9a0373..7aa458a1c33 100644
--- a/spec/lib/gitlab/github_import/representation/note_text_spec.rb
+++ b/spec/lib/gitlab/github_import/representation/note_text_spec.rb
@@ -22,35 +22,45 @@ RSpec.describe Gitlab::GithubImport::Representation::NoteText do
end
describe '.from_db_record' do
+ let(:representation) { described_class.from_db_record(record) }
+
context 'with Release' do
- let(:record) { build_stubbed(:release, id: 42, description: 'Some text here..') }
+ let(:record) { build_stubbed(:release, id: 42, description: 'Some text here..', tag: 'v1.0') }
+
+ it_behaves_like 'a Note text data', 'Release'
- it_behaves_like 'a Note text data', 'Release' do
- let(:representation) { described_class.from_db_record(record) }
+ it 'includes tag' do
+ expect(representation.tag).to eq 'v1.0'
end
end
context 'with Issue' do
- let(:record) { build_stubbed(:issue, id: 42, description: 'Some text here..') }
+ let(:record) { build_stubbed(:issue, id: 42, iid: 2, description: 'Some text here..') }
+
+ it_behaves_like 'a Note text data', 'Issue'
- it_behaves_like 'a Note text data', 'Issue' do
- let(:representation) { described_class.from_db_record(record) }
+ it 'includes noteable iid' do
+ expect(representation.iid).to eq 2
end
end
context 'with MergeRequest' do
- let(:record) { build_stubbed(:merge_request, id: 42, description: 'Some text here..') }
+ let(:record) { build_stubbed(:merge_request, id: 42, iid: 2, description: 'Some text here..') }
- it_behaves_like 'a Note text data', 'MergeRequest' do
- let(:representation) { described_class.from_db_record(record) }
+ it_behaves_like 'a Note text data', 'MergeRequest'
+
+ it 'includes noteable iid' do
+ expect(representation.iid).to eq 2
end
end
context 'with Note' do
- let(:record) { build_stubbed(:note, id: 42, note: 'Some text here..') }
+ let(:record) { build_stubbed(:note, id: 42, note: 'Some text here..', noteable_type: 'Issue') }
+
+ it_behaves_like 'a Note text data', 'Note'
- it_behaves_like 'a Note text data', 'Note' do
- let(:representation) { described_class.from_db_record(record) }
+ it 'includes noteable type' do
+ expect(representation.noteable_type).to eq 'Issue'
end
end
end
@@ -61,7 +71,8 @@ RSpec.describe Gitlab::GithubImport::Representation::NoteText do
{
'record_db_id' => 42,
'record_type' => 'Release',
- 'text' => 'Some text here..'
+ 'text' => 'Some text here..',
+ 'tag' => 'v1.0'
}
end
@@ -70,11 +81,76 @@ RSpec.describe Gitlab::GithubImport::Representation::NoteText do
end
describe '#github_identifiers' do
- it 'returns a hash with needed identifiers' do
- record_id = rand(100)
- representation = described_class.new(record_db_id: record_id, text: 'text')
+ let(:iid) { nil }
+ let(:tag) { nil }
+ let(:noteable_type) { nil }
+ let(:hash) do
+ {
+ 'record_db_id' => 42,
+ 'record_type' => record_type,
+ 'text' => 'Some text here..',
+ 'iid' => iid,
+ 'tag' => tag,
+ 'noteable_type' => noteable_type
+ }
+ end
+
+ subject { described_class.from_json_hash(hash) }
+
+ context 'with Release' do
+ let(:record_type) { 'Release' }
+ let(:tag) { 'v1.0' }
+
+ it 'returns a hash with needed identifiers' do
+ expect(subject.github_identifiers).to eq(
+ {
+ db_id: 42,
+ tag: 'v1.0'
+ }
+ )
+ end
+ end
+
+ context 'with Issue' do
+ let(:record_type) { 'Issue' }
+ let(:iid) { 2 }
+
+ it 'returns a hash with needed identifiers' do
+ expect(subject.github_identifiers).to eq(
+ {
+ db_id: 42,
+ noteable_iid: 2
+ }
+ )
+ end
+ end
- expect(representation.github_identifiers).to eq({ db_id: record_id })
+ context 'with Merge Request' do
+ let(:record_type) { 'MergeRequest' }
+ let(:iid) { 3 }
+
+ it 'returns a hash with needed identifiers' do
+ expect(subject.github_identifiers).to eq(
+ {
+ db_id: 42,
+ noteable_iid: 3
+ }
+ )
+ end
+ end
+
+ context 'with Note' do
+ let(:record_type) { 'Note' }
+ let(:noteable_type) { 'MergeRequest' }
+
+ it 'returns a hash with needed identifiers' do
+ expect(subject.github_identifiers).to eq(
+ {
+ db_id: 42,
+ noteable_type: 'MergeRequest'
+ }
+ )
+ end
end
end
end
diff --git a/spec/lib/gitlab/github_import/representation/pull_request_review_spec.rb b/spec/lib/gitlab/github_import/representation/pull_request_review_spec.rb
index 0203da9f4fb..8925f466e27 100644
--- a/spec/lib/gitlab/github_import/representation/pull_request_review_spec.rb
+++ b/spec/lib/gitlab/github_import/representation/pull_request_review_spec.rb
@@ -77,7 +77,7 @@ RSpec.describe Gitlab::GithubImport::Representation::PullRequestReview do
it 'returns a hash with needed identifiers' do
github_identifiers = {
review_id: 999,
- merge_request_id: 42
+ merge_request_iid: 1
}
other_attributes = { something_else: '_something_else_' }
review = described_class.new(github_identifiers.merge(other_attributes))
diff --git a/spec/lib/gitlab/github_import/representation/pull_request_spec.rb b/spec/lib/gitlab/github_import/representation/pull_request_spec.rb
index b8c1c67e07c..4b8e7401e9d 100644
--- a/spec/lib/gitlab/github_import/representation/pull_request_spec.rb
+++ b/spec/lib/gitlab/github_import/representation/pull_request_spec.rb
@@ -287,7 +287,8 @@ RSpec.describe Gitlab::GithubImport::Representation::PullRequest do
describe '#github_identifiers' do
it 'returns a hash with needed identifiers' do
github_identifiers = {
- iid: 1
+ iid: 1,
+ title: 'My Pull Request'
}
other_attributes = { something_else: '_something_else_' }
pr = described_class.new(github_identifiers.merge(other_attributes))
diff --git a/spec/lib/gitlab/github_import/representation/pull_requests/review_requests_spec.rb b/spec/lib/gitlab/github_import/representation/pull_requests/review_requests_spec.rb
index 0393f692a69..0259fbedee3 100644
--- a/spec/lib/gitlab/github_import/representation/pull_requests/review_requests_spec.rb
+++ b/spec/lib/gitlab/github_import/representation/pull_requests/review_requests_spec.rb
@@ -46,4 +46,27 @@ RSpec.describe Gitlab::GithubImport::Representation::PullRequests::ReviewRequest
let(:review_requests) { described_class.from_json_hash(response) }
end
end
+
+ describe '#github_identifiers' do
+ it 'returns a hash with needed identifiers' do
+ review_requests = {
+ merge_request_iid: 2,
+ merge_request_id: merge_request_id,
+ users: [
+ { id: 4, login: 'alice' },
+ { id: 5, login: 'bob' }
+ ]
+ }
+
+ github_identifiers = {
+ merge_request_iid: 2,
+ requested_reviewers: %w[alice bob]
+ }
+
+ other_attributes = { merge_request_id: 123, something_else: '_something_else_' }
+ review_requests = described_class.new(review_requests.merge(other_attributes))
+
+ expect(review_requests.github_identifiers).to eq(github_identifiers)
+ end
+ end
end