Commit e96063ee authored by Imre Farkas's avatar Imre Farkas

Merge branch '239130-conan-recipe-display-be' into 'master'

Use Conan recipe as package name in API response

See merge request gitlab-org/gitlab!42860
parents d6f2a64d ee43db9b
......@@ -42,7 +42,7 @@ export default {
</script>
<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-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:
"version": "1.0.3",
"package_type": "npm",
"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
extend ::API::Entities::EntityHelpers
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 :package_type
......
......@@ -48,7 +48,7 @@ RSpec.describe 'Group Packages' do
it 'allows you to navigate to the project page' do
page.within('[data-qa-selector="packages-table"]') do
click_link project.name
find('[data-qa-selector="package-path"]', text: project.name).click
end
expect(page).to have_current_path(project_path(project))
......
......@@ -11,6 +11,9 @@
"name": {
"type": "string"
},
"conan_package_name": {
"type": "string"
},
"version": {
"type": "string"
},
......
......@@ -23,6 +23,19 @@ RSpec.describe API::ProjectPackages do
it_behaves_like 'returns packages', :project, :no_type
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
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