BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
0 deletions
+35
-0
environment.rb
lib/gitlab/ci/config/node/environment.rb
+5
-0
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