Commit ac6d25e8 authored by Doug Stull's avatar Doug Stull

Merge branch '339418-gitlab-migration-migrate-issue-boards' into 'master'

Resolve "GitLab Migration - Migrate Issue Boards"

See merge request gitlab-org/gitlab!71661
parents 7e5d423c f09c27dd
...@@ -2,11 +2,12 @@ ...@@ -2,11 +2,12 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe BulkImports::Groups::Pipelines::BoardsPipeline do RSpec.describe BulkImports::Common::Pipelines::BoardsPipeline do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group) } let_it_be(:group) { create(:group) }
let_it_be(:bulk_import) { create(:bulk_import, user: user) } let_it_be(:bulk_import) { create(:bulk_import, user: user) }
let_it_be(:filepath) { 'ee/spec/fixtures/bulk_imports/gz/boards.ndjson.gz' } let_it_be(:filepath) { 'ee/spec/fixtures/bulk_imports/gz/boards.ndjson.gz' }
let_it_be(:entity) do let_it_be(:entity) do
create( create(
:bulk_import_entity, :bulk_import_entity,
......
...@@ -14,7 +14,7 @@ RSpec.describe BulkImports::Groups::Stage do ...@@ -14,7 +14,7 @@ RSpec.describe BulkImports::Groups::Stage do
[1, BulkImports::Groups::Pipelines::BadgesPipeline], [1, BulkImports::Groups::Pipelines::BadgesPipeline],
[1, BulkImports::Groups::Pipelines::IterationsPipeline], [1, BulkImports::Groups::Pipelines::IterationsPipeline],
[1, BulkImports::Groups::Pipelines::ProjectEntitiesPipeline], [1, BulkImports::Groups::Pipelines::ProjectEntitiesPipeline],
[2, BulkImports::Groups::Pipelines::BoardsPipeline], [2, BulkImports::Common::Pipelines::BoardsPipeline],
[2, BulkImports::Groups::Pipelines::EpicsPipeline], [2, BulkImports::Groups::Pipelines::EpicsPipeline],
[4, BulkImports::Common::Pipelines::EntityFinisher] [4, BulkImports::Common::Pipelines::EntityFinisher]
] ]
......
# frozen_string_literal: true # frozen_string_literal: true
module BulkImports module BulkImports
module Groups module Common
module Pipelines module Pipelines
class BoardsPipeline class BoardsPipeline
include NdjsonPipeline include NdjsonPipeline
......
...@@ -36,7 +36,7 @@ module BulkImports ...@@ -36,7 +36,7 @@ module BulkImports
stage: 1 stage: 1
}, },
boards: { boards: {
pipeline: BulkImports::Groups::Pipelines::BoardsPipeline, pipeline: BulkImports::Common::Pipelines::BoardsPipeline,
stage: 2 stage: 2
}, },
finisher: { finisher: {
......
...@@ -23,9 +23,13 @@ module BulkImports ...@@ -23,9 +23,13 @@ module BulkImports
pipeline: BulkImports::Projects::Pipelines::IssuesPipeline, pipeline: BulkImports::Projects::Pipelines::IssuesPipeline,
stage: 3 stage: 3
}, },
boards: {
pipeline: BulkImports::Common::Pipelines::BoardsPipeline,
stage: 4
},
finisher: { finisher: {
pipeline: BulkImports::Common::Pipelines::EntityFinisher, pipeline: BulkImports::Common::Pipelines::EntityFinisher,
stage: 4 stage: 5
} }
} }
end end
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe BulkImports::Common::Pipelines::BoardsPipeline do
let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, group: group) }
let_it_be(:bulk_import) { create(:bulk_import, user: user) }
let(:board_data) do
{
"name" => "Test Board",
"lists" => [
{
"list_type" => "backlog",
"position" => 0
},
{
"list_type" => "closed",
"position" => 1
},
{
"list_type" => "label",
"position" => 2,
"label" => {
"title" => "test",
"type" => "GroupLabel",
"group_id" => group.id
}
}
]
}
end
let(:tracker) { create(:bulk_import_tracker, entity: entity) }
let(:context) { BulkImports::Pipeline::Context.new(tracker) }
subject { described_class.new(context) }
before do
allow_next_instance_of(BulkImports::Common::Extractors::NdjsonExtractor) do |extractor|
allow(extractor).to receive(:extract).and_return(BulkImports::Pipeline::ExtractedData.new(data: board_data))
end
group.add_owner(user)
end
context 'when issue board belongs to a project' do
let_it_be(:entity) do
create(
:bulk_import_entity,
source_type: :project_entity,
project: project,
bulk_import: bulk_import,
source_full_path: 'source/full/path',
destination_name: 'My Destination Group',
destination_namespace: group.full_path
)
end
describe '#run' do
it 'imports issue boards into destination project' do
expect { subject.run }.to change(::Board, :count).by(1)
board = project.boards.find_by(name: board_data["name"])
expect(board).to be
expect(board.project.id).to eq(project.id)
expect(board.lists.count).to eq(3)
expect(board.lists.map(&:list_type).sort).to match_array(%w(backlog closed label))
expect(board.lists.find_by(list_type: "label").label.title).to eq("test")
end
end
end
context 'when issue board belongs to a group' do
let_it_be(:entity) do
create(
:bulk_import_entity,
group: group,
bulk_import: bulk_import,
source_full_path: 'source/full/path',
destination_name: 'My Destination Group',
destination_namespace: group.full_path
)
end
describe '#run' do
it 'imports issue boards into destination group' do
expect { subject.run }.to change(::Board, :count).by(1)
board = group.boards.find_by(name: board_data["name"])
expect(board).to be
expect(board.group.id).to eq(group.id)
expect(board.lists.count).to eq(3)
expect(board.lists.map(&:list_type).sort).to match_array(%w(backlog closed label))
expect(board.lists.find_by(list_type: "label").label.title).to eq("test")
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe BulkImports::Groups::Pipelines::BoardsPipeline do
let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group) }
let_it_be(:bulk_import) { create(:bulk_import, user: user) }
let_it_be(:filepath) { 'spec/fixtures/bulk_imports/gz/boards.ndjson.gz' }
let_it_be(:entity) do
create(
:bulk_import_entity,
group: group,
bulk_import: bulk_import,
source_full_path: 'source/full/path',
destination_name: 'My Destination Group',
destination_namespace: group.full_path
)
end
let_it_be(:tracker) { create(:bulk_import_tracker, entity: entity) }
let_it_be(:context) { BulkImports::Pipeline::Context.new(tracker) }
let(:tmpdir) { Dir.mktmpdir }
before do
FileUtils.copy_file(filepath, File.join(tmpdir, 'boards.ndjson.gz'))
group.add_owner(user)
end
subject { described_class.new(context) }
describe '#run' do
it 'imports group boards into destination group and removes tmpdir' do
allow(Dir).to receive(:mktmpdir).and_return(tmpdir)
allow_next_instance_of(BulkImports::FileDownloadService) do |service|
allow(service).to receive(:execute)
end
expect { subject.run }.to change(Board, :count).by(1)
lists = group.boards.find_by(name: 'first board').lists
expect(lists.count).to eq(3)
expect(lists.first.label.title).to eq('TSL')
expect(lists.second.label.title).to eq('Sosync')
end
end
end
...@@ -14,7 +14,7 @@ RSpec.describe BulkImports::Groups::Stage do ...@@ -14,7 +14,7 @@ RSpec.describe BulkImports::Groups::Stage do
[1, BulkImports::Common::Pipelines::LabelsPipeline], [1, BulkImports::Common::Pipelines::LabelsPipeline],
[1, BulkImports::Groups::Pipelines::MilestonesPipeline], [1, BulkImports::Groups::Pipelines::MilestonesPipeline],
[1, BulkImports::Groups::Pipelines::BadgesPipeline], [1, BulkImports::Groups::Pipelines::BadgesPipeline],
[2, BulkImports::Groups::Pipelines::BoardsPipeline] [2, BulkImports::Common::Pipelines::BoardsPipeline]
] ]
end end
......
...@@ -9,7 +9,8 @@ RSpec.describe BulkImports::Projects::Stage do ...@@ -9,7 +9,8 @@ RSpec.describe BulkImports::Projects::Stage do
[1, BulkImports::Projects::Pipelines::RepositoryPipeline], [1, BulkImports::Projects::Pipelines::RepositoryPipeline],
[2, BulkImports::Common::Pipelines::LabelsPipeline], [2, BulkImports::Common::Pipelines::LabelsPipeline],
[3, BulkImports::Projects::Pipelines::IssuesPipeline], [3, BulkImports::Projects::Pipelines::IssuesPipeline],
[4, BulkImports::Common::Pipelines::EntityFinisher] [4, BulkImports::Common::Pipelines::BoardsPipeline],
[5, BulkImports::Common::Pipelines::EntityFinisher]
] ]
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