diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-21 18:10:03 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-21 18:10:03 +0300 |
commit | d5098d9fe3a5f05d9b90996851ab753f8b40cf65 (patch) | |
tree | 6f909667e89a3ad70e10c39b48fc417459b759fd /spec/models | |
parent | 4ea7a80898d3266d386ca928d7c253d4bf588e1c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/ci/pipeline_artifact_spec.rb | 46 | ||||
-rw-r--r-- | spec/models/ci/pipeline_spec.rb | 32 | ||||
-rw-r--r-- | spec/models/packages/package_spec.rb | 13 |
3 files changed, 72 insertions, 19 deletions
diff --git a/spec/models/ci/pipeline_artifact_spec.rb b/spec/models/ci/pipeline_artifact_spec.rb index 9d63d74a6cc..9d2172d7572 100644 --- a/spec/models/ci/pipeline_artifact_spec.rb +++ b/spec/models/ci/pipeline_artifact_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe Ci::PipelineArtifact, type: :model do - let_it_be(:coverage_report) { create(:ci_pipeline_artifact) } + let(:coverage_report) { create(:ci_pipeline_artifact) } describe 'associations' do it { is_expected.to belong_to(:pipeline) } @@ -44,24 +44,6 @@ RSpec.describe Ci::PipelineArtifact, type: :model do end end - describe '#set_size' do - subject { create(:ci_pipeline_artifact) } - - context 'when file is being created' do - it 'sets the size' do - expect(subject.size).to eq(85) - end - end - - context 'when file is being updated' do - it 'updates the size' do - subject.update!(file: fixture_file_upload('spec/fixtures/dk.png')) - - expect(subject.size).to eq(1062) - end - end - end - describe 'file is being stored' do subject { create(:ci_pipeline_artifact) } @@ -78,5 +60,31 @@ RSpec.describe Ci::PipelineArtifact, type: :model do it_behaves_like 'mounted file in object store' end end + + context 'when file contains multi-byte characters' do + let(:coverage_report_multibyte) { create(:ci_pipeline_artifact, :with_multibyte_characters) } + + it 'sets the size in bytesize' do + expect(coverage_report_multibyte.size).to eq(12) + end + end + end + + describe '.has_code_coverage?' do + subject { Ci::PipelineArtifact.has_code_coverage? } + + context 'when pipeline artifact has a code coverage' do + let!(:pipeline_artifact) { create(:ci_pipeline_artifact) } + + it 'returns true' do + expect(subject).to be_truthy + end + end + + context 'when pipeline artifact does not have a code coverage' do + it 'returns false' do + expect(subject).to be_falsey + end + end end end diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index b4e80fa7588..54dad2e1840 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -2948,6 +2948,38 @@ RSpec.describe Ci::Pipeline, :mailer do end end + describe '#has_coverage_reports?' do + subject { pipeline.has_coverage_reports? } + + context 'when pipeline has builds with coverage reports' do + before do + create(:ci_build, :coverage_reports, pipeline: pipeline, project: project) + end + + context 'when pipeline status is running' do + let(:pipeline) { create(:ci_pipeline, :running, project: project) } + + it { expect(subject).to be_falsey } + end + + context 'when pipeline status is success' do + let(:pipeline) { create(:ci_pipeline, :success, project: project) } + + it { expect(subject).to be_truthy } + end + end + + context 'when pipeline does not have builds with coverage reports' do + before do + create(:ci_build, :artifacts, pipeline: pipeline, project: project) + end + + let(:pipeline) { create(:ci_pipeline, :success, project: project) } + + it { expect(subject).to be_falsey } + end + end + describe '#test_report_summary' do subject { pipeline.test_report_summary } diff --git a/spec/models/packages/package_spec.rb b/spec/models/packages/package_spec.rb index 4170bf595f0..1de68070d0c 100644 --- a/spec/models/packages/package_spec.rb +++ b/spec/models/packages/package_spec.rb @@ -482,4 +482,17 @@ RSpec.describe Packages::Package, type: :model do it { is_expected.to contain_exactly(*tags) } end end + + describe 'plan_limits' do + Packages::Package.package_types.keys.without('composer').each do |pt| + context "File size limits for #{pt}" do + let(:package) { create("#{pt}_package") } + + it "plan_limits includes column #{pt}_max_file_size" do + expect { package.project.actual_limits.send("#{pt}_max_file_size") } + .not_to raise_error(NoMethodError) + end + end + end + end end |