Commit ee43db9b authored by Steve Abrams's avatar Steve Abrams Committed by Imre Farkas

Use Conan recipe as package name in API response

Use the conan recipe as the name value and add
conan_package_name as an additional attribute
when returning a conan package.
parent a24659e6
...@@ -42,7 +42,7 @@ export default { ...@@ -42,7 +42,7 @@ export default {
</script> </script>
<template> <template>
<div class="gl-display-flex gl-align-items-center"> <div data-qa-selector="package-path" class="gl-display-flex gl-align-items-center">
<gl-icon data-testid="base-icon" name="project" class="gl-mx-3 gl-min-w-0" /> <gl-icon data-testid="base-icon" name="project" class="gl-mx-3 gl-min-w-0" />
<gl-link data-testid="root-link" class="gl-text-gray-500 gl-min-w-0" :href="`/${rootLink}`"> <gl-link data-testid="root-link" class="gl-text-gray-500 gl-min-w-0" :href="`/${rootLink}`">
......
---
title: Use Conan recipe as package name in package API
merge_request: 42860
author:
type: changed
...@@ -50,6 +50,19 @@ Example response: ...@@ -50,6 +50,19 @@ Example response:
"version": "1.0.3", "version": "1.0.3",
"package_type": "npm", "package_type": "npm",
"created_at": "2019-11-27T03:37:38.711Z" "created_at": "2019-11-27T03:37:38.711Z"
},
{
"id": 3,
"name": "Hello/0.1@mycompany/stable",
"conan_package_name": "Hello",
"version": "0.1",
"package_type": "conan",
"_links": {
"web_path": "/foo/bar/-/packages/3",
"delete_api_path": "https://gitlab.example.com/api/v4/projects/1/packages/3"
},
"created_at": "2029-12-16T20:33:34.316Z",
"tags": []
} }
] ]
``` ```
......
...@@ -7,7 +7,19 @@ module API ...@@ -7,7 +7,19 @@ module API
extend ::API::Entities::EntityHelpers extend ::API::Entities::EntityHelpers
expose :id expose :id
expose :name
expose :name do |package|
if package.conan?
package.conan_recipe
else
package.name
end
end
expose :conan_package_name, if: ->(package) { package.conan? } do |package|
package.name
end
expose :version expose :version
expose :package_type expose :package_type
......
...@@ -48,7 +48,7 @@ RSpec.describe 'Group Packages' do ...@@ -48,7 +48,7 @@ RSpec.describe 'Group Packages' do
it 'allows you to navigate to the project page' do it 'allows you to navigate to the project page' do
page.within('[data-qa-selector="packages-table"]') do page.within('[data-qa-selector="packages-table"]') do
click_link project.name find('[data-qa-selector="package-path"]', text: project.name).click
end end
expect(page).to have_current_path(project_path(project)) expect(page).to have_current_path(project_path(project))
......
...@@ -11,6 +11,9 @@ ...@@ -11,6 +11,9 @@
"name": { "name": {
"type": "string" "type": "string"
}, },
"conan_package_name": {
"type": "string"
},
"version": { "version": {
"type": "string" "type": "string"
}, },
......
...@@ -23,6 +23,19 @@ RSpec.describe API::ProjectPackages do ...@@ -23,6 +23,19 @@ RSpec.describe API::ProjectPackages do
it_behaves_like 'returns packages', :project, :no_type it_behaves_like 'returns packages', :project, :no_type
end end
context 'with conan package' do
let!(:conan_package) { create(:conan_package, project: project) }
it 'uses the conan recipe as the package name' do
subject
response_conan_package = json_response.find { |package| package['id'] == conan_package.id }
expect(response_conan_package['name']).to eq(conan_package.conan_recipe)
expect(response_conan_package['conan_package_name']).to eq(conan_package.name)
end
end
context 'project is private' do context 'project is private' do
let(:project) { create(:project, :private) } let(:project) { create(:project, :private) }
......
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