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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
08272ec1
Commit
08272ec1
authored
Sep 14, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add validation of URL and validation of name
parent
ba5bd3d1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
0 deletions
+35
-0
lib/gitlab/ci/config/node/environment.rb
lib/gitlab/ci/config/node/environment.rb
+5
-0
spec/lib/gitlab/ci/config/node/environment_spec.rb
spec/lib/gitlab/ci/config/node/environment_spec.rb
+30
-0
No files found.
lib/gitlab/ci/config/node/environment.rb
View file @
08272ec1
...
...
@@ -11,6 +11,11 @@ module Gitlab
validations
do
validates
:name
,
presence:
true
validates
:url
,
length:
{
maximum:
255
},
allow_nil:
true
,
addressable_url:
true
validate
do
unless
hash
?
||
string?
errors
.
add
(:
config
,
'should be a hash or a string'
)
...
...
spec/lib/gitlab/ci/config/node/environment_spec.rb
View file @
08272ec1
...
...
@@ -87,6 +87,19 @@ describe Gitlab::Ci::Config::Node::Environment do
end
end
context
'when variables are used for environment'
do
let
(
:config
)
do
{
name:
'review/$CI_BUILD_REF_NAME'
,
url:
'https://$CI_BUILD_REF_NAME.review.gitlab.com'
}
end
describe
'#valid?'
do
it
'is valid'
do
expect
(
entry
).
to
be_valid
end
end
end
context
'when configuration is invalid'
do
context
'when configuration is an array'
do
let
(
:config
)
{
[
'env'
]
}
...
...
@@ -121,5 +134,22 @@ describe Gitlab::Ci::Config::Node::Environment do
end
end
end
context
'when invalid URL is used'
do
let
(
:config
)
{
{
name:
'test'
,
url:
'invalid-example.gitlab.com'
}
}
describe
'#valid?'
do
it
'is not valid'
do
expect
(
entry
).
not_to
be_valid
end
end
describe
'#errors?'
do
it
'contains error about invalid URL'
do
expect
(
entry
.
errors
)
.
to
include
"environment url must be a valid url"
end
end
end
end
end
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