Commit 88be2501 authored by Stan Hu's avatar Stan Hu

Merge branch 'mo-use-default-branch-for-code-coverage' into 'master'

Use default_branch for code coverage

See merge request gitlab-org/gitlab!46151
parents 25b436b4 f6a9650e
......@@ -151,6 +151,7 @@ module EE
results = ::Ci::DailyBuildGroupReportResult
.by_projects(project_ids)
.with_coverage
.with_default_branch
.latest
.summaries_per_project
......
......@@ -37,14 +37,26 @@ RSpec.describe 'Getting code coverage summary in a project' do
end
context 'when project has coverage' do
let!(:daily_build_group_report_result) { create(:ci_daily_build_group_report_result, project: project) }
context 'for the default branch' do
let!(:daily_build_group_report_result) { create(:ci_daily_build_group_report_result, project: project) }
it 'contains code coverage summary data', :aggregates_failures do
post_graphql(query, current_user: current_user)
it 'contains code coverage summary data', :aggregates_failures do
post_graphql(query, current_user: current_user)
expect(code_coverage_summary_graphql_data.dig('averageCoverage')).to eq(77.0)
expect(code_coverage_summary_graphql_data.dig('coverageCount')).to eq(1)
expect(code_coverage_summary_graphql_data.dig('lastUpdatedAt')).to eq(daily_build_group_report_result.date.to_s)
end
end
context 'not for the default branch' do
let!(:daily_build_group_report_result) { create(:ci_daily_build_group_report_result, :on_feature_branch, project: project) }
it 'returns nil' do
post_graphql(query, current_user: current_user)
expect(code_coverage_summary_graphql_data.dig('averageCoverage')).to eq(77.0)
expect(code_coverage_summary_graphql_data.dig('coverageCount')).to eq(1)
expect(code_coverage_summary_graphql_data.dig('lastUpdatedAt')).to eq(daily_build_group_report_result.date.to_s)
expect(code_coverage_summary_graphql_data).to be_nil
end
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