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
2ff68bfc
Commit
2ff68bfc
authored
Nov 03, 2014
by
Marin Jankovski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create project git hook spec.
parent
6c0ae72c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
141 additions
and
0 deletions
+141
-0
spec/requests/api/project_git_hook_spec.rb
spec/requests/api/project_git_hook_spec.rb
+141
-0
No files found.
spec/requests/api/project_git_hook_spec.rb
0 → 100644
View file @
2ff68bfc
require
'spec_helper'
describe
API
::
API
,
'ProjectGitHook'
,
api:
true
do
include
ApiHelpers
let
(
:user
)
{
create
(
:user
)
}
let
(
:user3
)
{
create
(
:user
)
}
let!
(
:project
)
{
create
(
:project
,
creator_id:
user
.
id
,
namespace:
user
.
namespace
)
}
before
do
project
.
team
<<
[
user
,
:master
]
project
.
team
<<
[
user3
,
:developer
]
end
describe
"GET /projects/:id/git_hook"
do
before
do
create
(
:git_hook
,
project:
project
)
end
context
"authorized user"
do
it
"should return project git hook"
do
get
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user
)
response
.
status
.
should
eq
(
200
)
json_response
.
should
be_an
Hash
json_response
[
'project_id'
].
should
eq
(
project
.
id
)
end
end
context
"unauthorized user"
do
it
"should not access project git hooks"
do
get
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user3
)
response
.
status
.
should
eq
(
403
)
end
end
end
describe
"POST /projects/:id/git_hook"
do
context
"authorized user"
do
it
"should add git hook to project"
do
post
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user
),
deny_delete_tag:
true
response
.
status
.
should
eq
(
201
)
json_response
.
should
be_an
Hash
json_response
[
'project_id'
].
should
eq
(
project
.
id
)
json_response
[
'deny_delete_tag'
].
should
eq
(
true
)
end
end
context
"unauthorized user"
do
it
"should not add git hook to project"
do
post
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user3
),
deny_delete_tag:
true
response
.
status
.
should
eq
(
403
)
end
end
end
describe
"POST /projects/:id/git_hook"
do
before
do
create
(
:git_hook
,
project:
project
)
end
context
"with existing git hook"
do
it
"should not add git hook to project"
do
post
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user
),
deny_delete_tag:
true
response
.
status
.
should
eq
(
422
)
end
end
end
describe
"PUT /projects/:id/git_hook"
do
before
do
create
(
:git_hook
,
project:
project
)
end
it
"should update an existing project git hook"
do
put
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user
),
deny_delete_tag:
false
,
commit_message_regex:
'Fixes \d+\..*'
response
.
status
.
should
eq
(
200
)
json_response
[
'deny_delete_tag'
].
should
eq
(
false
)
json_response
[
'commit_message_regex'
].
should
eq
(
'Fixes \d+\..*'
)
end
end
describe
"PUT /projects/:id/git_hook"
do
it
"should error on non existing project git hook"
do
put
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user
),
deny_delete_tag:
false
,
commit_message_regex:
'Fixes \d+\..*'
response
.
status
.
should
eq
(
404
)
end
it
"should not update git hook for unauthorized user"
do
post
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user3
),
deny_delete_tag:
true
response
.
status
.
should
eq
(
403
)
end
end
describe
"DELETE /projects/:id/git_hook"
do
before
do
create
(
:git_hook
,
project:
project
)
end
context
"authorized user"
do
it
"should delete git hook from project"
do
delete
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user
)
response
.
status
.
should
eq
(
200
)
json_response
.
should
be_an
Hash
end
end
context
"unauthorized user"
do
it
"should return a 403 error"
do
delete
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user3
)
response
.
status
.
should
eq
(
403
)
end
end
end
describe
"DELETE /projects/:id/git_hook"
do
context
"for non existing git hook"
do
it
"should delete git hook from project"
do
delete
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user
)
response
.
status
.
should
eq
(
404
)
json_response
.
should
be_an
Hash
json_response
[
'message'
].
should
eq
(
"404 Not Found"
)
end
it
"should return a 403 error if not authorized"
do
delete
api
(
"/projects/
#{
project
.
id
}
/git_hook"
,
user3
)
response
.
status
.
should
eq
(
403
)
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