diff options
Diffstat (limited to 'spec/services/packages/nuget/odata_package_entry_service_spec.rb')
-rw-r--r-- | spec/services/packages/nuget/odata_package_entry_service_spec.rb | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/spec/services/packages/nuget/odata_package_entry_service_spec.rb b/spec/services/packages/nuget/odata_package_entry_service_spec.rb index d4c47538ce2..b4a22fef32b 100644 --- a/spec/services/packages/nuget/odata_package_entry_service_spec.rb +++ b/spec/services/packages/nuget/odata_package_entry_service_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' RSpec.describe Packages::Nuget::OdataPackageEntryService, feature_category: :package_registry do + include GrapePathHelpers::NamedRouteMatcher + let_it_be(:project) { build_stubbed(:project) } let_it_be(:params) { { package_name: 'dummy', package_version: '1.0.0' } } let(:doc) { Nokogiri::XML(subject.payload) } @@ -10,7 +12,7 @@ RSpec.describe Packages::Nuget::OdataPackageEntryService, feature_category: :pac subject { described_class.new(project, params).execute } describe '#execute' do - shared_examples 'returning a package entry with the correct attributes' do |pkg_version, content_url_pkg_version| + shared_examples 'returning a package entry with the correct attributes' do |pkg_version = ''| it 'returns a package entry with the correct attributes' do expect(doc.root.name).to eq('entry') expect(doc_node('id').text).to include( @@ -18,7 +20,7 @@ RSpec.describe Packages::Nuget::OdataPackageEntryService, feature_category: :pac ) expect(doc_node('title').text).to eq(params[:package_name]) expect(doc_node('content').attr('src')).to include( - content_url(project.id, params[:package_name], content_url_pkg_version) + content_url(project.id, params[:package_name], pkg_version) ) expect(doc_node('Version').text).to eq(pkg_version) end @@ -29,29 +31,17 @@ RSpec.describe Packages::Nuget::OdataPackageEntryService, feature_category: :pac expect(subject).to be_success end - it_behaves_like 'returning a package entry with the correct attributes', '1.0.0', '1.0.0' + it_behaves_like 'returning a package entry with the correct attributes', '1.0.0' end - context 'when package_version is nil' do + context 'when package_version is not present' do let(:params) { { package_name: 'dummy', package_version: nil } } it 'returns a success ServiceResponse' do expect(subject).to be_success end - it_behaves_like 'returning a package entry with the correct attributes', - described_class::SEMVER_LATEST_VERSION_PLACEHOLDER, described_class::LATEST_VERSION_FOR_V2_DOWNLOAD_ENDPOINT - end - - context 'when package_version is 0.0.0-latest-version' do - let(:params) { { package_name: 'dummy', package_version: described_class::SEMVER_LATEST_VERSION_PLACEHOLDER } } - - it 'returns a success ServiceResponse' do - expect(subject).to be_success - end - - it_behaves_like 'returning a package entry with the correct attributes', - described_class::SEMVER_LATEST_VERSION_PLACEHOLDER, described_class::LATEST_VERSION_FOR_V2_DOWNLOAD_ENDPOINT + it_behaves_like 'returning a package entry with the correct attributes' end end @@ -64,6 +54,13 @@ RSpec.describe Packages::Nuget::OdataPackageEntryService, feature_category: :pac end def content_url(id, package_name, package_version) - "api/v4/projects/#{id}/packages/nuget/v2/download/#{package_name}/#{package_version}" + if package_version.present? + filename = "#{package_name}.#{package_version}.nupkg" + api_v4_projects_packages_nuget_download_package_name_package_version_package_filename_path( + { id: id, package_name: package_name, package_version: package_version, package_filename: filename }, true + ) + else + api_v4_projects_packages_nuget_v2_path(id: id) + end end end |