Commit e460ade7 authored by Alex Buijs's avatar Alex Buijs

Move all create_action calls to service

As an abstraction layer for the model
parent d6d1304e
...@@ -12,7 +12,7 @@ module MergeRequests ...@@ -12,7 +12,7 @@ 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) OnboardingProgressService.new(merge_request.target_project.namespace).execute(action: :merge_request_created)
end end
end end
end end
......
...@@ -94,7 +94,7 @@ class PostReceiveService ...@@ -94,7 +94,7 @@ class PostReceiveService
end end
def record_onboarding_progress def record_onboarding_progress
NamespaceOnboardingAction.create_action(project.namespace, :git_write) OnboardingProgressService.new(project.namespace).execute(action: :git_write)
end end
end end
......
...@@ -24,7 +24,7 @@ module Subscriptions ...@@ -24,7 +24,7 @@ module Subscriptions
response = client.create_subscription(create_subscription_params, billing_email, token) response = client.create_subscription(create_subscription_params, billing_email, token)
NamespaceOnboardingAction.create_action(@group, :subscription_created) if response[:success] OnboardingProgressService.new(@group).execute(action: :subscription_created) if response[:success]
response response
end end
......
...@@ -52,7 +52,7 @@ RSpec.describe Repositories::GitHttpController do ...@@ -52,7 +52,7 @@ RSpec.describe Repositories::GitHttpController do
}.from(0).to(1) }.from(0).to(1)
end end
it 'records a namespace onboarding progress action' do it 'records an onboarding progress action' do
expect_next_instance_of(OnboardingProgressService) do |service| expect_next_instance_of(OnboardingProgressService) do |service|
expect(service).to receive(:execute).with(action: :git_read) expect(service).to receive(:execute).with(action: :git_read)
end end
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe MergeRequests::AfterCreateService do RSpec.describe MergeRequests::AfterCreateService do
include AfterNextHelpers
let_it_be(:merge_request) { create(:merge_request) } let_it_be(:merge_request) { create(:merge_request) }
subject(:after_create_service) do subject(:after_create_service) do
...@@ -56,9 +58,9 @@ RSpec.describe MergeRequests::AfterCreateService do ...@@ -56,9 +58,9 @@ RSpec.describe MergeRequests::AfterCreateService do
execute_service execute_service
end end
it 'records a namespace onboarding progress action' do it 'records an onboarding progress action' do
expect(NamespaceOnboardingAction).to receive(:create_action) expect_next(OnboardingProgressService, merge_request.target_project.namespace)
.with(merge_request.target_project.namespace, :merge_request_created).and_call_original .to receive(:execute).with(action: :merge_request_created).and_call_original
expect { execute_service }.to change(NamespaceOnboardingAction, :count).by(1) expect { execute_service }.to change(NamespaceOnboardingAction, :count).by(1)
end end
......
...@@ -4,6 +4,7 @@ require 'spec_helper' ...@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe PostReceiveService do RSpec.describe PostReceiveService do
include Gitlab::Routing include Gitlab::Routing
include AfterNextHelpers
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project, :repository, :wiki_repo, namespace: user.namespace) } let_it_be(:project) { create(:project, :repository, :wiki_repo, namespace: user.namespace) }
...@@ -46,8 +47,8 @@ RSpec.describe PostReceiveService do ...@@ -46,8 +47,8 @@ RSpec.describe PostReceiveService do
expect(subject).to be_empty expect(subject).to be_empty
end end
it 'does not record a namespace onboarding progress action' do it 'does not record an onboarding progress action' do
expect(NamespaceOnboardingAction).not_to receive(:create_action) expect_next(OnboardingProgressService).not_to receive(:execute)
subject subject
end end
...@@ -87,9 +88,9 @@ RSpec.describe PostReceiveService do ...@@ -87,9 +88,9 @@ RSpec.describe PostReceiveService do
expect(response.reference_counter_decreased).to be(true) expect(response.reference_counter_decreased).to be(true)
end end
it 'records a namespace onboarding progress action' do it 'records an onboarding progress action' do
expect(NamespaceOnboardingAction).to receive(:create_action) expect_next(OnboardingProgressService, project.namespace)
.with(project.namespace, :git_write) .to receive(:execute).with(action: :git_write)
subject subject
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