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
659d55a1
Commit
659d55a1
authored
Feb 25, 2020
by
Rajendra Kadam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add optional parameter and specs for post call
parent
fcc86c15
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
1 deletion
+34
-1
lib/api/remote_mirrors.rb
lib/api/remote_mirrors.rb
+2
-1
spec/requests/api/remote_mirrors_spec.rb
spec/requests/api/remote_mirrors_spec.rb
+32
-0
No files found.
lib/api/remote_mirrors.rb
View file @
659d55a1
...
...
@@ -30,7 +30,8 @@ module API
success
Entities
::
RemoteMirror
end
params
do
requries
:url
,
type:
String
,
desc:
'The URL for a remote mirror'
requires
:url
,
type:
String
,
desc:
'The URL for a remote mirror'
optional
:only_protected_branches
,
type:
Boolean
,
desc:
'Determines if only protected branches are mirrored'
end
post
':id/remote_mirrors'
do
create_params
=
declared_params
(
include_missing:
false
)
...
...
spec/requests/api/remote_mirrors_spec.rb
View file @
659d55a1
...
...
@@ -39,6 +39,38 @@ describe API::RemoteMirrors do
end
end
describe
'POST /projects/:id/remote_mirrors'
do
let
(
:route
)
{
"/projects/
#{
project
.
id
}
/remote_mirrors"
}
it
'requires `admin_remote_mirror` permission'
do
post
api
(
route
,
developer
)
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
it
'creates a remote mirror'
do
project
.
add_maintainer
(
user
)
post
api
(
route
,
user
),
params:
{
url:
'https://foo:bar@test.com'
}
expect
(
response
).
to
have_gitlab_http_status
(
:success
)
expect
(
response
).
to
match_response_schema
(
'remote_mirror'
)
end
it
'returns error if url is invalid'
do
project
.
add_maintainer
(
user
)
post
api
(
route
,
user
),
params:
{
url:
'ftp://foo:bar@test.com'
}
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
json_response
[
'message'
][
'url'
]).
to
eq
([
"is blocked: Only allowed schemes are ssh, git, http, https"
])
end
end
describe
'PUT /projects/:id/remote_mirrors/:mirror_id'
do
let
(
:route
)
{
->
(
id
)
{
"/projects/
#{
project
.
id
}
/remote_mirrors/
#{
id
}
"
}
}
let
(
:mirror
)
{
project
.
remote_mirrors
.
first
}
...
...
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