summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/ci/pipeline_spec.rb21
-rw-r--r--spec/models/merge_request_diff_spec.rb86
2 files changed, 15 insertions, 92 deletions
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb
index 134fb1143cc..7b58acafd93 100644
--- a/spec/models/ci/pipeline_spec.rb
+++ b/spec/models/ci/pipeline_spec.rb
@@ -68,14 +68,23 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
describe '#downloadable_artifacts' do
- let(:build) { create(:ci_build, pipeline: pipeline) }
+ let_it_be(:build) { create(:ci_build, pipeline: pipeline) }
+ let_it_be(:downloadable_artifact) { create(:ci_job_artifact, :codequality, job: build) }
+ let_it_be(:expired_artifact) { create(:ci_job_artifact, :junit, :expired, job: build) }
+ let_it_be(:undownloadable_artifact) { create(:ci_job_artifact, :trace, job: build) }
- it 'returns downloadable artifacts that have not expired' do
- downloadable_artifact = create(:ci_job_artifact, :codequality, job: build)
- _expired_artifact = create(:ci_job_artifact, :junit, :expired, job: build)
- _undownloadable_artifact = create(:ci_job_artifact, :trace, job: build)
+ context 'when artifacts are locked' do
+ it 'returns downloadable artifacts including locked artifacts' do
+ expect(pipeline.downloadable_artifacts).to contain_exactly(downloadable_artifact, expired_artifact)
+ end
+ end
- expect(pipeline.downloadable_artifacts).to contain_exactly(downloadable_artifact)
+ context 'when artifacts are unlocked' do
+ it 'returns only downloadable artifacts not expired' do
+ expired_artifact.job.pipeline.unlocked!
+
+ expect(pipeline.reload.downloadable_artifacts).to contain_exactly(downloadable_artifact)
+ end
end
end
end
diff --git a/spec/models/merge_request_diff_spec.rb b/spec/models/merge_request_diff_spec.rb
index 5101271d257..0e843f0d9dc 100644
--- a/spec/models/merge_request_diff_spec.rb
+++ b/spec/models/merge_request_diff_spec.rb
@@ -485,27 +485,6 @@ RSpec.describe MergeRequestDiff do
'files/whitespace'
])
end
-
- context 'when sort_diffs feature flag is disabled' do
- before do
- stub_feature_flags(sort_diffs: false)
- end
-
- it 'does not sort diff files directory first' do
- expect(diff_with_commits.diffs_in_batch(1, 10, diff_options: diff_options).diff_file_paths).to eq([
- '.DS_Store',
- '.gitattributes',
- '.gitignore',
- '.gitmodules',
- 'CHANGELOG',
- 'README',
- 'bar/branch-test.txt',
- 'custom-highlighting/test.gitlab-custom',
- 'encoding/iso8859.txt',
- 'files/.DS_Store'
- ])
- end
- end
end
end
@@ -581,37 +560,6 @@ RSpec.describe MergeRequestDiff do
'gitlab-shell'
])
end
-
- context 'when sort_diffs feature flag is disabled' do
- before do
- stub_feature_flags(sort_diffs: false)
- end
-
- it 'does not sort diff files directory first' do
- expect(diff_with_commits.diffs(diff_options).diff_file_paths).to eq([
- '.DS_Store',
- '.gitattributes',
- '.gitignore',
- '.gitmodules',
- 'CHANGELOG',
- 'README',
- 'bar/branch-test.txt',
- 'custom-highlighting/test.gitlab-custom',
- 'encoding/iso8859.txt',
- 'files/.DS_Store',
- 'files/images/wm.svg',
- 'files/js/commit.coffee',
- 'files/lfs/lfs_object.iso',
- 'files/ruby/popen.rb',
- 'files/ruby/regex.rb',
- 'files/whitespace',
- 'foo/bar/.gitkeep',
- 'gitlab-grack',
- 'gitlab-shell',
- 'with space/README.md'
- ])
- end
- end
end
end
@@ -718,40 +666,6 @@ RSpec.describe MergeRequestDiff do
])
end
- context 'when sort_diffs feature flag is disabled' do
- before do
- stub_feature_flags(sort_diffs: false)
- end
-
- it 'persists diff files unsorted by directory first' do
- mr_diff = create(:merge_request).merge_request_diff
- diff_files_paths = mr_diff.merge_request_diff_files.map { |file| file.new_path.presence || file.old_path }
-
- expect(diff_files_paths).to eq([
- '.DS_Store',
- '.gitattributes',
- '.gitignore',
- '.gitmodules',
- 'CHANGELOG',
- 'README',
- 'bar/branch-test.txt',
- 'custom-highlighting/test.gitlab-custom',
- 'encoding/iso8859.txt',
- 'files/.DS_Store',
- 'files/images/wm.svg',
- 'files/js/commit.coffee',
- 'files/lfs/lfs_object.iso',
- 'files/ruby/popen.rb',
- 'files/ruby/regex.rb',
- 'files/whitespace',
- 'foo/bar/.gitkeep',
- 'gitlab-grack',
- 'gitlab-shell',
- 'with space/README.md'
- ])
- end
- end
-
it 'expands collapsed diffs before saving' do
mr_diff = create(:merge_request, source_branch: 'expand-collapse-lines', target_branch: 'master').merge_request_diff
diff_file = mr_diff.merge_request_diff_files.find_by(new_path: 'expand-collapse/file-5.txt')