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
c7daa5f1
Commit
c7daa5f1
authored
Jul 17, 2015
by
Marin Jankovski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for gitlab ci service validity.
parent
302c5255
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
0 deletions
+39
-0
spec/models/project_services/gitlab_ci_service_spec.rb
spec/models/project_services/gitlab_ci_service_spec.rb
+27
-0
spec/requests/api/services_spec.rb
spec/requests/api/services_spec.rb
+12
-0
No files found.
spec/models/project_services/gitlab_ci_service_spec.rb
View file @
c7daa5f1
...
...
@@ -26,6 +26,33 @@ describe GitlabCiService do
it
{
is_expected
.
to
have_one
(
:service_hook
)
}
end
describe
'validations'
do
context
'active'
do
before
{
allow
(
subject
).
to
receive
(
:activated?
).
and_return
(
true
)
}
it
{
is_expected
.
to
validate_presence_of
(
:token
)
}
it
{
is_expected
.
to
validate_presence_of
(
:project_url
)
}
it
{
is_expected
.
to
allow_value
(
'ewf9843kdnfdfs89234n'
).
for
(
:token
)
}
it
{
is_expected
.
to
allow_value
(
'http://ci.example.com/project/1'
).
for
(
:project_url
)
}
it
{
is_expected
.
not_to
allow_value
(
'token with spaces'
).
for
(
:token
)
}
it
{
is_expected
.
not_to
allow_value
(
'token/with%spaces'
).
for
(
:token
)
}
it
{
is_expected
.
not_to
allow_value
(
'this is not url'
).
for
(
:project_url
)
}
it
{
is_expected
.
not_to
allow_value
(
'http//noturl'
).
for
(
:project_url
)
}
it
{
is_expected
.
not_to
allow_value
(
'ftp://ci.example.com/projects/3'
).
for
(
:project_url
)
}
end
context
'inactive'
do
before
{
allow
(
subject
).
to
receive
(
:activated?
).
and_return
(
false
)
}
it
{
is_expected
.
not_to
validate_presence_of
(
:token
)
}
it
{
is_expected
.
not_to
validate_presence_of
(
:project_url
)
}
it
{
is_expected
.
to
allow_value
(
'ewf9843kdnfdfs89234n'
).
for
(
:token
)
}
it
{
is_expected
.
to
allow_value
(
'http://ci.example.com/project/1'
).
for
(
:project_url
)
}
it
{
is_expected
.
to
allow_value
(
'token with spaces'
).
for
(
:token
)
}
it
{
is_expected
.
to
allow_value
(
'ftp://ci.example.com/projects/3'
).
for
(
:project_url
)
}
end
end
describe
'commits methods'
do
before
do
@service
=
GitlabCiService
.
new
...
...
spec/requests/api/services_spec.rb
View file @
c7daa5f1
...
...
@@ -17,6 +17,18 @@ describe API::API, api: true do
expect
(
response
.
status
).
to
eq
(
400
)
end
it
"should return if the format of token is invalid"
do
put
api
(
"/projects/
#{
project
.
id
}
/services/gitlab-ci"
,
user
),
token:
'token-with dashes and spaces%'
,
project_url:
"http://ci.example.com/projects/1"
,
active:
true
expect
(
response
.
status
).
to
eq
(
404
)
end
it
"should return if the format of token is invalid"
do
put
api
(
"/projects/
#{
project
.
id
}
/services/gitlab-ci"
,
user
),
token:
'token-with dashes and spaces%'
,
project_url:
"ftp://ci.example/projects/1"
,
active:
true
expect
(
response
.
status
).
to
eq
(
404
)
end
end
describe
"DELETE /projects/:id/services/gitlab-ci"
do
...
...
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