Commit 6e6ab6e9 authored by James Lopez's avatar James Lopez

Merge branch '222469-add-composer-metadata-to-presenter' into 'master'

Adds composer metadata to package presenter

Closes #222469

See merge request gitlab-org/gitlab!38559
parents 939b05db 90de54ec
......@@ -22,6 +22,7 @@ module Packages
package_detail[:maven_metadatum] = @package.maven_metadatum if @package.maven_metadatum
package_detail[:nuget_metadatum] = @package.nuget_metadatum if @package.nuget_metadatum
package_detail[:composer_metadatum] = @package.composer_metadatum if @package.composer_metadatum
package_detail[:dependency_links] = @package.dependency_links.map(&method(:build_dependency_links))
package_detail[:pipeline] = build_pipeline_info(@package.build_info.pipeline) if @package.build_info
......
......@@ -10,13 +10,14 @@ RSpec.describe ::Packages::Detail::PackagePresenter do
let_it_be(:user_info) { { name: user.name, avatar_url: user.avatar_url } }
let!(:expected_package_files) do
npm_file = package.package_files.first
[{
created_at: npm_file.created_at,
download_path: npm_file.download_path,
file_name: npm_file.file_name,
size: npm_file.size
}]
package.package_files.map do |file|
{
created_at: file.created_at,
download_path: file.download_path,
file_name: file.file_name,
size: file.size
}
end
end
let(:pipeline_info) do
pipeline = package.build_info.pipeline
......@@ -67,6 +68,15 @@ RSpec.describe ::Packages::Detail::PackagePresenter do
end
end
context 'with composer metadata' do
let(:package) { create(:composer_package, :with_metadatum, sha: '123', project: project) }
let(:expected_package_details) { super().merge(composer_metadatum: package.composer_metadatum) }
it 'returns composer_metadatum' do
expect(presenter.detail_view).to eq expected_package_details
end
end
context 'with nuget_metadatum' do
let_it_be(:package) { create(:nuget_package, project: project) }
let_it_be(:nuget_metadatum) { create(:nuget_metadatum, package: package) }
......
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