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
b1b727d2
Commit
b1b727d2
authored
Dec 28, 2020
by
Alex Buijs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for onboarding user added worker
when adding a member to a project, now correctly pass the namespace_id
parent
a5fb595d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
19 deletions
+29
-19
app/services/members/create_service.rb
app/services/members/create_service.rb
+2
-1
spec/services/members/create_service_spec.rb
spec/services/members/create_service_spec.rb
+27
-18
No files found.
app/services/members/create_service.rb
View file @
b1b727d2
...
...
@@ -54,7 +54,8 @@ module Members
end
def
enqueue_onboarding_progress_action
(
source
)
Namespaces
::
OnboardingUserAddedWorker
.
perform_async
(
source
.
id
)
namespace_id
=
source
.
is_a?
(
Project
)
?
source
.
namespace_id
:
source
.
id
Namespaces
::
OnboardingUserAddedWorker
.
perform_async
(
namespace_id
)
end
end
end
...
...
spec/services/members/create_service_spec.rb
View file @
b1b727d2
...
...
@@ -2,26 +2,35 @@
require
'spec_helper'
RSpec
.
describe
Members
::
CreateService
do
let_it_be
(
:
project
)
{
create
(
:project
)
}
RSpec
.
describe
Members
::
CreateService
,
:clean_gitlab_redis_shared_state
,
:sidekiq_inline
do
let_it_be
(
:
source
)
{
create
(
:project
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:
project_us
er
)
{
create
(
:user
)
}
let_it_be
(
:user_ids
)
{
project_us
er
.
id
.
to_s
}
let_it_be
(
:
memb
er
)
{
create
(
:user
)
}
let_it_be
(
:user_ids
)
{
memb
er
.
id
.
to_s
}
let_it_be
(
:access_level
)
{
Gitlab
::
Access
::
GUEST
}
let
(
:params
)
{
{
user_ids:
user_ids
,
access_level:
access_level
}
}
subject
(
:execute_service
)
{
described_class
.
new
(
user
,
params
).
execute
(
project
)
}
subject
(
:execute_service
)
{
described_class
.
new
(
user
,
params
).
execute
(
source
)
}
before
do
project
.
add_maintainer
(
user
)
allow
(
Namespaces
::
OnboardingUserAddedWorker
).
to
receive
(
:idempotent?
).
and_return
(
false
)
source
.
is_a?
(
Project
)
?
source
.
add_maintainer
(
user
)
:
source
.
add_owner
(
user
)
end
context
'when passing valid parameters'
do
it
'adds a user to members'
do
expect
(
execute_service
[
:status
]).
to
eq
(
:success
)
expect
(
project
.
users
).
to
include
project_user
expect
(
Namespaces
::
OnboardingUserAddedWorker
.
jobs
.
last
[
'args'
][
0
]).
to
eq
(
project
.
id
)
expect
(
source
.
users
).
to
include
member
expect
(
NamespaceOnboardingAction
.
completed?
(
source
.
namespace
,
:user_added
)).
to
be
(
true
)
end
context
'when executing on a group'
do
let_it_be
(
:source
)
{
create
(
:group
)
}
it
'adds a user to members'
do
expect
(
execute_service
[
:status
]).
to
eq
(
:success
)
expect
(
source
.
users
).
to
include
member
expect
(
NamespaceOnboardingAction
.
completed?
(
source
,
:user_added
)).
to
be
(
true
)
end
end
end
...
...
@@ -31,8 +40,8 @@ RSpec.describe Members::CreateService do
it
'does not add a member'
do
expect
(
execute_service
[
:status
]).
to
eq
(
:error
)
expect
(
execute_service
[
:message
]).
to
be_present
expect
(
project
.
users
).
not_to
include
project_us
er
expect
(
Namespace
s
::
OnboardingUserAddedWorker
.
jobs
.
size
).
to
eq
(
0
)
expect
(
source
.
users
).
not_to
include
memb
er
expect
(
Namespace
OnboardingAction
.
completed?
(
source
.
namespace
,
:user_added
)).
to
be
(
false
)
end
end
...
...
@@ -42,8 +51,8 @@ RSpec.describe Members::CreateService do
it
'limits the number of users to 100'
do
expect
(
execute_service
[
:status
]).
to
eq
(
:error
)
expect
(
execute_service
[
:message
]).
to
be_present
expect
(
project
.
users
).
not_to
include
project_us
er
expect
(
Namespace
s
::
OnboardingUserAddedWorker
.
jobs
.
size
).
to
eq
(
0
)
expect
(
source
.
users
).
not_to
include
memb
er
expect
(
Namespace
OnboardingAction
.
completed?
(
source
.
namespace
,
:user_added
)).
to
be
(
false
)
end
end
...
...
@@ -52,19 +61,19 @@ RSpec.describe Members::CreateService do
it
'does not add a member'
do
expect
(
execute_service
[
:status
]).
to
eq
(
:error
)
expect
(
execute_service
[
:message
]).
to
include
(
"
#{
project_us
er
.
username
}
: Access level is not included in the list"
)
expect
(
project
.
users
).
not_to
include
project_us
er
expect
(
Namespace
s
::
OnboardingUserAddedWorker
.
jobs
.
size
).
to
eq
(
0
)
expect
(
execute_service
[
:message
]).
to
include
(
"
#{
memb
er
.
username
}
: Access level is not included in the list"
)
expect
(
source
.
users
).
not_to
include
memb
er
expect
(
Namespace
OnboardingAction
.
completed?
(
source
.
namespace
,
:user_added
)).
to
be
(
false
)
end
end
context
'when passing an existing invite user id'
do
let
(
:user_ids
)
{
create
(
:project_member
,
:invited
,
project:
project
).
invite_email
}
let
(
:user_ids
)
{
create
(
:project_member
,
:invited
,
project:
source
).
invite_email
}
it
'does not add a member'
do
expect
(
execute_service
[
:status
]).
to
eq
(
:error
)
expect
(
execute_service
[
:message
]).
to
eq
(
'Invite email has already been taken'
)
expect
(
Namespace
s
::
OnboardingUserAddedWorker
.
jobs
.
size
).
to
eq
(
0
)
expect
(
Namespace
OnboardingAction
.
completed?
(
source
.
namespace
,
:user_added
)).
to
be
(
false
)
end
end
end
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