diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-14 15:09:37 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-14 15:09:37 +0300 |
commit | b7f103736153a739f0da400eba20a155e0db2797 (patch) | |
tree | ad802e7e9b38bb66decea4639a60fea0982eacc1 /spec/models | |
parent | bbacb6748ab541728ac22ee71eb1ffd3884d2a10 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/ci/job_artifact_spec.rb | 78 | ||||
-rw-r--r-- | spec/models/work_items/type_spec.rb | 6 |
2 files changed, 81 insertions, 3 deletions
diff --git a/spec/models/ci/job_artifact_spec.rb b/spec/models/ci/job_artifact_spec.rb index 83c233fa942..498af80dbb6 100644 --- a/spec/models/ci/job_artifact_spec.rb +++ b/spec/models/ci/job_artifact_spec.rb @@ -824,4 +824,82 @@ RSpec.describe Ci::JobArtifact, feature_category: :build_artifacts do it { is_expected.to eq(artifact.file.filename) } end + + describe '#to_deleted_object_attrs' do + let(:pick_up_at) { nil } + let(:expire_at) { nil } + let(:file_final_path) { nil } + + let(:artifact) do + create( + :ci_job_artifact, + :archive, + :remote_store, + file_final_path: file_final_path, + expire_at: expire_at + ) + end + + subject(:attributes) { artifact.to_deleted_object_attrs(pick_up_at) } + + before do + stub_artifacts_object_storage + end + + shared_examples_for 'returning attributes for object deletion' do + it 'returns the file store' do + expect(attributes[:file_store]).to eq(artifact.file_store) + end + + context 'when pick_up_at is present' do + let(:pick_up_at) { 2.hours.ago } + + it 'returns the pick_up_at value' do + expect(attributes[:pick_up_at]).to eq(pick_up_at) + end + end + + context 'when pick_up_at is not present' do + context 'and expire_at is present' do + let(:expire_at) { 4.hours.ago } + + it 'sets expire_at as pick_up_at' do + expect(attributes[:pick_up_at]).to eq(expire_at) + end + end + + context 'and expire_at is not present' do + it 'sets current time as pick_up_at' do + freeze_time do + expect(attributes[:pick_up_at]).to eq(Time.current) + end + end + end + end + end + + context 'when file_final_path is present' do + let(:file_final_path) { 'some/hash/path/to/randomfile' } + + it 'returns the store_dir and file based on the file_final_path' do + expect(attributes).to include( + store_dir: 'some/hash/path/to', + file: 'randomfile' + ) + end + + it_behaves_like 'returning attributes for object deletion' + end + + context 'when file_final_path is not present' do + it 'returns the uploader default store_dir and file_identifier' do + expect(attributes).to include( + store_dir: artifact.file.store_dir.to_s, + file: artifact.file_identifier + ) + end + + it_behaves_like 'returning attributes for object deletion' + end + end end diff --git a/spec/models/work_items/type_spec.rb b/spec/models/work_items/type_spec.rb index 024157731a9..e4d2ccdfc5a 100644 --- a/spec/models/work_items/type_spec.rb +++ b/spec/models/work_items/type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe WorkItems::Type do +RSpec.describe WorkItems::Type, feature_category: :team_planning do describe 'modules' do it { is_expected.to include_module(CacheMarkdownField) } end @@ -49,10 +49,10 @@ RSpec.describe WorkItems::Type do it 'deletes type but not unrelated issues' do type = create(:work_item_type) - expect(described_class.count).to eq(9) + expect(described_class.count).to eq(10) expect { type.destroy! }.not_to change(Issue, :count) - expect(described_class.count).to eq(8) + expect(described_class.count).to eq(9) end end |