Commit 379a66cf authored by Kerri Miller's avatar Kerri Miller

Merge branch 'filter-a-pipeline-by-author-and-tagName' into 'master'

Filter a pipeline by author

See merge request gitlab-org/gitlab!79470
parents e7a59661 d704138c
......@@ -20,11 +20,14 @@ module ResolvesPipelines
GraphQL::Types::String,
required: false,
description: "Filter pipelines by the sha of the commit they are run for."
argument :source,
GraphQL::Types::String,
required: false,
description: "Filter pipelines by their source."
argument :username,
GraphQL::Types::String,
required: false,
description: "Filter pipelines by the user that triggered the pipeline."
end
class_methods do
......
......@@ -9514,6 +9514,7 @@ four standard [pagination arguments](#connection-pagination-arguments):
| <a id="commitpipelinessha"></a>`sha` | [`String`](#string) | Filter pipelines by the sha of the commit they are run for. |
| <a id="commitpipelinessource"></a>`source` | [`String`](#string) | Filter pipelines by their source. |
| <a id="commitpipelinesstatus"></a>`status` | [`PipelineStatusEnum`](#pipelinestatusenum) | Filter pipelines by their status. |
| <a id="commitpipelinesusername"></a>`username` | [`String`](#string) | Filter pipelines by the user that triggered the pipeline. |
### `ComplianceFramework`
......@@ -12379,6 +12380,7 @@ four standard [pagination arguments](#connection-pagination-arguments):
| <a id="mergerequestpipelinessha"></a>`sha` | [`String`](#string) | Filter pipelines by the sha of the commit they are run for. |
| <a id="mergerequestpipelinessource"></a>`source` | [`String`](#string) | Filter pipelines by their source. |
| <a id="mergerequestpipelinesstatus"></a>`status` | [`PipelineStatusEnum`](#pipelinestatusenum) | Filter pipelines by their status. |
| <a id="mergerequestpipelinesusername"></a>`username` | [`String`](#string) | Filter pipelines by the user that triggered the pipeline. |
##### `MergeRequest.reference`
......@@ -14420,6 +14422,7 @@ four standard [pagination arguments](#connection-pagination-arguments):
| <a id="projectpipelinessha"></a>`sha` | [`String`](#string) | Filter pipelines by the sha of the commit they are run for. |
| <a id="projectpipelinessource"></a>`source` | [`String`](#string) | Filter pipelines by their source. |
| <a id="projectpipelinesstatus"></a>`status` | [`PipelineStatusEnum`](#pipelinestatusenum) | Filter pipelines by their status. |
| <a id="projectpipelinesusername"></a>`username` | [`String`](#string) | Filter pipelines by the user that triggered the pipeline. |
##### `Project.projectMembers`
......@@ -15,7 +15,7 @@ RSpec.describe ResolvesPipelines do
end
end
let(:current_user) { create(:user) }
let_it_be(:current_user) { create(:user) }
let_it_be(:project) { create(:project, :private) }
let_it_be(:pipeline) { create(:ci_pipeline, project: project) }
......@@ -23,13 +23,15 @@ RSpec.describe ResolvesPipelines do
let_it_be(:success_pipeline) { create(:ci_pipeline, :success, project: project) }
let_it_be(:ref_pipeline) { create(:ci_pipeline, project: project, ref: 'awesome-feature') }
let_it_be(:sha_pipeline) { create(:ci_pipeline, project: project, sha: 'deadbeef') }
let_it_be(:username_pipeline) { create(:ci_pipeline, project: project, user: current_user) }
let_it_be(:all_pipelines) do
[
pipeline,
failed_pipeline,
success_pipeline,
ref_pipeline,
sha_pipeline
sha_pipeline,
username_pipeline
]
end
......@@ -37,7 +39,7 @@ RSpec.describe ResolvesPipelines do
project.add_developer(current_user)
end
it { is_expected.to have_graphql_arguments(:status, :scope, :ref, :sha, :source) }
it { is_expected.to have_graphql_arguments(:status, :scope, :ref, :sha, :source, :username) }
it 'finds all pipelines' do
expect(resolve_pipelines).to contain_exactly(*all_pipelines)
......@@ -71,6 +73,10 @@ RSpec.describe ResolvesPipelines do
end
end
it 'allows filtering by username' do
expect(resolve_pipelines(username: current_user.username)).to contain_exactly(username_pipeline)
end
it 'does not return any pipelines if the user does not have access' do
expect(resolve_pipelines({}, {})).to be_empty
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