Commit 45d5c4d3 authored by Jarka Košanová's avatar Jarka Košanová

Merge branch '232828-return-pipeline-url-helpers' into 'master'

Adds urls to package presenter

See merge request gitlab-org/gitlab!38518
parents 4d6433ff 475dc256
...@@ -50,7 +50,9 @@ module Packages ...@@ -50,7 +50,9 @@ module Packages
user: build_user_info(pipeline_info.user), user: build_user_info(pipeline_info.user),
project: { project: {
name: pipeline_info.project.name, 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 end
......
...@@ -9,6 +9,7 @@ RSpec.describe ::Packages::Detail::PackagePresenter do ...@@ -9,6 +9,7 @@ RSpec.describe ::Packages::Detail::PackagePresenter do
let(:presenter) { described_class.new(package) } let(:presenter) { described_class.new(package) }
let_it_be(:user_info) { { name: user.name, avatar_url: user.avatar_url } } let_it_be(:user_info) { { name: user.name, avatar_url: user.avatar_url } }
let!(:expected_package_files) do let!(:expected_package_files) do
package.package_files.map do |file| package.package_files.map do |file|
{ {
...@@ -19,6 +20,7 @@ RSpec.describe ::Packages::Detail::PackagePresenter do ...@@ -19,6 +20,7 @@ RSpec.describe ::Packages::Detail::PackagePresenter do
} }
end end
end end
let(:pipeline_info) do let(:pipeline_info) do
pipeline = package.build_info.pipeline pipeline = package.build_info.pipeline
{ {
...@@ -30,11 +32,15 @@ RSpec.describe ::Packages::Detail::PackagePresenter do ...@@ -30,11 +32,15 @@ RSpec.describe ::Packages::Detail::PackagePresenter do
user: user_info, user: user_info,
project: { project: {
name: pipeline.project.name, 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 end
let!(:dependency_links) { [] } let!(:dependency_links) { [] }
let!(:expected_package_details) do let!(:expected_package_details) do
{ {
id: package.id, id: package.id,
...@@ -56,7 +62,7 @@ RSpec.describe ::Packages::Detail::PackagePresenter do ...@@ -56,7 +62,7 @@ RSpec.describe ::Packages::Detail::PackagePresenter do
let(:expected_package_details) { super().merge(pipeline: pipeline_info) } let(:expected_package_details) { super().merge(pipeline: pipeline_info) }
it 'returns details with pipeline' do 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
end end
...@@ -91,6 +97,7 @@ RSpec.describe ::Packages::Detail::PackagePresenter do ...@@ -91,6 +97,7 @@ RSpec.describe ::Packages::Detail::PackagePresenter do
let_it_be(:package) { create(:nuget_package, project: project) } let_it_be(:package) { create(:nuget_package, project: project) }
let_it_be(:dependency_link) { create(:packages_dependency_link, package: package) } 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(:nuget_dependency) { create(:nuget_dependency_link_metadatum, dependency_link: dependency_link) }
let_it_be(:expected_link) do let_it_be(:expected_link) do
{ {
name: dependency_link.dependency.name, name: dependency_link.dependency.name,
...@@ -98,6 +105,7 @@ RSpec.describe ::Packages::Detail::PackagePresenter do ...@@ -98,6 +105,7 @@ RSpec.describe ::Packages::Detail::PackagePresenter do
target_framework: nuget_dependency.target_framework target_framework: nuget_dependency.target_framework
} }
end end
let_it_be(:dependency_links) { [expected_link] } let_it_be(:dependency_links) { [expected_link] }
it 'returns the correct dependency link' do 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