Commit d00d952d authored by Nick Kipling's avatar Nick Kipling

Update package_presenter for NuGet metadata

Adds support for NuGet metadata
Adds support for dependency links
Tests updated for above
parent d067ae8b
......@@ -21,6 +21,8 @@ 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[:dependency_links] = @package.dependency_links.map { |dl| build_dependency_links(dl) } if @package.dependency_links
package_detail[:pipeline] = build_pipeline_info(@package.build_info.pipeline) if @package.build_info
package_detail
......@@ -58,6 +60,14 @@ module Packages
name: user.name
}
end
def build_dependency_links(link)
{
name: link.dependency.name,
version_pattern: link.dependency.version_pattern,
target_framework: link.nuget_metadatum.target_framework
}
end
end
end
end
......@@ -43,7 +43,8 @@ describe ::Packages::Detail::PackagePresenter do
project_id: package.project_id,
tags: package.tags.as_json,
updated_at: package.updated_at,
version: package.version
version: package.version,
dependency_links: []
}
end
......@@ -65,6 +66,17 @@ describe ::Packages::Detail::PackagePresenter 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) }
it 'returns nuget_metadatum' do
expected_package_details[:nuget_metadatum] = nuget_metadatum
expect(presenter.detail_view).to eq expected_package_details
end
end
end
it 'build_package_file_view returns correct file data' do
......@@ -88,4 +100,21 @@ describe ::Packages::Detail::PackagePresenter do
expect(presenter.build_user_info(nil)).to eq nil
end
end
context 'build_dependency_links' do
let_it_be(:package) { create(:nuget_package, project: project) }
let_it_be(:dependency_link) { create(:packages_dependency_link, package: package) }
let_it_be(:nuget_dependency) { create(:nuget_dependency_link_metadatum, dependency_link: dependency_link) }
let_it_be(:expected_link) do
{
name: dependency_link.dependency.name,
version_pattern: dependency_link.dependency.version_pattern,
target_framework: nuget_dependency.target_framework
}
end
it 'returns correct dependency data for nuget packages' do
expect(presenter.build_dependency_links(dependency_link)).to eq expected_link
end
end
end
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