Commit f40e636d authored by George Koltsov's avatar George Koltsov

Add Project Feature to Project Migration

 - Add project feature information to the project
   migration in order to migrate project access level
   settings
parent cc2f3a8c
...@@ -83,16 +83,6 @@ RSpec.describe BulkImports::Groups::Pipelines::EpicsPipeline do ...@@ -83,16 +83,6 @@ RSpec.describe BulkImports::Groups::Pipelines::EpicsPipeline do
end end
end end
context 'when epic is persisted' do
it 'does not save epic' do
epic = create(:epic, group: group)
expect(epic).not_to receive(:save!)
subject.load(context, epic)
end
end
context 'when epic is missing' do context 'when epic is missing' do
it 'returns' do it 'returns' do
expect(subject.load(context, nil)).to be_nil expect(subject.load(context, nil)).to be_nil
......
...@@ -16,6 +16,7 @@ RSpec.describe BulkImports::Projects::Stage do ...@@ -16,6 +16,7 @@ RSpec.describe BulkImports::Projects::Stage do
[4, BulkImports::Projects::Pipelines::PushRulePipeline], [4, BulkImports::Projects::Pipelines::PushRulePipeline],
[4, BulkImports::Projects::Pipelines::ProtectedBranchesPipeline], [4, BulkImports::Projects::Pipelines::ProtectedBranchesPipeline],
[4, BulkImports::Projects::Pipelines::CiPipelinesPipeline], [4, BulkImports::Projects::Pipelines::CiPipelinesPipeline],
[4, BulkImports::Projects::Pipelines::ProjectFeaturePipeline],
[5, BulkImports::Common::Pipelines::WikiPipeline], [5, BulkImports::Common::Pipelines::WikiPipeline],
[5, BulkImports::Common::Pipelines::UploadsPipeline], [5, BulkImports::Common::Pipelines::UploadsPipeline],
[6, BulkImports::Common::Pipelines::EntityFinisher] [6, BulkImports::Common::Pipelines::EntityFinisher]
......
...@@ -31,9 +31,7 @@ module BulkImports ...@@ -31,9 +31,7 @@ module BulkImports
end end
def load(_, object) def load(_, object)
return unless object object&.save!
object.save! unless object.persisted?
end end
def deep_transform_relation!(relation_hash, relation_key, relation_definition, &block) def deep_transform_relation!(relation_hash, relation_key, relation_definition, &block)
......
# frozen_string_literal: true
module BulkImports
module Projects
module Pipelines
class ProjectFeaturePipeline
include NdjsonPipeline
relation_name 'project_feature'
extractor ::BulkImports::Common::Extractors::NdjsonExtractor, relation: relation
end
end
end
end
...@@ -47,6 +47,10 @@ module BulkImports ...@@ -47,6 +47,10 @@ module BulkImports
pipeline: BulkImports::Projects::Pipelines::CiPipelinesPipeline, pipeline: BulkImports::Projects::Pipelines::CiPipelinesPipeline,
stage: 4 stage: 4
}, },
project_feature: {
pipeline: BulkImports::Projects::Pipelines::ProjectFeaturePipeline,
stage: 4
},
wiki: { wiki: {
pipeline: BulkImports::Common::Pipelines::WikiPipeline, pipeline: BulkImports::Common::Pipelines::WikiPipeline,
stage: 5 stage: 5
......
...@@ -59,16 +59,6 @@ RSpec.describe BulkImports::Common::Pipelines::LabelsPipeline do ...@@ -59,16 +59,6 @@ RSpec.describe BulkImports::Common::Pipelines::LabelsPipeline do
end end
end end
context 'when label is persisted' do
it 'does not save label' do
label = create(:group_label, group: group)
expect(label).not_to receive(:save!)
subject.load(context, label)
end
end
context 'when label is missing' do context 'when label is missing' do
it 'returns' do it 'returns' do
expect(subject.load(context, nil)).to be_nil expect(subject.load(context, nil)).to be_nil
......
...@@ -81,16 +81,6 @@ RSpec.describe BulkImports::Common::Pipelines::MilestonesPipeline do ...@@ -81,16 +81,6 @@ RSpec.describe BulkImports::Common::Pipelines::MilestonesPipeline do
end end
end end
context 'when milestone is persisted' do
it 'does not save milestone' do
milestone = create(:milestone, group: group)
expect(milestone).not_to receive(:save!)
subject.load(context, milestone)
end
end
context 'when milestone is missing' do context 'when milestone is missing' do
it 'returns' do it 'returns' do
expect(subject.load(context, nil)).to be_nil expect(subject.load(context, nil)).to be_nil
......
...@@ -143,16 +143,6 @@ RSpec.describe BulkImports::NdjsonPipeline do ...@@ -143,16 +143,6 @@ RSpec.describe BulkImports::NdjsonPipeline do
end end
end end
context 'when object is persisted' do
it 'does not save the object' do
object = double(persisted?: true)
expect(object).not_to receive(:save!)
subject.load(nil, object)
end
end
context 'when object is missing' do context 'when object is missing' do
it 'returns' do it 'returns' do
expect(subject.load(nil, nil)).to be_nil expect(subject.load(nil, nil)).to be_nil
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe BulkImports::Projects::Pipelines::ProjectFeaturePipeline do
let_it_be(:project) { create(:project) }
let_it_be(:entity) { create(:bulk_import_entity, :project_entity, project: project) }
let_it_be(:tracker) { create(:bulk_import_tracker, entity: entity) }
let_it_be(:context) { BulkImports::Pipeline::Context.new(tracker) }
let_it_be(:project_feature) do
{
"builds_access_level": 10,
"wiki_access_level": 10,
"issues_access_level": 10,
"merge_requests_access_level": 10,
"snippets_access_level": 10,
"repository_access_level": 10,
"pages_access_level": 10,
"forking_access_level": 10,
"metrics_dashboard_access_level": 10,
"operations_access_level": 10,
"analytics_access_level": 10,
"security_and_compliance_access_level": 10,
"container_registry_access_level": 10,
"updated_at": "2016-09-23T11:58:28.000Z",
"created_at": "2014-12-26T09:26:45.000Z"
}
end
subject(:pipeline) { described_class.new(context) }
describe '#run' do
it 'imports project feature', :aggregate_failures do
allow_next_instance_of(BulkImports::Common::Extractors::NdjsonExtractor) do |extractor|
allow(extractor).to receive(:extract).and_return(BulkImports::Pipeline::ExtractedData.new(data: [[project_feature, 0]]))
end
pipeline.run
project_feature.each_pair do |key, value|
expect(entity.project.project_feature.public_send(key)).to eq(value)
end
end
end
end
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
require 'spec_helper' require 'spec_helper'
# Any new stages must be added to
# `ee/spec/lib/ee/bulk_imports/projects/stage_spec.rb` as well.
RSpec.describe BulkImports::Projects::Stage do RSpec.describe BulkImports::Projects::Stage do
let(:pipelines) do let(:pipelines) do
[ [
...@@ -15,6 +17,7 @@ RSpec.describe BulkImports::Projects::Stage do ...@@ -15,6 +17,7 @@ RSpec.describe BulkImports::Projects::Stage do
[4, BulkImports::Projects::Pipelines::ExternalPullRequestsPipeline], [4, BulkImports::Projects::Pipelines::ExternalPullRequestsPipeline],
[4, BulkImports::Projects::Pipelines::ProtectedBranchesPipeline], [4, BulkImports::Projects::Pipelines::ProtectedBranchesPipeline],
[4, BulkImports::Projects::Pipelines::CiPipelinesPipeline], [4, BulkImports::Projects::Pipelines::CiPipelinesPipeline],
[4, BulkImports::Projects::Pipelines::ProjectFeaturePipeline],
[5, BulkImports::Common::Pipelines::WikiPipeline], [5, BulkImports::Common::Pipelines::WikiPipeline],
[5, BulkImports::Common::Pipelines::UploadsPipeline], [5, BulkImports::Common::Pipelines::UploadsPipeline],
[6, BulkImports::Common::Pipelines::EntityFinisher] [6, BulkImports::Common::Pipelines::EntityFinisher]
......
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