diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-15 06:08:03 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-15 06:08:03 +0300 |
commit | 00880613328c66f85aee755fcd1e70ce4cb9fcdf (patch) | |
tree | a4abf7a4c00248d865dba9775482cd90f8467bfd /spec | |
parent | 45465a1f217b65ee3b11870175f363afaf912eb9 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/finders/releases_finder_spec.rb | 15 | ||||
-rw-r--r-- | spec/models/release_spec.rb | 14 |
2 files changed, 29 insertions, 0 deletions
diff --git a/spec/finders/releases_finder_spec.rb b/spec/finders/releases_finder_spec.rb index bee0ae0d5c1..2603a205c42 100644 --- a/spec/finders/releases_finder_spec.rb +++ b/spec/finders/releases_finder_spec.rb @@ -26,6 +26,18 @@ RSpec.describe ReleasesFinder, feature_category: :release_orchestration do end end + shared_examples_for 'when a release is tagless' do + # There shouldn't be tags in this state, but because some exist in production and cause page loading errors, this + # test exists. We can test empty string but not the nil value since there is a not null constraint at the database + # level. + it 'does not return the tagless release' do + empty_string_tag = create(:release, project: project, tag: 'v99.0.0') + empty_string_tag.update_column(:tag, '') + + expect(subject).not_to include(empty_string_tag) + end + end + shared_examples_for 'preload' do it 'preloads associations' do expect(Release).to receive(:preloaded).once.and_call_original @@ -89,6 +101,7 @@ RSpec.describe ReleasesFinder, feature_category: :release_orchestration do it_behaves_like 'preload' it_behaves_like 'when a tag parameter is passed' + it_behaves_like 'when a release is tagless' end end @@ -132,6 +145,7 @@ RSpec.describe ReleasesFinder, feature_category: :release_orchestration do it_behaves_like 'preload' it_behaves_like 'when a tag parameter is passed' + it_behaves_like 'when a release is tagless' context 'with sorting parameters' do it 'sorted by released_at in descending order by default' do @@ -223,6 +237,7 @@ RSpec.describe ReleasesFinder, feature_category: :release_orchestration do end it_behaves_like 'preload' + it_behaves_like 'when a release is tagless' end end end diff --git a/spec/models/release_spec.rb b/spec/models/release_spec.rb index 7b07cb62e0d..6a871ec039c 100644 --- a/spec/models/release_spec.rb +++ b/spec/models/release_spec.rb @@ -122,6 +122,20 @@ RSpec.describe Release, feature_category: :release_orchestration do end end + describe 'tagged' do + # We only test for empty string since there's a not null constraint at the database level + it 'does not return the tagless release' do + empty_string_tag = create(:release, tag: 'v99.0.0') + empty_string_tag.update_column(:tag, '') + + expect(described_class.tagged).not_to include(empty_string_tag) + end + + it 'does return the tagged releases' do + expect(described_class.tagged).to include(release) + end + end + describe 'latest releases' do let_it_be(:yesterday) { Time.zone.now - 1.day } let_it_be(:tomorrow) { Time.zone.now + 1.day } |