diff options
Diffstat (limited to 'spec/lib/bulk_imports/projects/pipelines')
-rw-r--r-- | spec/lib/bulk_imports/projects/pipelines/design_bundle_pipeline_spec.rb | 19 | ||||
-rw-r--r-- | spec/lib/bulk_imports/projects/pipelines/repository_bundle_pipeline_spec.rb | 19 |
2 files changed, 32 insertions, 6 deletions
diff --git a/spec/lib/bulk_imports/projects/pipelines/design_bundle_pipeline_spec.rb b/spec/lib/bulk_imports/projects/pipelines/design_bundle_pipeline_spec.rb index 5b7309b09f5..87efad92131 100644 --- a/spec/lib/bulk_imports/projects/pipelines/design_bundle_pipeline_spec.rb +++ b/spec/lib/bulk_imports/projects/pipelines/design_bundle_pipeline_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe BulkImports::Projects::Pipelines::DesignBundlePipeline do +RSpec.describe BulkImports::Projects::Pipelines::DesignBundlePipeline, feature_category: :importers do let_it_be(:design) { create(:design, :with_file) } let(:portable) { create(:project) } @@ -125,9 +125,9 @@ RSpec.describe BulkImports::Projects::Pipelines::DesignBundlePipeline do context 'when path is symlink' do it 'returns' do symlink = File.join(tmpdir, 'symlink') + FileUtils.ln_s(design_bundle_path, symlink) - FileUtils.ln_s(File.join(tmpdir, design_bundle_path), symlink) - + expect(Gitlab::Utils::FileInfo).to receive(:linked?).with(symlink).and_call_original expect(portable.design_repository).not_to receive(:create_from_bundle) pipeline.load(context, symlink) @@ -136,6 +136,19 @@ RSpec.describe BulkImports::Projects::Pipelines::DesignBundlePipeline do end end + context 'when path has multiple hard links' do + it 'returns' do + FileUtils.link(design_bundle_path, File.join(tmpdir, 'hard_link')) + + expect(Gitlab::Utils::FileInfo).to receive(:linked?).with(design_bundle_path).and_call_original + expect(portable.design_repository).not_to receive(:create_from_bundle) + + pipeline.load(context, design_bundle_path) + + expect(portable.design_repository.exists?).to eq(false) + end + end + context 'when path is not under tmpdir' do it 'returns' do expect { pipeline.load(context, '/home/test.txt') } diff --git a/spec/lib/bulk_imports/projects/pipelines/repository_bundle_pipeline_spec.rb b/spec/lib/bulk_imports/projects/pipelines/repository_bundle_pipeline_spec.rb index 07fafc19026..5aae8c959fa 100644 --- a/spec/lib/bulk_imports/projects/pipelines/repository_bundle_pipeline_spec.rb +++ b/spec/lib/bulk_imports/projects/pipelines/repository_bundle_pipeline_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe BulkImports::Projects::Pipelines::RepositoryBundlePipeline do +RSpec.describe BulkImports::Projects::Pipelines::RepositoryBundlePipeline, feature_category: :importers do let_it_be(:source) { create(:project, :repository) } let(:portable) { create(:project) } @@ -123,9 +123,9 @@ RSpec.describe BulkImports::Projects::Pipelines::RepositoryBundlePipeline do context 'when path is symlink' do it 'returns' do symlink = File.join(tmpdir, 'symlink') + FileUtils.ln_s(bundle_path, symlink) - FileUtils.ln_s(File.join(tmpdir, bundle_path), symlink) - + expect(Gitlab::Utils::FileInfo).to receive(:linked?).with(symlink).and_call_original expect(portable.repository).not_to receive(:create_from_bundle) pipeline.load(context, symlink) @@ -134,6 +134,19 @@ RSpec.describe BulkImports::Projects::Pipelines::RepositoryBundlePipeline do end end + context 'when path has mutiple hard links' do + it 'returns' do + FileUtils.link(bundle_path, File.join(tmpdir, 'hard_link')) + + expect(Gitlab::Utils::FileInfo).to receive(:linked?).with(bundle_path).and_call_original + expect(portable.repository).not_to receive(:create_from_bundle) + + pipeline.load(context, bundle_path) + + expect(portable.repository.exists?).to eq(false) + end + end + context 'when path is not under tmpdir' do it 'returns' do expect { pipeline.load(context, '/home/test.txt') } |