Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2024-01-06 00:11:24 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2024-01-06 00:11:24 +0300
commit6fd670b99b45d3374f8b429e87be51dd67d6ab39 (patch)
treee3c6ad8503548b306cacd37c7d6c5b48a1a0a6c5 /spec/models
parent534ce3b2d0a6ec24de9c370e5b85c9528ff63e34 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/packages/protection/rule_spec.rb46
1 files changed, 24 insertions, 22 deletions
diff --git a/spec/models/packages/protection/rule_spec.rb b/spec/models/packages/protection/rule_spec.rb
index 3f0aefa945a..03d0440f0d9 100644
--- a/spec/models/packages/protection/rule_spec.rb
+++ b/spec/models/packages/protection/rule_spec.rb
@@ -35,30 +35,32 @@ RSpec.describe Packages::Protection::Rule, type: :model, feature_category: :pack
it { is_expected.to validate_uniqueness_of(:package_name_pattern).scoped_to(:project_id, :package_type) }
it { is_expected.to validate_length_of(:package_name_pattern).is_at_most(255) }
- [
- '@my-scope/my-package',
- '@my-scope/*my-package-with-wildcard-inbetween',
- '@my-scope/*my-package-with-wildcard-start',
- '@my-scope/my-*package-*with-wildcard-multiple-*',
- '@my-scope/my-package-with_____underscore',
- '@my-scope/my-package-with-regex-characters.+',
- '@my-scope/my-package-with-wildcard-end*'
- ].each do |package_name_pattern|
- it { is_expected.to allow_value(package_name_pattern).for(:package_name_pattern) }
+ where(:package_name_pattern, :allowed) do
+ '@my-scope/my-package' | true
+ '@my-scope/*my-package-with-wildcard-inbetween' | true
+ '@my-scope/*my-package-with-wildcard-start' | true
+ '@my-scope/my-*package-*with-wildcard-multiple-*' | true
+ '@my-scope/my-package-with_____underscore' | true
+ '@my-scope/my-package-with-regex-characters.+' | true
+ '@my-scope/my-package-with-wildcard-end*' | true
+
+ '@my-scope/my-package-with-percent-sign-%' | false
+ '*@my-scope/my-package-with-wildcard-start' | false
+ '@my-scope/my-package-with-backslash-\*' | false
end
- [
- '@my-scope/my-package-with-percent-sign-%',
- '*@my-scope/my-package-with-wildcard-start',
- '@my-scope/my-package-with-backslash-\*'
- ].each do |package_name_pattern|
- it {
- is_expected.not_to(
- allow_value(package_name_pattern)
- .for(:package_name_pattern)
- .with_message(_('should be a valid NPM package name with optional wildcard characters.'))
- )
- }
+ with_them do
+ if params[:allowed]
+ it { is_expected.to allow_value(package_name_pattern).for(:package_name_pattern) }
+ else
+ it {
+ is_expected.not_to(
+ allow_value(package_name_pattern)
+ .for(:package_name_pattern)
+ .with_message(_('should be a valid NPM package name with optional wildcard characters.'))
+ )
+ }
+ end
end
end