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
11092340
Commit
11092340
authored
Oct 14, 2020
by
Małgorzata Ksionek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add methods to transfer service
parent
e1f09138
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
1 deletion
+55
-1
app/services/groups/transfer_service.rb
app/services/groups/transfer_service.rb
+21
-0
app/services/groups/update_service.rb
app/services/groups/update_service.rb
+1
-1
spec/services/groups/transfer_service_spec.rb
spec/services/groups/transfer_service_spec.rb
+33
-0
No files found.
app/services/groups/transfer_service.rb
View file @
11092340
...
...
@@ -38,6 +38,7 @@ module Groups
# Overridden in EE
def
post_update_hooks
(
updated_project_ids
)
refresh_project_authorizations
refresh_descendant_groups
if
@new_parent_group
end
def
ensure_allowed_transfer
...
...
@@ -101,6 +102,8 @@ module Groups
@group
.
visibility_level
=
@new_parent_group
.
visibility_level
end
update_two_factor_authentication
if
@new_parent_group
@group
.
parent
=
@new_parent_group
@group
.
clear_memoization
(
:self_and_ancestors_ids
)
...
...
@@ -129,8 +132,26 @@ module Groups
projects_to_update
.
update_all
(
visibility_level:
@new_parent_group
.
visibility_level
)
end
def
update_two_factor_authentication
return
if
namespace_parent_allows_two_factor_auth
@group
.
require_two_factor_authentication
=
false
end
def
refresh_descendant_groups
return
if
namespace_parent_allows_two_factor_auth
if
@group
.
descendants
.
where
(
require_two_factor_authentication:
true
).
any?
DisallowTwoFactorForSubgroupsWorker
.
perform_async
(
@group
.
id
)
end
end
# rubocop: enable CodeReuse/ActiveRecord
def
namespace_parent_allows_two_factor_auth
@new_parent_group
.
namespace_settings
.
allow_mfa_for_subgroups
end
def
ensure_ownership
return
if
@new_parent_group
return
unless
@group
.
owners
.
empty?
...
...
app/services/groups/update_service.rb
View file @
11092340
...
...
@@ -101,7 +101,7 @@ module Groups
settings
=
group
.
namespace_settings
return
if
settings
.
allow_mfa_for_subgroups
binding
.
pry
if
settings
.
previous_changes
.
include?
(
:allow_mfa_for_subgroups
)
# enque in batches members update
DisallowTwoFactorForSubgroupsWorker
.
perform_async
(
group
.
id
)
...
...
spec/services/groups/transfer_service_spec.rb
View file @
11092340
...
...
@@ -567,6 +567,39 @@ RSpec.describe Groups::TransferService do
end
end
context
'when transferring a group with two factor authentication switched on'
do
before
do
TestEnv
.
clean_test_path
create
(
:group_member
,
:owner
,
group:
new_parent_group
,
user:
user
)
create
(
:group
,
:private
,
parent:
group
,
require_two_factor_authentication:
true
)
group
.
update!
(
require_two_factor_authentication:
true
)
end
it
'does not update group two factor authentication setting'
do
transfer_service
.
execute
(
new_parent_group
)
expect
(
group
.
require_two_factor_authentication
).
to
eq
(
true
)
end
context
'when new parent disallows two factor authentication switched on for descendants'
do
before
do
new_parent_group
.
namespace_settings
.
update!
(
allow_mfa_for_subgroups:
false
)
end
it
'updates group two factor authentication setting'
do
transfer_service
.
execute
(
new_parent_group
)
expect
(
group
.
require_two_factor_authentication
).
to
eq
(
false
)
end
it
'schedules update of group two factor authentication setting for descendants'
do
expect
(
DisallowTwoFactorForSubgroupsWorker
).
to
receive
(
:perform_async
).
with
(
group
.
id
)
transfer_service
.
execute
(
new_parent_group
)
end
end
end
context
'when updating the group goes wrong'
do
let!
(
:subgroup1
)
{
create
(
:group
,
:public
,
parent:
group
)
}
let!
(
:subgroup2
)
{
create
(
:group
,
:public
,
parent:
group
)
}
...
...
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