diff options
Diffstat (limited to 'spec/services/packages/nuget/update_package_from_metadata_service_spec.rb')
-rw-r--r-- | spec/services/packages/nuget/update_package_from_metadata_service_spec.rb | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/spec/services/packages/nuget/update_package_from_metadata_service_spec.rb b/spec/services/packages/nuget/update_package_from_metadata_service_spec.rb index b7c780c1ee2..92b493ed376 100644 --- a/spec/services/packages/nuget/update_package_from_metadata_service_spec.rb +++ b/spec/services/packages/nuget/update_package_from_metadata_service_spec.rb @@ -198,24 +198,26 @@ RSpec.describe Packages::Nuget::UpdatePackageFromMetadataService, :clean_gitlab_ it_behaves_like 'raising an', ::Packages::Nuget::MetadataExtractionService::ExtractionError end - context 'with package file with a blank package name' do - before do - allow(service).to receive(:package_name).and_return('') - end + context 'with an invalid package name' do + invalid_names = [ + '', + 'My/package', + '../../../my_package', + '%2e%2e%2fmy_package' + ] - it_behaves_like 'raising an', ::Packages::Nuget::UpdatePackageFromMetadataService::InvalidMetadataError - end + invalid_names.each do |invalid_name| + before do + allow(service).to receive(:package_name).and_return(invalid_name) + end - context 'with package file with a blank package version' do - before do - allow(service).to receive(:package_version).and_return('') + it_behaves_like 'raising an', ::Packages::Nuget::UpdatePackageFromMetadataService::InvalidMetadataError end - - it_behaves_like 'raising an', ::Packages::Nuget::UpdatePackageFromMetadataService::InvalidMetadataError end context 'with an invalid package version' do invalid_versions = [ + '', '555', '1.2', '1./2.3', @@ -224,13 +226,11 @@ RSpec.describe Packages::Nuget::UpdatePackageFromMetadataService, :clean_gitlab_ ] invalid_versions.each do |invalid_version| - it "raises an error for version #{invalid_version}" do + before do allow(service).to receive(:package_version).and_return(invalid_version) - - expect { subject }.to raise_error(ActiveRecord::RecordInvalid, 'Validation failed: Version is invalid') - expect(package_file.file_name).not_to include(invalid_version) - expect(package_file.file.file.path).not_to include(invalid_version) end + + it_behaves_like 'raising an', ::Packages::Nuget::UpdatePackageFromMetadataService::InvalidMetadataError end end end |