Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
45808ab7
Commit
45808ab7
authored
Jun 22, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adopt changes from moving environment_scope in CE
parent
443f1031
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
16 deletions
+14
-16
app/models/ci/variable.rb
app/models/ci/variable.rb
+1
-5
app/models/ee/ci/variable.rb
app/models/ee/ci/variable.rb
+0
-6
spec/models/ci/variable_spec.rb
spec/models/ci/variable_spec.rb
+13
-5
No files found.
app/models/ci/variable.rb
View file @
45808ab7
...
...
@@ -3,15 +3,11 @@ module Ci
extend
Ci
::
Model
prepend
EE
::
Ci
::
Variable
def
self
.
key_uniqueness_scope
:project_id
end
belongs_to
:project
validates
:key
,
presence:
true
,
uniqueness:
{
scope:
key_uniqueness_scope
},
uniqueness:
{
scope:
[
:project_id
,
:environment_scope
]
},
length:
{
maximum:
255
},
format:
{
with:
/\A[a-zA-Z0-9_]+\z/
,
message:
"can contain only letters, digits and '_'."
}
...
...
app/models/ee/ci/variable.rb
View file @
45808ab7
...
...
@@ -3,12 +3,6 @@ module EE
module
Variable
extend
ActiveSupport
::
Concern
module
ClassMethods
def
key_uniqueness_scope
%i[project_id environment_scope]
end
end
prepended
do
validates
(
:environment_scope
,
...
...
spec/models/ci/variable_spec.rb
View file @
45808ab7
...
...
@@ -5,11 +5,19 @@ describe Ci::Variable, models: true do
let
(
:secret_value
)
{
'secret'
}
describe
'validations'
do
# EE
before
do
stub_feature
(
:variable_environment_scope
)
end
it
{
is_expected
.
to
validate_presence_of
(
:key
)
}
it
{
is_expected
.
to
validate_uniqueness_of
(
:key
).
scoped_to
(
:project_id
,
:environment_scope
)
}
it
{
is_expected
.
to
validate_length_of
(
:key
).
is_at_most
(
255
)
}
it
{
is_expected
.
to
allow_value
(
'foo'
).
for
(
:key
)
}
it
{
is_expected
.
not_to
allow_value
(
'foo bar'
).
for
(
:key
)
}
it
{
is_expected
.
not_to
allow_value
(
'foo/bar'
).
for
(
:key
)
}
end
describe
'.unprotected'
do
subject
{
described_class
.
unprotected
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment