diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 01:45:44 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 01:45:44 +0000 |
commit | 85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch) | |
tree | 9160f299afd8c80c038f08e1545be119f5e3f1e1 /spec/presenters/ci | |
parent | 15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff) | |
download | gitlab-ce-85dc423f7090da0a52c73eb66faf22ddb20efff9.tar.gz |
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'spec/presenters/ci')
-rw-r--r-- | spec/presenters/ci/build_presenter_spec.rb | 6 | ||||
-rw-r--r-- | spec/presenters/ci/pipeline_artifacts/code_coverage_presenter_spec.rb | 62 | ||||
-rw-r--r-- | spec/presenters/ci/pipeline_presenter_spec.rb | 2 |
3 files changed, 66 insertions, 4 deletions
diff --git a/spec/presenters/ci/build_presenter_spec.rb b/spec/presenters/ci/build_presenter_spec.rb index 8d302b242b3..1ff2ea3d225 100644 --- a/spec/presenters/ci/build_presenter_spec.rb +++ b/spec/presenters/ci/build_presenter_spec.rb @@ -228,7 +228,7 @@ RSpec.describe Ci::BuildPresenter do let(:build) { create(:ci_build, :scheduled) } it 'returns execution time' do - Timecop.freeze do + freeze_time do is_expected.to be_like_time(60.0) end end @@ -238,7 +238,7 @@ RSpec.describe Ci::BuildPresenter do let(:build) { create(:ci_build, :expired_scheduled) } it 'returns execution time' do - Timecop.freeze do + freeze_time do is_expected.to eq(0) end end @@ -249,7 +249,7 @@ RSpec.describe Ci::BuildPresenter do let(:build) { create(:ci_build) } it 'does not return execution time' do - Timecop.freeze do + freeze_time do is_expected.to be_falsy end end diff --git a/spec/presenters/ci/pipeline_artifacts/code_coverage_presenter_spec.rb b/spec/presenters/ci/pipeline_artifacts/code_coverage_presenter_spec.rb new file mode 100644 index 00000000000..e679f5fa144 --- /dev/null +++ b/spec/presenters/ci/pipeline_artifacts/code_coverage_presenter_spec.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Ci::PipelineArtifacts::CodeCoveragePresenter do + let(:pipeline_artifact) { create(:ci_pipeline_artifact, :with_code_coverage_with_multiple_files) } + + subject(:presenter) { described_class.new(pipeline_artifact) } + + describe '#for_files' do + subject { presenter.for_files(filenames) } + + context 'when code coverage has data' do + context 'when filenames is empty' do + let(:filenames) { %w() } + + it 'returns hash without coverage' do + expect(subject).to match(files: {}) + end + end + + context 'when filenames do not match code coverage data' do + let(:filenames) { %w(demo.rb) } + + it 'returns hash without coverage' do + expect(subject).to match(files: {}) + end + end + + context 'when filenames matches code coverage data' do + context 'when asking for one filename' do + let(:filenames) { %w(file_a.rb) } + + it 'returns coverage for the given filename' do + expect(subject).to match(files: { "file_a.rb" => { "1" => 1, "2" => 1, "3" => 1 } }) + end + end + + context 'when asking for multiple filenames' do + let(:filenames) { %w(file_a.rb file_b.rb) } + + it 'returns coverage for a the given filenames' do + expect(subject).to match( + files: { + "file_a.rb" => { + "1" => 1, + "2" => 1, + "3" => 1 + }, + "file_b.rb" => { + "1" => 0, + "2" => 0, + "3" => 0 + } + } + ) + end + end + end + end + end +end diff --git a/spec/presenters/ci/pipeline_presenter_spec.rb b/spec/presenters/ci/pipeline_presenter_spec.rb index 158daad97f5..18f79bc930c 100644 --- a/spec/presenters/ci/pipeline_presenter_spec.rb +++ b/spec/presenters/ci/pipeline_presenter_spec.rb @@ -65,7 +65,7 @@ RSpec.describe Ci::PipelinePresenter do describe '#failure_reason' do context 'when pipeline has a failure reason' do - ::Ci::PipelineEnums.failure_reasons.keys.each do |failure_reason| + Enums::Ci::Pipeline.failure_reasons.keys.each do |failure_reason| context "when failure reason is #{failure_reason}" do before do pipeline.failure_reason = failure_reason |