diff options
Diffstat (limited to 'spec/lib/bulk_imports/projects')
12 files changed, 70 insertions, 34 deletions
diff --git a/spec/lib/bulk_imports/projects/pipelines/auto_devops_pipeline_spec.rb b/spec/lib/bulk_imports/projects/pipelines/auto_devops_pipeline_spec.rb index e2744a6a457..b35ba612197 100644 --- a/spec/lib/bulk_imports/projects/pipelines/auto_devops_pipeline_spec.rb +++ b/spec/lib/bulk_imports/projects/pipelines/auto_devops_pipeline_spec.rb @@ -14,7 +14,7 @@ RSpec.describe BulkImports::Projects::Pipelines::AutoDevopsPipeline do project: project, bulk_import: bulk_import, source_full_path: 'source/full/path', - destination_name: 'My Destination Project', + destination_slug: 'My-Destination-Project', destination_namespace: group.full_path ) end diff --git a/spec/lib/bulk_imports/projects/pipelines/ci_pipelines_pipeline_spec.rb b/spec/lib/bulk_imports/projects/pipelines/ci_pipelines_pipeline_spec.rb index 98a2e8b6a57..a78f524b227 100644 --- a/spec/lib/bulk_imports/projects/pipelines/ci_pipelines_pipeline_spec.rb +++ b/spec/lib/bulk_imports/projects/pipelines/ci_pipelines_pipeline_spec.rb @@ -14,7 +14,7 @@ RSpec.describe BulkImports::Projects::Pipelines::CiPipelinesPipeline do project: project, bulk_import: bulk_import, source_full_path: 'source/full/path', - destination_name: 'My Destination Project', + destination_slug: 'My-Destination-Project', destination_namespace: group.full_path ) end diff --git a/spec/lib/bulk_imports/projects/pipelines/issues_pipeline_spec.rb b/spec/lib/bulk_imports/projects/pipelines/issues_pipeline_spec.rb index 19e3a1fecc3..a0789522ea8 100644 --- a/spec/lib/bulk_imports/projects/pipelines/issues_pipeline_spec.rb +++ b/spec/lib/bulk_imports/projects/pipelines/issues_pipeline_spec.rb @@ -14,7 +14,7 @@ RSpec.describe BulkImports::Projects::Pipelines::IssuesPipeline do project: project, bulk_import: bulk_import, source_full_path: 'source/full/path', - destination_name: 'My Destination Project', + destination_slug: 'My-Destination-Project', destination_namespace: group.full_path ) end diff --git a/spec/lib/bulk_imports/projects/pipelines/merge_requests_pipeline_spec.rb b/spec/lib/bulk_imports/projects/pipelines/merge_requests_pipeline_spec.rb index e780cde4ae2..5b85b3eee79 100644 --- a/spec/lib/bulk_imports/projects/pipelines/merge_requests_pipeline_spec.rb +++ b/spec/lib/bulk_imports/projects/pipelines/merge_requests_pipeline_spec.rb @@ -15,7 +15,7 @@ RSpec.describe BulkImports::Projects::Pipelines::MergeRequestsPipeline do project: project, bulk_import: bulk_import, source_full_path: 'source/full/path', - destination_name: 'My Destination Project', + destination_slug: 'My-Destination-Project', destination_namespace: group.full_path ) end diff --git a/spec/lib/bulk_imports/projects/pipelines/pipeline_schedules_pipeline_spec.rb b/spec/lib/bulk_imports/projects/pipelines/pipeline_schedules_pipeline_spec.rb index 12713f008bb..0bfd9410808 100644 --- a/spec/lib/bulk_imports/projects/pipelines/pipeline_schedules_pipeline_spec.rb +++ b/spec/lib/bulk_imports/projects/pipelines/pipeline_schedules_pipeline_spec.rb @@ -14,7 +14,7 @@ RSpec.describe BulkImports::Projects::Pipelines::PipelineSchedulesPipeline do project: project, bulk_import: bulk_import, source_full_path: 'source/full/path', - destination_name: 'My Destination Project', + destination_slug: 'My-Destination-Project', destination_namespace: group.full_path ) end diff --git a/spec/lib/bulk_imports/projects/pipelines/project_pipeline_spec.rb b/spec/lib/bulk_imports/projects/pipelines/project_pipeline_spec.rb index 567a0a4fcc3..09385a261b6 100644 --- a/spec/lib/bulk_imports/projects/pipelines/project_pipeline_spec.rb +++ b/spec/lib/bulk_imports/projects/pipelines/project_pipeline_spec.rb @@ -14,7 +14,7 @@ RSpec.describe BulkImports::Projects::Pipelines::ProjectPipeline do source_type: :project_entity, bulk_import: bulk_import, source_full_path: 'source/full/path', - destination_name: 'My Destination Project', + destination_slug: 'My-Destination-Project', destination_namespace: group.full_path ) end diff --git a/spec/lib/bulk_imports/projects/pipelines/references_pipeline_spec.rb b/spec/lib/bulk_imports/projects/pipelines/references_pipeline_spec.rb index 3c3d0a6d1c4..895d37ea385 100644 --- a/spec/lib/bulk_imports/projects/pipelines/references_pipeline_spec.rb +++ b/spec/lib/bulk_imports/projects/pipelines/references_pipeline_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe BulkImports::Projects::Pipelines::ReferencesPipeline do +RSpec.describe BulkImports::Projects::Pipelines::ReferencesPipeline, feature_category: :importers do let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project) } let_it_be(:bulk_import) { create(:bulk_import, user: user) } @@ -19,11 +19,44 @@ RSpec.describe BulkImports::Projects::Pipelines::ReferencesPipeline do let_it_be(:tracker) { create(:bulk_import_tracker, entity: entity) } let_it_be(:context) { BulkImports::Pipeline::Context.new(tracker) } - let(:issue) { create(:issue, project: project, description: 'https://my.gitlab.com/source/full/path/-/issues/1') } - let(:mr) { create(:merge_request, source_project: project, description: 'https://my.gitlab.com/source/full/path/-/merge_requests/1') } - let(:issue_note) { create(:note, project: project, noteable: issue, note: 'https://my.gitlab.com/source/full/path/-/issues/1') } - let(:mr_note) { create(:note, project: project, noteable: mr, note: 'https://my.gitlab.com/source/full/path/-/merge_requests/1') } + let(:mr) do + create( + :merge_request, + source_project: project, + description: 'https://my.gitlab.com/source/full/path/-/merge_requests/1' + ) + end + + let(:issue_note) do + create( + :note, + project: project, + noteable: issue, + note: 'https://my.gitlab.com/source/full/path/-/issues/1' + ) + end + + let(:mr_note) do + create( + :note, + project: project, + noteable: mr, + note: 'https://my.gitlab.com/source/full/path/-/merge_requests/1' + ) + end + + let(:old_note_html) { 'old note_html' } + let(:system_note) do + create( + :note, + project: project, + system: true, + noteable: issue, + note: "mentioned in merge request !#{mr.iid}", + note_html: old_note_html + ) + end subject(:pipeline) { described_class.new(context) } @@ -32,7 +65,7 @@ RSpec.describe BulkImports::Projects::Pipelines::ReferencesPipeline do end def create_project_data - [issue, mr, issue_note, mr_note] + [issue, mr, issue_note, mr_note, system_note] end describe '#extract' do @@ -43,6 +76,10 @@ RSpec.describe BulkImports::Projects::Pipelines::ReferencesPipeline do expect(extracted_data).to be_instance_of(BulkImports::Pipeline::ExtractedData) expect(extracted_data.data).to contain_exactly(issue_note, mr, issue, mr_note) + expect(system_note.note_html).not_to eq(old_note_html) + expect(system_note.note_html) + .to include("class=\"gfm gfm-merge_request\">!#{mr.iid}</a></p>") + .and include(project.full_path.to_s) end end @@ -122,9 +159,11 @@ RSpec.describe BulkImports::Projects::Pipelines::ReferencesPipeline do it 'does not save the object' do expect(mr).not_to receive(:save!) expect(mr_note).not_to receive(:save!) + expect(system_note).not_to receive(:save!) subject.load(context, mr) subject.load(context, mr_note) + subject.load(context, system_note) end end end diff --git a/spec/lib/bulk_imports/projects/pipelines/releases_pipeline_spec.rb b/spec/lib/bulk_imports/projects/pipelines/releases_pipeline_spec.rb index a376cdd712c..339ca727b57 100644 --- a/spec/lib/bulk_imports/projects/pipelines/releases_pipeline_spec.rb +++ b/spec/lib/bulk_imports/projects/pipelines/releases_pipeline_spec.rb @@ -14,7 +14,7 @@ RSpec.describe BulkImports::Projects::Pipelines::ReleasesPipeline do project: project, bulk_import: bulk_import, source_full_path: 'source/full/path', - destination_name: 'My Destination Project', + destination_slug: 'My-Destination-Project', destination_namespace: group.full_path ) end diff --git a/spec/lib/bulk_imports/projects/pipelines/repository_pipeline_spec.rb b/spec/lib/bulk_imports/projects/pipelines/repository_pipeline_spec.rb index a968104fc91..0cc8da80a61 100644 --- a/spec/lib/bulk_imports/projects/pipelines/repository_pipeline_spec.rb +++ b/spec/lib/bulk_imports/projects/pipelines/repository_pipeline_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe BulkImports::Projects::Pipelines::RepositoryPipeline do +RSpec.describe BulkImports::Projects::Pipelines::RepositoryPipeline, feature_category: :importers do let_it_be(:user) { create(:user) } let_it_be(:parent) { create(:project) } let_it_be(:bulk_import) { create(:bulk_import, user: user) } @@ -14,7 +14,7 @@ RSpec.describe BulkImports::Projects::Pipelines::RepositoryPipeline do :project_entity, bulk_import: bulk_import, source_full_path: 'source/full/path', - destination_name: 'My Destination Repository', + destination_slug: 'My-Destination-Repository', destination_namespace: parent.full_path, project: parent ) diff --git a/spec/lib/bulk_imports/projects/pipelines/snippets_pipeline_spec.rb b/spec/lib/bulk_imports/projects/pipelines/snippets_pipeline_spec.rb index dae879de998..41b3ea37804 100644 --- a/spec/lib/bulk_imports/projects/pipelines/snippets_pipeline_spec.rb +++ b/spec/lib/bulk_imports/projects/pipelines/snippets_pipeline_spec.rb @@ -14,7 +14,7 @@ RSpec.describe BulkImports::Projects::Pipelines::SnippetsPipeline do project: project, bulk_import: bulk_import, source_full_path: 'source/full/path', - destination_name: 'My Destination Project', + destination_slug: 'My-Destination-Project', destination_namespace: group.full_path ) end diff --git a/spec/lib/bulk_imports/projects/pipelines/snippets_repository_pipeline_spec.rb b/spec/lib/bulk_imports/projects/pipelines/snippets_repository_pipeline_spec.rb index dfd01cdf4bb..56c0f8c8807 100644 --- a/spec/lib/bulk_imports/projects/pipelines/snippets_repository_pipeline_spec.rb +++ b/spec/lib/bulk_imports/projects/pipelines/snippets_repository_pipeline_spec.rb @@ -15,7 +15,7 @@ RSpec.describe BulkImports::Projects::Pipelines::SnippetsRepositoryPipeline do project: project, bulk_import: bulk_import_configuration.bulk_import, source_full_path: 'source/full/path', - destination_name: 'My Destination Project', + destination_slug: 'My-Destination-Project', destination_namespace: project.full_path ) end diff --git a/spec/lib/bulk_imports/projects/transformers/project_attributes_transformer_spec.rb b/spec/lib/bulk_imports/projects/transformers/project_attributes_transformer_spec.rb index c1c4d0bf0db..36dc63a9331 100644 --- a/spec/lib/bulk_imports/projects/transformers/project_attributes_transformer_spec.rb +++ b/spec/lib/bulk_imports/projects/transformers/project_attributes_transformer_spec.rb @@ -2,27 +2,27 @@ require 'spec_helper' -RSpec.describe BulkImports::Projects::Transformers::ProjectAttributesTransformer do +RSpec.describe BulkImports::Projects::Transformers::ProjectAttributesTransformer, feature_category: :importers do describe '#transform' do let_it_be(:user) { create(:user) } - let_it_be(:destination_group) { create(:group) } let_it_be(:project) { create(:project, name: 'My Source Project') } let_it_be(:bulk_import) { create(:bulk_import, user: user) } - let_it_be(:entity) do + let(:entity) do create( :bulk_import_entity, source_type: :project_entity, bulk_import: bulk_import, source_full_path: 'source/full/path', - destination_slug: 'Destination Project Name', - destination_namespace: destination_group.full_path + destination_slug: 'Destination-Project-Name', + destination_namespace: destination_namespace ) end - let_it_be(:tracker) { create(:bulk_import_tracker, entity: entity) } - let_it_be(:context) { BulkImports::Pipeline::Context.new(tracker) } - + let(:destination_group) { create(:group) } + let(:destination_namespace) { destination_group.full_path } + let(:tracker) { create(:bulk_import_tracker, entity: entity) } + let(:context) { BulkImports::Pipeline::Context.new(tracker) } let(:data) do { 'visibility' => 'private', @@ -40,13 +40,6 @@ RSpec.describe BulkImports::Projects::Transformers::ProjectAttributesTransformer expect(transformed_data[:path]).to eq(entity.destination_slug.parameterize) end - it 'transforms visibility level' do - visibility = data['visibility'] - - expect(transformed_data).not_to have_key(:visibility) - expect(transformed_data[:visibility_level]).to eq(Gitlab::VisibilityLevel.string_options[visibility]) - end - it 'adds import type' do expect(transformed_data[:import_type]).to eq(described_class::PROJECT_IMPORT_TYPE) end @@ -65,7 +58,7 @@ RSpec.describe BulkImports::Projects::Transformers::ProjectAttributesTransformer source_type: :project_entity, bulk_import: bulk_import, source_full_path: 'source/full/path', - destination_slug: 'Destination Project Name', + destination_slug: 'Destination-Project-Name', destination_namespace: '' ) @@ -89,8 +82,12 @@ RSpec.describe BulkImports::Projects::Transformers::ProjectAttributesTransformer transformed_data = described_class.new.transform(context, data) expect(transformed_data.keys) - .to contain_exactly(:created_at, :import_type, :name, :namespace_id, :path, :visibility_level) + .to contain_exactly('created_at', 'import_type', 'name', 'namespace_id', 'path', 'visibility_level') end end + + describe 'visibility level' do + include_examples 'visibility level settings' + end end end |