2020-07-28 23:09:34 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2022-07-23 23:45:48 +05:30
|
|
|
RSpec.describe 'Resolvers::GroupPackagesResolver' do
|
2020-07-28 23:09:34 +05:30
|
|
|
include GraphqlHelpers
|
|
|
|
|
2022-07-23 23:45:48 +05:30
|
|
|
let_it_be(:described_class) { Resolvers::GroupPackagesResolver }
|
2020-07-28 23:09:34 +05:30
|
|
|
let_it_be(:user) { create(:user) }
|
2021-04-17 20:07:23 +05:30
|
|
|
let_it_be(:group) { create(:group, :public) }
|
2021-09-04 01:27:46 +05:30
|
|
|
let_it_be(:project) { create(:project, :public, group: group, path: 'a') }
|
2021-06-08 01:23:25 +05:30
|
|
|
|
|
|
|
let(:args) do
|
2022-07-23 23:45:48 +05:30
|
|
|
{ sort: 'CREATED_DESC' }
|
2021-06-08 01:23:25 +05:30
|
|
|
end
|
2020-07-28 23:09:34 +05:30
|
|
|
|
|
|
|
describe '#resolve' do
|
2021-06-08 01:23:25 +05:30
|
|
|
subject { resolve(described_class, ctx: { current_user: user }, obj: group, args: args).to_a }
|
2020-07-28 23:09:34 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
it_behaves_like 'group and projects packages resolver'
|
2021-09-04 01:27:46 +05:30
|
|
|
|
|
|
|
describe 'project_path sorting' do
|
|
|
|
let_it_be(:project2) { create(:project, :public, group: group, path: 'b') }
|
2023-01-13 00:05:48 +05:30
|
|
|
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) }
|
2021-09-04 01:27:46 +05:30
|
|
|
|
|
|
|
context 'filter by package_name' do
|
2022-07-23 23:45:48 +05:30
|
|
|
let(:args) { { sort: 'PROJECT_PATH_DESC' } }
|
2021-09-04 01:27:46 +05:30
|
|
|
|
|
|
|
it { is_expected.to eq([package4, package2, package3, package]) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'filter by package_type' do
|
2022-07-23 23:45:48 +05:30
|
|
|
let(:args) { { sort: 'PROJECT_PATH_ASC' } }
|
2021-09-04 01:27:46 +05:30
|
|
|
|
|
|
|
it { is_expected.to eq([package, package3, package2, package4]) }
|
|
|
|
end
|
|
|
|
end
|
2020-07-28 23:09:34 +05:30
|
|
|
end
|
|
|
|
end
|