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
merge_request.diffs(include_stats: false).write_cache
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
......
......@@ -94,7 +94,7 @@ class PostReceiveService
end
def record_onboarding_progress
NamespaceOnboardingAction.create_action(project.namespace, :git_write)
OnboardingProgressService.new(project.namespace).execute(action: :git_write)
end
end
......
......@@ -24,7 +24,7 @@ module Subscriptions
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
end
......
......@@ -52,7 +52,7 @@ RSpec.describe Repositories::GitHttpController do
}.from(0).to(1)
end
it 'records a namespace onboarding progress action' do
it 'records an onboarding progress action' do
expect_next_instance_of(OnboardingProgressService) do |service|
expect(service).to receive(:execute).with(action: :git_read)
end
......
......@@ -3,6 +3,8 @@
require 'spec_helper'
RSpec.describe MergeRequests::AfterCreateService do
include AfterNextHelpers
let_it_be(:merge_request) { create(:merge_request) }
subject(:after_create_service) do
......@@ -56,9 +58,9 @@ RSpec.describe MergeRequests::AfterCreateService do
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
it 'records an onboarding progress action' do
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)
end
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe PostReceiveService do
include Gitlab::Routing
include AfterNextHelpers
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project, :repository, :wiki_repo, namespace: user.namespace) }
......@@ -46,8 +47,8 @@ RSpec.describe PostReceiveService do
expect(subject).to be_empty
end
it 'does not record a namespace onboarding progress action' do
expect(NamespaceOnboardingAction).not_to receive(:create_action)
it 'does not record an onboarding progress action' do
expect_next(OnboardingProgressService).not_to receive(:execute)
subject
end
......@@ -87,9 +88,9 @@ RSpec.describe PostReceiveService do
expect(response.reference_counter_decreased).to be(true)
end
it 'records a namespace onboarding progress action' do
expect(NamespaceOnboardingAction).to receive(:create_action)
.with(project.namespace, :git_write)
it 'records an onboarding progress action' do
expect_next(OnboardingProgressService, project.namespace)
.to receive(:execute).with(action: :git_write)
subject
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