Commit 59c3615c authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '328212-graphql-project-path' into 'master'

Add order_project_path to package graphql API sort

See merge request gitlab-org/gitlab!62473
parents 6aee3b0b 76ed6278
......@@ -6,10 +6,8 @@ module Types
graphql_name 'PackageGroupSort'
description 'Values for sorting group packages'
# The following enums are not available till we enable the new Arel node:
# See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/58657#note_552632305
# value 'PROJECT_PATH_DESC', 'Project by descending order.', value: :project_path_desc
# value 'PROJECT_PATH_ASC', 'Project by ascending order.', value: :project_path_asc
value 'PROJECT_PATH_DESC', 'Ordered by project path in descending order.', value: :project_path_desc
value 'PROJECT_PATH_ASC', 'Ordered by project path in ascending order.', value: :project_path_asc
end
end
end
......@@ -14662,6 +14662,8 @@ Values for sorting group packages.
| <a id="packagegroupsortcreated_desc"></a>`CREATED_DESC` | Ordered by created_at in descending order. |
| <a id="packagegroupsortname_asc"></a>`NAME_ASC` | Ordered by name in ascending order. |
| <a id="packagegroupsortname_desc"></a>`NAME_DESC` | Ordered by name in descending order. |
| <a id="packagegroupsortproject_path_asc"></a>`PROJECT_PATH_ASC` | Ordered by project path in ascending order. |
| <a id="packagegroupsortproject_path_desc"></a>`PROJECT_PATH_DESC` | Ordered by project path in descending order. |
| <a id="packagegroupsorttype_asc"></a>`TYPE_ASC` | Ordered by type in ascending order. |
| <a id="packagegroupsorttype_desc"></a>`TYPE_DESC` | Ordered by type in descending order. |
| <a id="packagegroupsortversion_asc"></a>`VERSION_ASC` | Ordered by version in ascending order. |
......
......@@ -7,7 +7,7 @@ RSpec.describe Resolvers::GroupPackagesResolver do
let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group, :public) }
let_it_be(:project) { create(:project, :public, group: group) }
let_it_be(:project) { create(:project, :public, group: group, path: 'a') }
let(:args) do
{ sort: :created_desc }
......@@ -17,5 +17,25 @@ RSpec.describe Resolvers::GroupPackagesResolver do
subject { resolve(described_class, ctx: { current_user: user }, obj: group, args: args).to_a }
it_behaves_like 'group and projects packages resolver'
describe 'project_path sorting' do
let_it_be(:project2) { create(:project, :public, group: group, path: 'b') }
let_it_be(:package) { create(:package, project: project ) }
let_it_be(:package2) { create(:package, project: project2 ) }
let_it_be(:package3) { create(:package, project: project ) }
let_it_be(:package4) { create(:package, project: project2 ) }
context 'filter by package_name' do
let(:args) { { sort: :project_path_desc } }
it { is_expected.to eq([package4, package2, package3, package]) }
end
context 'filter by package_type' do
let(:args) { { sort: :project_path_asc } }
it { is_expected.to eq([package, package3, package2, package4]) }
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe GitlabSchema.types['PackageGroupSort'] do
it 'exposes all package group sort values' do
expect(described_class.values.keys).to contain_exactly(*%w[CREATED_DESC CREATED_ASC NAME_DESC NAME_ASC PROJECT_PATH_DESC PROJECT_PATH_ASC VERSION_DESC VERSION_ASC TYPE_DESC TYPE_ASC])
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe GitlabSchema.types['PackageSort'] do
it 'exposes all package sort values' do
expect(described_class.values.keys).to contain_exactly(*%w[CREATED_DESC CREATED_ASC NAME_DESC NAME_ASC VERSION_DESC VERSION_ASC TYPE_DESC TYPE_ASC])
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