Commit c1c6fb33 authored by Patrick Bajao's avatar Patrick Bajao

Merge branch 'kassio/bulkimports-import-group-label-timestamps' into 'master'

BulkImports: Import Label timestamps

See merge request gitlab-org/gitlab!54678
parents 2d12dc1c aa5ec8b0
---
title: 'BulkImports: Import Label timestamps'
merge_request: 54678
author:
type: changed
...@@ -24,7 +24,12 @@ The following resources are migrated to the target instance: ...@@ -24,7 +24,12 @@ The following resources are migrated to the target instance:
- description - description
- attributes - attributes
- subgroups - subgroups
- Labels ([Introduced in 13.9](https://gitlab.com/gitlab-org/gitlab/-/issues/292429)) - Group Labels ([Introduced in 13.9](https://gitlab.com/gitlab-org/gitlab/-/issues/292429))
- title
- description
- color
- created_at ([Introduced in 13.10](https://gitlab.com/gitlab-org/gitlab/-/issues/300007))
- updated_at ([Introduced in 13.10](https://gitlab.com/gitlab-org/gitlab/-/issues/300007))
- Members ([Introduced in 13.9](https://gitlab.com/gitlab-org/gitlab/-/issues/299415)) - Members ([Introduced in 13.9](https://gitlab.com/gitlab-org/gitlab/-/issues/299415))
Group members are associated with the imported group if: Group members are associated with the imported group if:
- The user already exists in the target GitLab instance and - The user already exists in the target GitLab instance and
......
...@@ -19,6 +19,8 @@ module BulkImports ...@@ -19,6 +19,8 @@ module BulkImports
title title
description description
color color
created_at: createdAt
updated_at: updatedAt
} }
} }
} }
......
...@@ -6,6 +6,7 @@ RSpec.describe BulkImports::Groups::Pipelines::LabelsPipeline do ...@@ -6,6 +6,7 @@ RSpec.describe BulkImports::Groups::Pipelines::LabelsPipeline do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:group) { create(:group) } let(:group) { create(:group) }
let(:cursor) { 'cursor' } let(:cursor) { 'cursor' }
let(:timestamp) { Time.new(2020, 01, 01).utc }
let(:entity) do let(:entity) do
create( create(
:bulk_import_entity, :bulk_import_entity,
...@@ -20,21 +21,23 @@ RSpec.describe BulkImports::Groups::Pipelines::LabelsPipeline do ...@@ -20,21 +21,23 @@ RSpec.describe BulkImports::Groups::Pipelines::LabelsPipeline do
subject { described_class.new(context) } subject { described_class.new(context) }
def extractor_data(title:, has_next_page:, cursor: nil) def label_data(title)
data = [
{ {
'title' => title, 'title' => title,
'description' => 'desc', 'description' => 'desc',
'color' => '#428BCA' 'color' => '#428BCA',
'created_at' => timestamp.to_s,
'updated_at' => timestamp.to_s
} }
] end
def extractor_data(title:, has_next_page:, cursor: nil)
page_info = { page_info = {
'end_cursor' => cursor, 'end_cursor' => cursor,
'has_next_page' => has_next_page 'has_next_page' => has_next_page
} }
BulkImports::Pipeline::ExtractedData.new(data: data, page_info: page_info) BulkImports::Pipeline::ExtractedData.new(data: [label_data(title)], page_info: page_info)
end end
describe '#run' do describe '#run' do
...@@ -55,6 +58,8 @@ RSpec.describe BulkImports::Groups::Pipelines::LabelsPipeline do ...@@ -55,6 +58,8 @@ RSpec.describe BulkImports::Groups::Pipelines::LabelsPipeline do
expect(label.title).to eq('label2') expect(label.title).to eq('label2')
expect(label.description).to eq('desc') expect(label.description).to eq('desc')
expect(label.color).to eq('#428BCA') expect(label.color).to eq('#428BCA')
expect(label.created_at).to eq(timestamp)
expect(label.updated_at).to eq(timestamp)
end end
end end
...@@ -92,19 +97,15 @@ RSpec.describe BulkImports::Groups::Pipelines::LabelsPipeline do ...@@ -92,19 +97,15 @@ RSpec.describe BulkImports::Groups::Pipelines::LabelsPipeline do
describe '#load' do describe '#load' do
it 'creates the label' do it 'creates the label' do
data = { data = label_data('label')
'title' => 'label',
'description' => 'description',
'color' => '#FFFFFF'
}
expect { subject.load(context, data) }.to change(Label, :count).by(1) expect { subject.load(context, data) }.to change(Label, :count).by(1)
label = group.labels.first label = group.labels.first
expect(label.title).to eq(data['title']) data.each do |key, value|
expect(label.description).to eq(data['description']) expect(label[key]).to eq(value)
expect(label.color).to eq(data['color']) end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment