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:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-10-19 00:11:14 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-10-19 00:11:14 +0300
commit0fd6206b8f54a122743dc993d31db31bc2ddac5d (patch)
treef3f5d4570b95e76a48d34f59c65e8c20653a0367 /spec/requests
parent962b96e640834c04a729f7478afa48d3dedf9fca (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests')
-rw-r--r--spec/requests/projects/merge_requests_controller_spec.rb56
1 files changed, 56 insertions, 0 deletions
diff --git a/spec/requests/projects/merge_requests_controller_spec.rb b/spec/requests/projects/merge_requests_controller_spec.rb
index e549913ccc3..4af8f4fac7f 100644
--- a/spec/requests/projects/merge_requests_controller_spec.rb
+++ b/spec/requests/projects/merge_requests_controller_spec.rb
@@ -148,6 +148,62 @@ RSpec.describe Projects::MergeRequestsController, feature_category: :source_code
expect(Gitlab::Json.parse(response.body)['count']['all']).to eq(2)
end
+ context 'when there are pipelines with failed builds' do
+ before do
+ pipeline = create_pipeline
+
+ create(:ci_build, :failed, pipeline: pipeline)
+ create(:ci_build, :failed, pipeline: pipeline)
+ end
+
+ it 'returns the failed build count but not the failed builds' do
+ get pipelines_project_merge_request_path(project, merge_request, format: :json)
+
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(Gitlab::Json.parse(response.body)['pipelines'].size).to eq(1)
+ expect(Gitlab::Json.parse(response.body)['pipelines'][0]['failed_builds_count']).to eq(2)
+ expect(Gitlab::Json.parse(response.body)['pipelines'][0]).not_to have_key('failed_builds')
+ end
+
+ it 'avoids N+1 queries', :use_sql_query_cache do
+ # warm up
+ get pipelines_project_merge_request_path(project, merge_request, format: :json)
+
+ control = ActiveRecord::QueryRecorder.new(skip_cached: false) do
+ get pipelines_project_merge_request_path(project, merge_request, format: :json)
+ end
+
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(Gitlab::Json.parse(response.body)['count']['all']).to eq(1)
+
+ pipeline_2 = create_pipeline
+ create(:ci_build, :failed, pipeline: pipeline_2)
+ create(:ci_build, :failed, pipeline: pipeline_2)
+
+ expect do
+ get pipelines_project_merge_request_path(project, merge_request, format: :json)
+ end.to issue_same_number_of_queries_as(control)
+
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(Gitlab::Json.parse(response.body)['count']['all']).to eq(2)
+ end
+
+ context 'when the FF ci_fix_performance_pipelines_json_endpoint is disabled' do
+ before do
+ stub_feature_flags(ci_fix_performance_pipelines_json_endpoint: false)
+ end
+
+ it 'returns the failed builds' do
+ get pipelines_project_merge_request_path(project, merge_request, format: :json)
+
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(Gitlab::Json.parse(response.body)['pipelines'].size).to eq(1)
+ expect(Gitlab::Json.parse(response.body)['pipelines'][0]['failed_builds_count']).to eq(2)
+ expect(Gitlab::Json.parse(response.body)['pipelines'][0]['failed_builds'].size).to eq(2)
+ end
+ end
+ end
+
private
def create_pipeline