Commit 31f679da authored by Maxime Orefice's avatar Maxime Orefice

Refactor daily coverage specs

parent a64f507e
......@@ -3,17 +3,13 @@
require 'spec_helper'
RSpec.describe Ci::DailyBuildGroupReportResultService, '#execute' do
let!(:pipeline) { create(:ci_pipeline, created_at: '2020-02-06 00:01:10') }
let!(:rspec_job) { create(:ci_build, pipeline: pipeline, name: '3/3 rspec', coverage: 80) }
let!(:karma_job) { create(:ci_build, pipeline: pipeline, name: '2/2 karma', coverage: 90) }
let!(:extra_job) { create(:ci_build, pipeline: pipeline, name: 'extra', coverage: nil) }
let!(:group) { create(:group, :private) }
let_it_be(:group) { create(:group, :private) }
let_it_be(:pipeline) { create(:ci_pipeline, project: create(:project, group: group), created_at: '2020-02-06 00:01:10') }
let_it_be(:rspec_job) { create(:ci_build, pipeline: pipeline, name: '3/3 rspec', coverage: 80) }
let_it_be(:karma_job) { create(:ci_build, pipeline: pipeline, name: '2/2 karma', coverage: 90) }
let_it_be(:extra_job) { create(:ci_build, pipeline: pipeline, name: 'extra', coverage: nil) }
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
described_class.new.execute(pipeline)
......@@ -25,7 +21,7 @@ RSpec.describe Ci::DailyBuildGroupReportResultService, '#execute' do
group_name: rspec_job.group_name,
data: { 'coverage' => rspec_job.coverage },
date: pipeline.created_at.to_date,
group_id: pipeline.project.group.id
group_id: group.id
)
end
......@@ -37,7 +33,7 @@ RSpec.describe Ci::DailyBuildGroupReportResultService, '#execute' do
group_name: karma_job.group_name,
data: { 'coverage' => karma_job.coverage },
date: pipeline.created_at.to_date,
group_id: pipeline.project.group.id
group_id: group.id
)
end
......@@ -162,10 +158,6 @@ RSpec.describe Ci::DailyBuildGroupReportResultService, '#execute' do
let!(:some_job) { create(:ci_build, pipeline: new_pipeline, name: 'foo') }
before do
new_pipeline.project.group = group
end
it 'does nothing' do
expect { described_class.new.execute(new_pipeline) }.not_to raise_error
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