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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
abf15a96
Commit
abf15a96
authored
Apr 25, 2016
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://dev.gitlab.org/gitlab/gitlabhq
parents
fffc8a86
41aa7a89
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
4 deletions
+17
-4
CHANGELOG
CHANGELOG
+3
-0
lib/api/project_hooks.rb
lib/api/project_hooks.rb
+2
-2
spec/requests/api/project_hooks_spec.rb
spec/requests/api/project_hooks_spec.rb
+12
-2
No files found.
CHANGELOG
View file @
abf15a96
...
...
@@ -7,6 +7,9 @@ v 8.7.1 (unreleased)
- Fix .gitlab-ci.yml parsing issue when hidde job is a template without script definition. !3849
- Fix license detection to detect all license files, not only known licenses. !3878
- Use the `can?` helper instead of `current_user.can?`. !3882
- Prevent users from deleting Webhooks via API they do not own
- Use the `can?` helper instead of `current_user.can?`
- Fix .gitlab-ci.yml parsing issue when hidde job is a template without script definition
v 8.7.0
- Gitlab::GitAccess and Gitlab::GitAccessWiki are now instrumented
...
...
lib/api/project_hooks.rb
View file @
abf15a96
...
...
@@ -103,10 +103,10 @@ module API
required_attributes!
[
:hook_id
]
begin
@hook
=
ProjectHook
.
find
(
params
[
:hook_id
])
@hook
.
destroy
@hook
=
user_project
.
hooks
.
destroy
(
params
[
:hook_id
])
rescue
# ProjectHook can raise Error if hook_id not found
not_found!
(
"Error deleting hook
#{
params
[
:hook_id
]
}
"
)
end
end
end
...
...
spec/requests/api/project_hooks_spec.rb
View file @
abf15a96
...
...
@@ -148,14 +148,24 @@ describe API::API, 'ProjectHooks', api: true do
expect
(
response
.
status
).
to
eq
(
200
)
end
it
"should return
success
when deleting non existent hook"
do
it
"should return
a 404 error
when deleting non existent hook"
do
delete
api
(
"/projects/
#{
project
.
id
}
/hooks/42"
,
user
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
404
)
end
it
"should return a 405 error if hook id not given"
do
delete
api
(
"/projects/
#{
project
.
id
}
/hooks"
,
user
)
expect
(
response
.
status
).
to
eq
(
405
)
end
it
"shold return a 404 if a user attempts to delete project hooks he/she does not own"
do
test_user
=
create
(
:user
)
other_project
=
create
(
:project
)
other_project
.
team
<<
[
test_user
,
:master
]
delete
api
(
"/projects/
#{
other_project
.
id
}
/hooks/
#{
hook
.
id
}
"
,
test_user
)
expect
(
response
.
status
).
to
eq
(
404
)
expect
(
WebHook
.
exists?
(
hook
.
id
)).
to
be_truthy
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