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
8bbd8172
Commit
8bbd8172
authored
Mar 13, 2019
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add transactional argument
parent
edaabaf4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
3 deletions
+21
-3
ee/app/services/group_saml/identity/destroy_service.rb
ee/app/services/group_saml/identity/destroy_service.rb
+6
-2
ee/lib/api/scim.rb
ee/lib/api/scim.rb
+3
-1
ee/spec/services/group_saml/identity/destroy_service_spec.rb
ee/spec/services/group_saml/identity/destroy_service_spec.rb
+12
-0
No files found.
ee/app/services/group_saml/identity/destroy_service.rb
View file @
8bbd8172
...
...
@@ -11,8 +11,8 @@ module GroupSaml
@identity
=
identity
end
def
execute
Identity
.
transaction
do
def
execute
(
transactional:
false
)
with_transaction
(
transactional
)
do
identity
.
destroy!
remove_group_access
end
...
...
@@ -20,6 +20,10 @@ module GroupSaml
private
def
with_transaction
(
transactional
,
&
block
)
transactional
?
::
Identity
.
transaction
{
yield
}
:
yield
end
def
remove_group_access
return
unless
group_membership
return
if
group
.
last_owner?
(
user
)
...
...
ee/lib/api/scim.rb
View file @
8bbd8172
...
...
@@ -17,7 +17,7 @@ module API
end
def
destroy_identity
(
identity
)
GroupSaml
::
Identity
::
DestroyService
.
new
(
identity
).
execute
GroupSaml
::
Identity
::
DestroyService
.
new
(
identity
).
execute
(
transactional:
true
)
true
rescue
=>
e
...
...
@@ -34,9 +34,11 @@ module API
error!
({
with:
EE
::
Gitlab
::
Scim
::
Error
}.
merge
(
detail:
message
),
409
)
end
# rubocop: disable CodeReuse/ActiveRecord
def
email_taken?
(
email
,
identity
)
User
.
by_any_email
(
email
.
downcase
).
where
.
not
(
id:
identity
.
user
.
id
).
count
>
0
end
# rubocop: enable CodeReuse/ActiveRecord
end
resource
:Users
do
...
...
ee/spec/services/group_saml/identity/destroy_service_spec.rb
View file @
8bbd8172
...
...
@@ -21,6 +21,18 @@ describe GroupSaml::Identity::DestroyService do
expect
(
identity
).
to
be_destroyed
end
it
"does not use a transaction"
do
expect
(
::
Identity
).
to
receive
(
:transaction
).
and_yield
.
once
subject
.
execute
end
it
"uses a transaction when transactional is set"
do
expect
(
::
Identity
).
to
receive
(
:transaction
).
and_yield
.
twice
subject
.
execute
(
transactional:
true
)
end
it
"removes access to the group"
do
expect
do
subject
.
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