Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/requests/api/graphql/ci/pipelines_spec.rb')
-rw-r--r--spec/requests/api/graphql/ci/pipelines_spec.rb108
1 files changed, 108 insertions, 0 deletions
diff --git a/spec/requests/api/graphql/ci/pipelines_spec.rb b/spec/requests/api/graphql/ci/pipelines_spec.rb
index 95ddd0250e7..5ae68be46a2 100644
--- a/spec/requests/api/graphql/ci/pipelines_spec.rb
+++ b/spec/requests/api/graphql/ci/pipelines_spec.rb
@@ -12,6 +12,38 @@ RSpec.describe 'Query.project(fullPath).pipelines' do
travel_to(Time.current) { example.run }
end
+ describe 'sha' do
+ let_it_be(:pipeline) { create(:ci_pipeline, project: project) }
+
+ let(:pipelines_graphql_data) { graphql_data.dig(*%w[project pipelines nodes]).first }
+
+ let(:query) do
+ %(
+ query {
+ project(fullPath: "#{project.full_path}") {
+ pipelines {
+ nodes {
+ fullSha: sha
+ shortSha: sha(format: SHORT)
+ alsoFull: sha(format: LONG)
+ }
+ }
+ }
+ }
+ )
+ end
+
+ it 'returns all formats of the SHA' do
+ post_graphql(query, current_user: user)
+
+ expect(pipelines_graphql_data).to include(
+ 'fullSha' => eq(pipeline.sha),
+ 'alsoFull' => eq(pipeline.sha),
+ 'shortSha' => eq(pipeline.short_sha)
+ )
+ end
+ end
+
describe 'duration fields' do
let_it_be(:pipeline) do
create(:ci_pipeline, project: project)
@@ -251,6 +283,50 @@ RSpec.describe 'Query.project(fullPath).pipelines' do
end
end
+ describe 'warningMessages' do
+ let_it_be(:pipeline) { create(:ci_pipeline, project: project) }
+ let_it_be(:warning_message) { create(:ci_pipeline_message, pipeline: pipeline, content: 'warning') }
+
+ let(:pipelines_graphql_data) { graphql_data.dig(*%w[project pipelines nodes]).first }
+
+ let(:query) do
+ %(
+ query {
+ project(fullPath: "#{project.full_path}") {
+ pipelines {
+ nodes {
+ warningMessages {
+ content
+ }
+ }
+ }
+ }
+ }
+ )
+ end
+
+ it 'returns pipeline warnings' do
+ post_graphql(query, current_user: user)
+
+ expect(pipelines_graphql_data['warningMessages']).to contain_exactly(
+ a_hash_including('content' => 'warning')
+ )
+ end
+
+ it 'avoids N+1 queries' do
+ control_count = ActiveRecord::QueryRecorder.new do
+ post_graphql(query, current_user: user)
+ end
+
+ pipeline_2 = create(:ci_pipeline, project: project)
+ create(:ci_pipeline_message, pipeline: pipeline_2, content: 'warning')
+
+ expect do
+ post_graphql(query, current_user: user)
+ end.not_to exceed_query_limit(control_count)
+ end
+ end
+
describe '.jobs(securityReportTypes)' do
let_it_be(:query) do
%(
@@ -420,4 +496,36 @@ RSpec.describe 'Query.project(fullPath).pipelines' do
end
end
end
+
+ describe 'ref_path' do
+ let_it_be(:merge_request) { create(:merge_request, source_project: project) }
+ let_it_be(:pipeline_1) { create(:ci_pipeline, project: project, user: user, merge_request: merge_request) }
+ let_it_be(:pipeline_2) { create(:ci_pipeline, project: project, user: user, merge_request: merge_request) }
+
+ let(:query) do
+ %(
+ query {
+ project(fullPath: "#{project.full_path}") {
+ pipelines {
+ nodes {
+ refPath
+ }
+ }
+ }
+ }
+ )
+ end
+
+ it 'avoids N+1 queries' do
+ control_count = ActiveRecord::QueryRecorder.new do
+ post_graphql(query, current_user: user)
+ end
+
+ create(:ci_pipeline, project: project, user: user, merge_request: merge_request)
+
+ expect do
+ post_graphql(query, current_user: user)
+ end.not_to exceed_query_limit(control_count)
+ end
+ end
end