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
db82a385
Commit
db82a385
authored
Jan 07, 2021
by
Alex Buijs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert all calls to OnboardingProgress model
Instead of the NamespaceOnboardingAction model
parent
66a8e157
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
65 additions
and
33 deletions
+65
-33
app/services/onboarding_progress_service.rb
app/services/onboarding_progress_service.rb
+1
-1
ee/spec/services/subscriptions/create_service_spec.rb
ee/spec/services/subscriptions/create_service_spec.rb
+8
-4
spec/services/members/create_service_spec.rb
spec/services/members/create_service_spec.rb
+13
-7
spec/services/merge_requests/after_create_service_spec.rb
spec/services/merge_requests/after_create_service_spec.rb
+6
-2
spec/services/onboarding_progress_service_spec.rb
spec/services/onboarding_progress_service_spec.rb
+17
-11
spec/workers/namespaces/onboarding_pipeline_created_worker_spec.rb
...ers/namespaces/onboarding_pipeline_created_worker_spec.rb
+12
-6
spec/workers/namespaces/onboarding_user_added_worker_spec.rb
spec/workers/namespaces/onboarding_user_added_worker_spec.rb
+8
-2
No files found.
app/services/onboarding_progress_service.rb
View file @
db82a385
...
...
@@ -8,6 +8,6 @@ class OnboardingProgressService
def
execute
(
action
:)
return
unless
@namespace
NamespaceOnboardingAction
.
create_action
(
@namespace
,
action
)
OnboardingProgress
.
register
(
@namespace
,
action
)
end
end
ee/spec/services/subscriptions/create_service_spec.rb
View file @
db82a385
...
...
@@ -66,10 +66,12 @@ RSpec.describe Subscriptions::CreateService do
expect
(
subject
.
execute
).
to
eq
(
success:
false
,
data:
{
errors:
'failed to create subscription'
})
end
it
'does not create a namespace onboarding action'
do
it
'does not register a namespace onboarding progress action'
do
OnboardingProgress
.
onboard
(
group
)
subject
.
execute
expect
(
NamespaceOnboardingAction
.
completed?
(
group
,
:subscription_created
)).
to
eq
(
false
)
expect
(
OnboardingProgress
.
completed?
(
group
,
:subscription_created
)).
to
eq
(
false
)
end
end
...
...
@@ -102,10 +104,12 @@ RSpec.describe Subscriptions::CreateService do
subject
.
execute
end
it
'creates a namespace onboarding action'
do
it
'registers a namespace onboarding progress action'
do
OnboardingProgress
.
onboard
(
group
)
subject
.
execute
expect
(
NamespaceOnboardingAction
.
completed?
(
group
,
:subscription_created
)).
to
eq
(
true
)
expect
(
OnboardingProgress
.
completed?
(
group
,
:subscription_created
)).
to
eq
(
true
)
end
end
end
...
...
spec/services/members/create_service_spec.rb
View file @
db82a385
...
...
@@ -13,14 +13,20 @@ RSpec.describe Members::CreateService, :clean_gitlab_redis_shared_state, :sideki
subject
(
:execute_service
)
{
described_class
.
new
(
user
,
params
).
execute
(
source
)
}
before
do
source
.
is_a?
(
Project
)
?
source
.
add_maintainer
(
user
)
:
source
.
add_owner
(
user
)
if
source
.
is_a?
(
Project
)
source
.
add_maintainer
(
user
)
OnboardingProgress
.
onboard
(
source
.
namespace
)
else
source
.
add_owner
(
user
)
OnboardingProgress
.
onboard
(
source
)
end
end
context
'when passing valid parameters'
do
it
'adds a user to members'
do
expect
(
execute_service
[
:status
]).
to
eq
(
:success
)
expect
(
source
.
users
).
to
include
member
expect
(
NamespaceOnboardingAction
.
completed?
(
source
.
namespace
,
:user_added
)).
to
be
(
true
)
expect
(
OnboardingProgress
.
completed?
(
source
.
namespace
,
:user_added
)).
to
be
(
true
)
end
context
'when executing on a group'
do
...
...
@@ -29,7 +35,7 @@ RSpec.describe Members::CreateService, :clean_gitlab_redis_shared_state, :sideki
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
)
expect
(
OnboardingProgress
.
completed?
(
source
,
:user_added
)).
to
be
(
true
)
end
end
end
...
...
@@ -41,7 +47,7 @@ RSpec.describe Members::CreateService, :clean_gitlab_redis_shared_state, :sideki
expect
(
execute_service
[
:status
]).
to
eq
(
:error
)
expect
(
execute_service
[
:message
]).
to
be_present
expect
(
source
.
users
).
not_to
include
member
expect
(
NamespaceOnboardingAction
.
completed?
(
source
.
namespace
,
:user_added
)).
to
be
(
false
)
expect
(
OnboardingProgress
.
completed?
(
source
.
namespace
,
:user_added
)).
to
be
(
false
)
end
end
...
...
@@ -52,7 +58,7 @@ RSpec.describe Members::CreateService, :clean_gitlab_redis_shared_state, :sideki
expect
(
execute_service
[
:status
]).
to
eq
(
:error
)
expect
(
execute_service
[
:message
]).
to
be_present
expect
(
source
.
users
).
not_to
include
member
expect
(
NamespaceOnboardingAction
.
completed?
(
source
.
namespace
,
:user_added
)).
to
be
(
false
)
expect
(
OnboardingProgress
.
completed?
(
source
.
namespace
,
:user_added
)).
to
be
(
false
)
end
end
...
...
@@ -63,7 +69,7 @@ RSpec.describe Members::CreateService, :clean_gitlab_redis_shared_state, :sideki
expect
(
execute_service
[
:status
]).
to
eq
(
:error
)
expect
(
execute_service
[
:message
]).
to
include
(
"
#{
member
.
username
}
: Access level is not included in the list"
)
expect
(
source
.
users
).
not_to
include
member
expect
(
NamespaceOnboardingAction
.
completed?
(
source
.
namespace
,
:user_added
)).
to
be
(
false
)
expect
(
OnboardingProgress
.
completed?
(
source
.
namespace
,
:user_added
)).
to
be
(
false
)
end
end
...
...
@@ -73,7 +79,7 @@ RSpec.describe Members::CreateService, :clean_gitlab_redis_shared_state, :sideki
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
(
NamespaceOnboardingAction
.
completed?
(
source
.
namespace
,
:user_added
)).
to
be
(
false
)
expect
(
OnboardingProgress
.
completed?
(
source
.
namespace
,
:user_added
)).
to
be
(
false
)
end
end
end
spec/services/merge_requests/after_create_service_spec.rb
View file @
db82a385
...
...
@@ -58,11 +58,15 @@ RSpec.describe MergeRequests::AfterCreateService do
execute_service
end
it
'records an onboarding progress action'
do
it
'registers an onboarding progress action'
do
OnboardingProgress
.
onboard
(
merge_request
.
target_project
.
namespace
)
expect_next
(
OnboardingProgressService
,
merge_request
.
target_project
.
namespace
)
.
to
receive
(
:execute
).
with
(
action: :merge_request_created
).
and_call_original
expect
{
execute_service
}.
to
change
(
NamespaceOnboardingAction
,
:count
).
by
(
1
)
execute_service
expect
(
OnboardingProgress
.
completed?
(
merge_request
.
target_project
.
namespace
,
:merge_request_created
)).
to
be
(
true
)
end
end
end
spec/services/onboarding_progress_service_spec.rb
View file @
db82a385
...
...
@@ -11,32 +11,38 @@ RSpec.describe OnboardingProgressService do
subject
(
:execute_service
)
{
described_class
.
new
(
namespace
).
execute
(
action: :subscription_created
)
}
context
'when the namespace is a root'
do
it
'records a namespace onboarding progress action fot the given namespace'
do
expect
(
NamespaceOnboardingAction
).
to
receive
(
:create_action
)
.
with
(
namespace
,
:subscription_created
).
and_call_original
before
do
OnboardingProgress
.
onboard
(
namespace
)
end
it
'registers a namespace onboarding progress action for the given namespace'
do
execute_service
expect
{
execute_service
}.
to
change
(
NamespaceOnboardingAction
,
:count
).
by
(
1
)
expect
(
OnboardingProgress
.
completed?
(
namespace
,
:subscription_created
)).
to
eq
(
true
)
end
end
context
'when the namespace is not the root'
do
let
(
:root_namespace
)
{
build
(
:namespace
)
}
it
'records a namespace onboarding progress action for the root namespace'
do
expect
(
NamespaceOnboardingAction
).
to
receive
(
:create_action
)
.
with
(
root_namespace
,
:subscription_created
).
and_call_original
before
do
OnboardingProgress
.
onboard
(
root_namespace
)
end
it
'registers a namespace onboarding progress action for the root namespace'
do
execute_service
expect
{
execute_service
}.
to
change
(
NamespaceOnboardingAction
,
:count
).
by
(
1
)
expect
(
OnboardingProgress
.
completed?
(
root_namespace
,
:subscription_created
)).
to
eq
(
true
)
end
end
context
'when no namespace is passed'
do
let
(
:namespace
)
{
nil
}
it
'does not record a namespace onboarding progress action'
do
expect
(
NamespaceOnboardingAction
).
not_to
receive
(
:create_action
)
it
'does not register a namespace onboarding progress action'
do
execute_service
expect
(
OnboardingProgress
.
completed?
(
root_namespace
,
:subscription_created
)).
to
be
(
nil
)
end
end
end
...
...
spec/workers/namespaces/onboarding_pipeline_created_worker_spec.rb
View file @
db82a385
...
...
@@ -7,20 +7,26 @@ RSpec.describe Namespaces::OnboardingPipelineCreatedWorker, '#perform' do
let_it_be
(
:ci_pipeline
)
{
create
(
:ci_pipeline
)
}
it
'records the event'
do
before
do
OnboardingProgress
.
onboard
(
ci_pipeline
.
project
.
namespace
)
end
it
'registers an onboarding progress action'
do
expect_next
(
OnboardingProgressService
,
ci_pipeline
.
project
.
namespace
)
.
to
receive
(
:execute
).
with
(
action: :pipeline_created
).
and_call_original
expect
do
subject
.
perform
(
ci_pipeline
.
project
.
namespace_id
)
e
nd
.
to
change
(
NamespaceOnboardingAction
,
:count
).
by
(
1
)
subject
.
perform
(
ci_pipeline
.
project
.
namespace_id
)
e
xpect
(
OnboardingProgress
.
completed?
(
ci_pipeline
.
project
.
namespace
,
:pipeline_created
)).
to
eq
(
true
)
end
context
"when a namespace doesn't exist"
do
it
"does nothing"
do
it
'does not register an onboarding progress action'
do
expect_next
(
OnboardingProgressService
,
ci_pipeline
.
project
.
namespace
).
not_to
receive
(
:execute
)
expect
{
subject
.
perform
(
nil
)
}.
not_to
change
(
NamespaceOnboardingAction
,
:count
)
subject
.
perform
(
nil
)
expect
(
OnboardingProgress
.
completed?
(
ci_pipeline
.
project
.
namespace
,
:pipeline_created
)).
to
eq
(
false
)
end
end
end
spec/workers/namespaces/onboarding_user_added_worker_spec.rb
View file @
db82a385
...
...
@@ -7,10 +7,16 @@ RSpec.describe Namespaces::OnboardingUserAddedWorker, '#perform' do
let_it_be
(
:group
)
{
create
(
:group
)
}
it
'records the event'
do
before
do
OnboardingProgress
.
onboard
(
group
)
end
it
'registers an onboarding progress action'
do
expect_next
(
OnboardingProgressService
,
group
)
.
to
receive
(
:execute
).
with
(
action: :user_added
).
and_call_original
expect
{
subject
.
perform
(
group
.
id
)
}.
to
change
(
NamespaceOnboardingAction
,
:count
).
by
(
1
)
subject
.
perform
(
group
.
id
)
expect
(
OnboardingProgress
.
completed?
(
group
,
:user_added
)).
to
be
(
true
)
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