Commit 475dc256 authored by Giorgenes Gelatti's avatar Giorgenes Gelatti

Adds urls to package presenter

Adds pipeline_url and commit_url
to package detail presenter
parent d9983961
......@@ -49,7 +49,9 @@ module Packages
user: build_user_info(pipeline_info.user),
project: {
name: pipeline_info.project.name,
web_url: pipeline_info.project.web_url
web_url: pipeline_info.project.web_url,
pipeline_url: Gitlab::Routing.url_helpers.project_pipeline_url(pipeline_info.project, pipeline_info),
commit_url: Gitlab::Routing.url_helpers.project_commit_url(pipeline_info.project, pipeline_info.sha)
}
}
end
......
......@@ -9,6 +9,7 @@ RSpec.describe ::Packages::Detail::PackagePresenter do
let(:presenter) { described_class.new(package) }
let_it_be(:user_info) { { name: user.name, avatar_url: user.avatar_url } }
let!(:expected_package_files) do
npm_file = package.package_files.first
[{
......@@ -18,6 +19,7 @@ RSpec.describe ::Packages::Detail::PackagePresenter do
size: npm_file.size
}]
end
let(:pipeline_info) do
pipeline = package.build_info.pipeline
{
......@@ -29,11 +31,15 @@ RSpec.describe ::Packages::Detail::PackagePresenter do
user: user_info,
project: {
name: pipeline.project.name,
web_url: pipeline.project.web_url
web_url: pipeline.project.web_url,
pipeline_url: include("pipelines/#{pipeline.id}"),
commit_url: include("commit/#{pipeline.sha}")
}
}
end
let!(:dependency_links) { [] }
let!(:expected_package_details) do
{
id: package.id,
......@@ -55,7 +61,7 @@ RSpec.describe ::Packages::Detail::PackagePresenter do
let(:expected_package_details) { super().merge(pipeline: pipeline_info) }
it 'returns details with pipeline' do
expect(presenter.detail_view).to eq expected_package_details
expect(presenter.detail_view).to match expected_package_details
end
end
......@@ -81,6 +87,7 @@ RSpec.describe ::Packages::Detail::PackagePresenter 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,
......@@ -88,6 +95,7 @@ RSpec.describe ::Packages::Detail::PackagePresenter do
target_framework: nuget_dependency.target_framework
}
end
let_it_be(:dependency_links) { [expected_link] }
it 'returns the correct dependency link' do
......
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