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
98f8fe95
Commit
98f8fe95
authored
Feb 28, 2020
by
Rajendra Kadam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add optional enabled parameter and refactor and improve specs
parent
8961d279
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
7 deletions
+24
-7
lib/api/remote_mirrors.rb
lib/api/remote_mirrors.rb
+1
-0
spec/requests/api/remote_mirrors_spec.rb
spec/requests/api/remote_mirrors_spec.rb
+23
-7
No files found.
lib/api/remote_mirrors.rb
View file @
98f8fe95
...
...
@@ -31,6 +31,7 @@ module API
end
params
do
requires
:url
,
type:
String
,
desc:
'The URL for a remote mirror'
optional
:enabled
,
type:
Boolean
,
desc:
'Determines if the mirror is enabled'
optional
:only_protected_branches
,
type:
Boolean
,
desc:
'Determines if only protected branches are mirrored'
end
post
':id/remote_mirrors'
do
...
...
spec/requests/api/remote_mirrors_spec.rb
View file @
98f8fe95
...
...
@@ -42,21 +42,37 @@ describe API::RemoteMirrors do
describe
'POST /projects/:id/remote_mirrors'
do
let
(
:route
)
{
"/projects/
#{
project
.
id
}
/remote_mirrors"
}
shared_examples
'creates a remote mirror'
do
it
'creates a remote mirror and returns reponse'
do
project
.
add_maintainer
(
user
)
post
api
(
route
,
user
),
params:
params
enabled
=
params
.
fetch
(
:enabled
,
false
)
expect
(
response
).
to
have_gitlab_http_status
(
:success
)
expect
(
response
).
to
match_response_schema
(
'remote_mirror'
)
expect
(
json_response
[
'enabled'
]).
to
eq
(
enabled
)
end
end
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
)
context
'creates a remote mirror'
do
context
'disabled by default'
do
let
(
:params
)
{
{
url:
'https://foo:bar@test.com'
}
}
post
api
(
route
,
user
),
params:
{
url:
'https://foo:bar@test.com'
}
it_behaves_like
'creates a remote mirror'
end
expect
(
response
).
to
have_gitlab_http_status
(
:success
)
expect
(
response
).
to
match_response_schema
(
'remote_mirror'
)
context
'enabled'
do
let
(
:params
)
{
{
url:
'https://foo:bar@test.com'
,
enabled:
true
}
}
it_behaves_like
'creates a remote mirror'
end
end
it
'returns error if url is invalid'
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