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
b56e4038
Commit
b56e4038
authored
Jul 17, 2018
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removes irrelevant unit tests for remote mirror and mirrors with the same URL
parent
a5accabe
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
28 deletions
+16
-28
ee/lib/ee/api/helpers.rb
ee/lib/ee/api/helpers.rb
+2
-1
ee/spec/controllers/projects/mirrors_controller_spec.rb
ee/spec/controllers/projects/mirrors_controller_spec.rb
+0
-23
ee/spec/controllers/projects_controller_spec.rb
ee/spec/controllers/projects_controller_spec.rb
+0
-2
ee/spec/services/projects/update_service_spec.rb
ee/spec/services/projects/update_service_spec.rb
+12
-0
lib/api/projects.rb
lib/api/projects.rb
+2
-2
No files found.
ee/lib/ee/api/helpers.rb
View file @
b56e4038
...
...
@@ -63,7 +63,8 @@ module EE
end
def
valid_mirror_user?
(
mirror_params
)
return
true
unless
mirror_params
[
:mirror_user_id
].
present?
return
true
unless
mirror_params
[
:mirror
]
return
false
unless
mirror_params
[
:mirror_user_id
].
present?
default_mirror_users
.
map
(
&
:id
).
include?
(
mirror_params
[
:mirror_user_id
].
to_i
)
end
...
...
ee/spec/controllers/projects/mirrors_controller_spec.rb
View file @
b56e4038
...
...
@@ -19,22 +19,6 @@ describe Projects::MirrorsController do
do_put
(
project
,
remote_mirrors_attributes:
{
'0'
=>
{
'enabled'
=>
1
,
'url'
=>
url
}
})
end
.
to
change
{
RemoteMirror
.
count
}.
to
(
1
)
end
context
'when remote mirror has the same URL'
do
it
'does not allow to create the remote mirror'
do
expect
do
do_put
(
project
,
remote_mirrors_attributes:
{
'0'
=>
{
'enabled'
=>
1
,
'url'
=>
project
.
import_url
}
})
end
.
not_to
change
{
RemoteMirror
.
count
}
end
context
'with disabled local mirror'
do
it
'allows to create a remote mirror'
do
expect
do
do_put
(
project
,
mirror:
0
,
remote_mirrors_attributes:
{
'0'
=>
{
'enabled'
=>
1
,
'url'
=>
project
.
import_url
}
})
end
.
to
change
{
RemoteMirror
.
count
}.
to
(
1
)
end
end
end
end
context
'when the current project has a remote mirror'
do
...
...
@@ -55,8 +39,6 @@ describe Projects::MirrorsController do
context
'when trying to create a mirror with a different URL'
do
it
'should setup the mirror'
do
expect_any_instance_of
(
EE
::
Project
).
to
receive
(
:force_import_job!
)
do_put
(
project
,
mirror:
true
,
mirror_user_id:
project
.
owner
.
id
,
import_url:
'http://local.dev'
)
expect
(
project
.
reload
.
mirror
).
to
eq
(
true
)
...
...
@@ -65,8 +47,6 @@ describe Projects::MirrorsController do
context
'mirror user is not the current user'
do
it
'should only assign the current user'
do
expect_any_instance_of
(
EE
::
Project
).
to
receive
(
:force_import_job!
)
new_user
=
create
(
:user
)
project
.
add_maintainer
(
new_user
)
...
...
@@ -94,7 +74,6 @@ describe Projects::MirrorsController do
it
'creates a new mirror'
do
sign_in
(
admin
)
expect_any_instance_of
(
EE
::
Project
).
to
receive
(
:force_import_job!
)
expect
do
do_put
(
project
,
mirror:
true
,
mirror_user_id:
admin
.
id
,
import_url:
url
)
...
...
@@ -120,8 +99,6 @@ describe Projects::MirrorsController do
context
'when project does not have a mirror'
do
it
'allows to create a mirror'
do
expect_any_instance_of
(
EE
::
Project
).
to
receive
(
:force_import_job!
)
expect
do
do_put
(
project
,
mirror:
true
,
mirror_user_id:
project
.
owner
.
id
,
import_url:
url
)
end
.
to
change
{
Project
.
mirror
.
count
}.
to
(
1
)
...
...
ee/spec/controllers/projects_controller_spec.rb
View file @
b56e4038
...
...
@@ -144,8 +144,6 @@ describe ProjectsController do
end
it
'updates repository mirror attributes'
do
expect_any_instance_of
(
EE
::
Project
).
to
receive
(
:force_import_job!
)
put
:update
,
namespace_id:
project
.
namespace
,
id:
project
,
...
...
ee/spec/services/projects/update_service_spec.rb
View file @
b56e4038
...
...
@@ -31,6 +31,12 @@ describe Projects::UpdateService, '#execute' do
expect
(
updated_project
.
mirror_user_id
).
to
eq
(
user
.
id
)
expect
(
updated_project
.
mirror_trigger_builds
).
to
be
true
end
it
'forces an import job'
do
expect
(
project
).
to
receive
(
:force_import_job!
).
once
update_project
(
project
,
user
,
opts
)
end
end
context
'when unlicensed'
do
...
...
@@ -47,6 +53,12 @@ describe Projects::UpdateService, '#execute' do
expect
(
updated_project
.
mirror_user_id
).
to
be_nil
expect
(
updated_project
.
mirror_trigger_builds
).
to
be
false
end
it
'does not force an import job'
do
expect
(
project
).
not_to
receive
(
:force_import_job!
)
update_project
(
project
,
user
,
opts
)
end
end
end
...
...
lib/api/projects.rb
View file @
b56e4038
...
...
@@ -140,7 +140,7 @@ module API
post
do
attrs
=
declared_params
(
include_missing:
false
)
attrs
=
translate_params_for_compatibility
(
attrs
)
attrs
[
:mirror_user_id
]
=
current_user
.
id
if
attrs
[
:
import_url
].
present?
attrs
[
:mirror_user_id
]
=
current_user
.
id
if
attrs
[
:
mirror
]
project
=
::
Projects
::
CreateService
.
new
(
current_user
,
attrs
).
execute
...
...
@@ -174,7 +174,7 @@ module API
attrs
=
declared_params
(
include_missing:
false
)
attrs
=
translate_params_for_compatibility
(
attrs
)
attrs
[
:mirror_user_id
]
=
user
.
id
if
attrs
[
:
import_url
].
present?
attrs
[
:mirror_user_id
]
=
user
.
id
if
attrs
[
:
mirror
]
project
=
::
Projects
::
CreateService
.
new
(
user
,
attrs
).
execute
...
...
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