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
bf78685a
Commit
bf78685a
authored
Mar 02, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix ProjectPushRules API
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
4053ce9e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
78 additions
and
2 deletions
+78
-2
lib/api/api.rb
lib/api/api.rb
+1
-0
lib/api/v3/project_push_rule.rb
lib/api/v3/project_push_rule.rb
+22
-0
spec/requests/api/project_push_rule_spec.rb
spec/requests/api/project_push_rule_spec.rb
+1
-2
spec/requests/api/v3/project_push_rule_spec.rb
spec/requests/api/v3/project_push_rule_spec.rb
+54
-0
No files found.
lib/api/api.rb
View file @
bf78685a
...
...
@@ -22,6 +22,7 @@ module API
mount
::
API
::
V3
::
Notes
mount
::
API
::
V3
::
ProjectGitHook
mount
::
API
::
V3
::
ProjectHooks
mount
::
API
::
V3
::
ProjectPushRule
mount
::
API
::
V3
::
Projects
mount
::
API
::
V3
::
ProjectSnippets
mount
::
API
::
V3
::
Repositories
...
...
lib/api/v3/project_push_rule.rb
0 → 100644
View file @
bf78685a
module
API
module
V3
class
ProjectPushRule
<
Grape
::
API
before
{
authenticate!
}
before
{
authorize_admin_project
}
params
do
requires
:id
,
type:
String
,
desc:
'The ID of a project'
end
resource
:projects
do
desc
'Deletes project push rule'
delete
":id/push_rule"
do
push_rule
=
user_project
.
push_rule
not_found!
(
'Push Rule'
)
unless
push_rule
status
(
200
)
push_rule
.
destroy
end
end
end
end
end
spec/requests/api/project_push_rule_spec.rb
View file @
bf78685a
...
...
@@ -131,8 +131,7 @@ describe API::ProjectPushRule, 'ProjectPushRule', api: true do
it
"deletes push rule from project"
do
delete
api
(
"/projects/
#{
project
.
id
}
/push_rule"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Hash
expect
(
response
).
to
have_http_status
(
204
)
end
end
...
...
spec/requests/api/v3/project_push_rule_spec.rb
0 → 100644
View file @
bf78685a
require
'spec_helper'
describe
API
::
V3
::
ProjectPushRule
,
'ProjectPushRule'
,
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
"DELETE /projects/:id/push_rule"
do
before
do
create
(
:push_rule
,
project:
project
)
end
context
"authorized user"
do
it
"deletes push rule from project"
do
delete
v3_api
(
"/projects/
#{
project
.
id
}
/push_rule"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Hash
end
end
context
"unauthorized user"
do
it
"returns a 403 error"
do
delete
v3_api
(
"/projects/
#{
project
.
id
}
/push_rule"
,
user3
)
expect
(
response
).
to
have_http_status
(
403
)
end
end
end
describe
"DELETE /projects/:id/push_rule"
do
context
"for non existing push rule"
do
it
"deletes push rule from project"
do
delete
v3_api
(
"/projects/
#{
project
.
id
}
/push_rule"
,
user
)
expect
(
response
).
to
have_http_status
(
404
)
expect
(
json_response
).
to
be_an
Hash
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Push Rule Not Found'
)
end
it
"returns a 403 error if not authorized"
do
delete
v3_api
(
"/projects/
#{
project
.
id
}
/push_rule"
,
user3
)
expect
(
response
).
to
have_http_status
(
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