Commit fd882d51 authored by Markus Koller's avatar Markus Koller

Merge branch 'namespace-onboarding-action-create-merge-request' into 'master'

Add create merge request namespace onboarding action

See merge request gitlab-org/gitlab!49002
parents 381213cc 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
......
...@@ -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
......
...@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment