Commit c93fd8db authored by Jarka Košanová's avatar Jarka Košanová

Merge branch 'mo-improve-coverage-spec' into 'master'

Refactor daily coverage specs

See merge request gitlab-org/gitlab!54081
parents 6d9df31f 31f679da
...@@ -3,17 +3,13 @@ ...@@ -3,17 +3,13 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Ci::DailyBuildGroupReportResultService, '#execute' do RSpec.describe Ci::DailyBuildGroupReportResultService, '#execute' do
let!(:pipeline) { create(:ci_pipeline, created_at: '2020-02-06 00:01:10') } let_it_be(:group) { create(:group, :private) }
let!(:rspec_job) { create(:ci_build, pipeline: pipeline, name: '3/3 rspec', coverage: 80) } let_it_be(:pipeline) { create(:ci_pipeline, project: create(:project, group: group), created_at: '2020-02-06 00:01:10') }
let!(:karma_job) { create(:ci_build, pipeline: pipeline, name: '2/2 karma', coverage: 90) } let_it_be(:rspec_job) { create(:ci_build, pipeline: pipeline, name: '3/3 rspec', coverage: 80) }
let!(:extra_job) { create(:ci_build, pipeline: pipeline, name: 'extra', coverage: nil) } let_it_be(:karma_job) { create(:ci_build, pipeline: pipeline, name: '2/2 karma', coverage: 90) }
let!(:group) { create(:group, :private) } let_it_be(:extra_job) { create(:ci_build, pipeline: pipeline, name: 'extra', coverage: nil) }
let(:coverages) { Ci::DailyBuildGroupReportResult.all } let(:coverages) { Ci::DailyBuildGroupReportResult.all }
before do
pipeline.project.group = group
end
it 'creates daily code coverage record for each job in the pipeline that has coverage value' do it 'creates daily code coverage record for each job in the pipeline that has coverage value' do
described_class.new.execute(pipeline) described_class.new.execute(pipeline)
...@@ -25,7 +21,7 @@ RSpec.describe Ci::DailyBuildGroupReportResultService, '#execute' do ...@@ -25,7 +21,7 @@ RSpec.describe Ci::DailyBuildGroupReportResultService, '#execute' do
group_name: rspec_job.group_name, group_name: rspec_job.group_name,
data: { 'coverage' => rspec_job.coverage }, data: { 'coverage' => rspec_job.coverage },
date: pipeline.created_at.to_date, date: pipeline.created_at.to_date,
group_id: pipeline.project.group.id group_id: group.id
) )
end end
...@@ -37,7 +33,7 @@ RSpec.describe Ci::DailyBuildGroupReportResultService, '#execute' do ...@@ -37,7 +33,7 @@ RSpec.describe Ci::DailyBuildGroupReportResultService, '#execute' do
group_name: karma_job.group_name, group_name: karma_job.group_name,
data: { 'coverage' => karma_job.coverage }, data: { 'coverage' => karma_job.coverage },
date: pipeline.created_at.to_date, date: pipeline.created_at.to_date,
group_id: pipeline.project.group.id group_id: group.id
) )
end end
...@@ -162,10 +158,6 @@ RSpec.describe Ci::DailyBuildGroupReportResultService, '#execute' do ...@@ -162,10 +158,6 @@ RSpec.describe Ci::DailyBuildGroupReportResultService, '#execute' do
let!(:some_job) { create(:ci_build, pipeline: new_pipeline, name: 'foo') } let!(:some_job) { create(:ci_build, pipeline: new_pipeline, name: 'foo') }
before do
new_pipeline.project.group = group
end
it 'does nothing' do it 'does nothing' do
expect { described_class.new.execute(new_pipeline) }.not_to raise_error expect { described_class.new.execute(new_pipeline) }.not_to raise_error
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