Commit f6a9650e authored by Maxime Orefice's avatar Maxime Orefice Committed by Stan Hu

Use default_branch for code coverage

This commits allow to fetch our code coverage data for the
default_branch with our graphql endpoint.
parent 180f2825
......@@ -153,6 +153,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