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
e4445e69
Commit
e4445e69
authored
Nov 24, 2020
by
Arturo Herrero
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce database queries in transfer_service_spec
parent
5b1c5673
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
22 deletions
+20
-22
spec/services/groups/transfer_service_spec.rb
spec/services/groups/transfer_service_spec.rb
+20
-22
No files found.
spec/services/groups/transfer_service_spec.rb
View file @
e4445e69
...
...
@@ -3,15 +3,15 @@
require
'spec_helper'
RSpec
.
describe
Groups
::
TransferService
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:new_parent_group
)
{
create
(
:group
,
:public
)
}
let
_it_be
(
:user
)
{
create
(
:user
)
}
let
_it_be
(
:new_parent_group
)
{
create
(
:group
,
:public
)
}
let!
(
:group_member
)
{
create
(
:group_member
,
:owner
,
group:
group
,
user:
user
)
}
let
(
:transfer_service
)
{
described_class
.
new
(
group
,
user
)
}
context
'handling packages'
do
let_it_be
(
:group
)
{
create
(
:group
,
:public
)
}
let_it_be
(
:new_group
)
{
create
(
:group
,
:public
)
}
let
(
:project
)
{
create
(
:project
,
:public
,
namespace:
group
)
}
let
(
:new_group
)
{
create
(
:group
,
:public
)
}
before
do
group
.
add_owner
(
user
)
...
...
@@ -35,8 +35,8 @@ RSpec.describe Groups::TransferService do
it_behaves_like
'transfer not allowed'
context
'with a project within subgroup'
do
let
(
:root_group
)
{
create
(
:group
)
}
let
(
:group
)
{
create
(
:group
,
parent:
root_group
)
}
let
_it_be
(
:root_group
)
{
create
(
:group
)
}
let
_it_be
(
:group
)
{
create
(
:group
,
parent:
root_group
)
}
before
do
root_group
.
add_owner
(
user
)
...
...
@@ -79,8 +79,6 @@ RSpec.describe Groups::TransferService do
shared_examples
'ensuring allowed transfer for a group'
do
context
"when there's an exception on GitLab shell directories"
do
let
(
:new_parent_group
)
{
create
(
:group
,
:public
)
}
before
do
allow_next_instance_of
(
described_class
)
do
|
instance
|
allow
(
instance
).
to
receive
(
:update_group_attributes
).
and_raise
(
Gitlab
::
UpdatePathError
,
'namespace directory cannot be moved'
)
...
...
@@ -101,7 +99,7 @@ RSpec.describe Groups::TransferService do
describe
'#execute'
do
context
'when transforming a group into a root group'
do
let
!
(
:group
)
{
create
(
:group
,
:public
,
:nested
)
}
let
_it_be_with_reload
(
:group
)
{
create
(
:group
,
:public
,
:nested
)
}
it_behaves_like
'ensuring allowed transfer for a group'
...
...
@@ -115,7 +113,7 @@ RSpec.describe Groups::TransferService do
end
context
'when the user does not have the right policies'
do
let
!
(
:group_member
)
{
create
(
:group_member
,
:guest
,
group:
group
,
user:
user
)
}
let
_it_be
(
:group_member
)
{
create
(
:group_member
,
:guest
,
group:
group
,
user:
user
)
}
it
"returns false"
do
expect
(
transfer_service
.
execute
(
nil
)).
to
be_falsy
...
...
@@ -128,7 +126,7 @@ RSpec.describe Groups::TransferService do
end
context
'when there is a group with the same path'
do
let
!
(
:group
)
{
create
(
:group
,
:public
,
:nested
,
path:
'not-unique'
)
}
let
_it_be
(
:group
)
{
create
(
:group
,
:public
,
:nested
,
path:
'not-unique'
)
}
before
do
create
(
:group
,
path:
'not-unique'
)
...
...
@@ -145,9 +143,9 @@ RSpec.describe Groups::TransferService do
end
context
'when the group is a subgroup and the transfer is valid'
do
let
!
(
:subgroup1
)
{
create
(
:group
,
:private
,
parent:
group
)
}
let
!
(
:subgroup2
)
{
create
(
:group
,
:internal
,
parent:
group
)
}
let
!
(
:project1
)
{
create
(
:project
,
:repository
,
:private
,
namespace:
group
)
}
let
_it_be
(
:subgroup1
)
{
create
(
:group
,
:private
,
parent:
group
)
}
let
_it_be
(
:subgroup2
)
{
create
(
:group
,
:internal
,
parent:
group
)
}
let
_it_be
(
:project1
)
{
create
(
:project
,
:repository
,
:private
,
namespace:
group
)
}
before
do
transfer_service
.
execute
(
nil
)
...
...
@@ -173,12 +171,12 @@ RSpec.describe Groups::TransferService do
end
context
'when transferring a subgroup into another group'
do
let
(
:group
)
{
create
(
:group
,
:public
,
:nested
)
}
let
_it_be_with_reload
(
:group
)
{
create
(
:group
,
:public
,
:nested
)
}
it_behaves_like
'ensuring allowed transfer for a group'
context
'when the new parent group is the same as the previous parent group'
do
let
(
:group
)
{
create
(
:group
,
:public
,
:nested
,
parent:
new_parent_group
)
}
let
_it_be
(
:group
)
{
create
(
:group
,
:public
,
:nested
,
parent:
new_parent_group
)
}
it
'returns false'
do
expect
(
transfer_service
.
execute
(
new_parent_group
)).
to
be_falsy
...
...
@@ -191,7 +189,7 @@ RSpec.describe Groups::TransferService do
end
context
'when the user does not have the right policies'
do
let
!
(
:group_member
)
{
create
(
:group_member
,
:guest
,
group:
group
,
user:
user
)
}
let
_it_be
(
:group_member
)
{
create
(
:group_member
,
:guest
,
group:
group
,
user:
user
)
}
it
"returns false"
do
expect
(
transfer_service
.
execute
(
new_parent_group
)).
to
be_falsy
...
...
@@ -221,7 +219,7 @@ RSpec.describe Groups::TransferService do
end
context
'when the parent group has a project with the same path'
do
let
!
(
:group
)
{
create
(
:group
,
:public
,
:nested
,
path:
'foo'
)
}
let
_it_be_with_reload
(
:group
)
{
create
(
:group
,
:public
,
:nested
,
path:
'foo'
)
}
before
do
create
(
:group_member
,
:owner
,
group:
new_parent_group
,
user:
user
)
...
...
@@ -464,7 +462,7 @@ RSpec.describe Groups::TransferService do
end
context
'updated paths'
do
let
(
:group
)
{
create
(
:group
,
:public
)
}
let
_it_be_with_reload
(
:group
)
{
create
(
:group
,
:public
)
}
before
do
transfer_service
.
execute
(
new_parent_group
)
...
...
@@ -500,10 +498,10 @@ RSpec.describe Groups::TransferService do
end
context
'resets project authorizations'
do
let
(
:old_parent_group
)
{
create
(
:group
)
}
let
(
:group
)
{
create
(
:group
,
:private
,
parent:
old_parent_group
)
}
let
(
:new_group_member
)
{
create
(
:user
)
}
let
(
:old_group_member
)
{
create
(
:user
)
}
let
_it_be
(
:old_parent_group
)
{
create
(
:group
)
}
let
_it_be_with_reload
(
:group
)
{
create
(
:group
,
:private
,
parent:
old_parent_group
)
}
let
_it_be
(
:new_group_member
)
{
create
(
:user
)
}
let
_it_be
(
:old_group_member
)
{
create
(
:user
)
}
before
do
new_parent_group
.
add_maintainer
(
new_group_member
)
...
...
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