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:
- description
- attributes
- 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))
Group members are associated with the imported group if:
- The user already exists in the target GitLab instance and
......
......@@ -19,6 +19,8 @@ module BulkImports
title
description
color
created_at: createdAt
updated_at: updatedAt
}
}
}
......
......@@ -6,6 +6,7 @@ RSpec.describe BulkImports::Groups::Pipelines::LabelsPipeline do
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:cursor) { 'cursor' }
let(:timestamp) { Time.new(2020, 01, 01).utc }
let(:entity) do
create(
:bulk_import_entity,
......@@ -20,21 +21,23 @@ RSpec.describe BulkImports::Groups::Pipelines::LabelsPipeline do
subject { described_class.new(context) }
def extractor_data(title:, has_next_page:, cursor: nil)
data = [
def label_data(title)
{
'title' => title,
'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 = {
'end_cursor' => cursor,
'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
describe '#run' do
......@@ -55,6 +58,8 @@ RSpec.describe BulkImports::Groups::Pipelines::LabelsPipeline do
expect(label.title).to eq('label2')
expect(label.description).to eq('desc')
expect(label.color).to eq('#428BCA')
expect(label.created_at).to eq(timestamp)
expect(label.updated_at).to eq(timestamp)
end
end
......@@ -92,19 +97,15 @@ RSpec.describe BulkImports::Groups::Pipelines::LabelsPipeline do
describe '#load' do
it 'creates the label' do
data = {
'title' => 'label',
'description' => 'description',
'color' => '#FFFFFF'
}
data = label_data('label')
expect { subject.load(context, data) }.to change(Label, :count).by(1)
label = group.labels.first
expect(label.title).to eq(data['title'])
expect(label.description).to eq(data['description'])
expect(label.color).to eq(data['color'])
data.each do |key, value|
expect(label[key]).to eq(value)
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