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
23066895
Commit
23066895
authored
Dec 03, 2020
by
Alex Buijs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add create merge request namespace onboarding action
For tracking namespace onboarding progress
parent
ce1a7c46
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
5 deletions
+17
-5
app/models/namespace_onboarding_action.rb
app/models/namespace_onboarding_action.rb
+1
-0
app/services/merge_requests/after_create_service.rb
app/services/merge_requests/after_create_service.rb
+2
-0
spec/services/merge_requests/after_create_service_spec.rb
spec/services/merge_requests/after_create_service_spec.rb
+14
-5
No files found.
app/models/namespace_onboarding_action.rb
View file @
23066895
...
@@ -8,6 +8,7 @@ class NamespaceOnboardingAction < ApplicationRecord
...
@@ -8,6 +8,7 @@ class NamespaceOnboardingAction < ApplicationRecord
ACTIONS
=
{
ACTIONS
=
{
subscription_created:
1
,
subscription_created:
1
,
git_write:
2
,
git_write:
2
,
merge_request_created:
3
,
git_read:
4
git_read:
4
}.
freeze
}.
freeze
...
...
app/services/merge_requests/after_create_service.rb
View file @
23066895
...
@@ -11,6 +11,8 @@ module MergeRequests
...
@@ -11,6 +11,8 @@ module MergeRequests
merge_request
.
diffs
(
include_stats:
false
).
write_cache
merge_request
.
diffs
(
include_stats:
false
).
write_cache
merge_request
.
create_cross_references!
(
current_user
)
merge_request
.
create_cross_references!
(
current_user
)
NamespaceOnboardingAction
.
create_action
(
merge_request
.
target_project
.
namespace
,
:merge_request_created
)
end
end
end
end
end
end
...
...
spec/services/merge_requests/after_create_service_spec.rb
View file @
23066895
...
@@ -18,32 +18,34 @@ RSpec.describe MergeRequests::AfterCreateService do
...
@@ -18,32 +18,34 @@ RSpec.describe MergeRequests::AfterCreateService do
allow
(
after_create_service
).
to
receive
(
:notification_service
).
and_return
(
notification_service
)
allow
(
after_create_service
).
to
receive
(
:notification_service
).
and_return
(
notification_service
)
end
end
subject
(
:execute_service
)
{
after_create_service
.
execute
(
merge_request
)
}
it
'creates a merge request open event'
do
it
'creates a merge request open event'
do
expect
(
event_service
)
expect
(
event_service
)
.
to
receive
(
:open_mr
).
with
(
merge_request
,
merge_request
.
author
)
.
to
receive
(
:open_mr
).
with
(
merge_request
,
merge_request
.
author
)
after_create_service
.
execute
(
merge_request
)
execute_service
end
end
it
'creates a new merge request notification'
do
it
'creates a new merge request notification'
do
expect
(
notification_service
)
expect
(
notification_service
)
.
to
receive
(
:new_merge_request
).
with
(
merge_request
,
merge_request
.
author
)
.
to
receive
(
:new_merge_request
).
with
(
merge_request
,
merge_request
.
author
)
after_create_service
.
execute
(
merge_request
)
execute_service
end
end
it
'writes diffs to the cache'
do
it
'writes diffs to the cache'
do
expect
(
merge_request
)
expect
(
merge_request
)
.
to
receive_message_chain
(
:diffs
,
:write_cache
)
.
to
receive_message_chain
(
:diffs
,
:write_cache
)
after_create_service
.
execute
(
merge_request
)
execute_service
end
end
it
'creates cross references'
do
it
'creates cross references'
do
expect
(
merge_request
)
expect
(
merge_request
)
.
to
receive
(
:create_cross_references!
).
with
(
merge_request
.
author
)
.
to
receive
(
:create_cross_references!
).
with
(
merge_request
.
author
)
after_create_service
.
execute
(
merge_request
)
execute_service
end
end
it
'creates a pipeline and updates the HEAD pipeline'
do
it
'creates a pipeline and updates the HEAD pipeline'
do
...
@@ -51,7 +53,14 @@ RSpec.describe MergeRequests::AfterCreateService do
...
@@ -51,7 +53,14 @@ RSpec.describe MergeRequests::AfterCreateService do
.
to
receive
(
:create_pipeline_for
).
with
(
merge_request
,
merge_request
.
author
)
.
to
receive
(
:create_pipeline_for
).
with
(
merge_request
,
merge_request
.
author
)
expect
(
merge_request
).
to
receive
(
:update_head_pipeline
)
expect
(
merge_request
).
to
receive
(
:update_head_pipeline
)
after_create_service
.
execute
(
merge_request
)
execute_service
end
it
'records a namespace onboarding progress action'
do
expect
(
NamespaceOnboardingAction
).
to
receive
(
:create_action
)
.
with
(
merge_request
.
target_project
.
namespace
,
:merge_request_created
).
and_call_original
expect
{
execute_service
}.
to
change
(
NamespaceOnboardingAction
,
:count
).
by
(
1
)
end
end
end
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