Commit 9db5d5dd authored by Nicolas Dular's avatar Nicolas Dular

Record onboarding progress for scoped labels

Records usage of scoped labels for the onboarding progress. This is
implemented in EE because scoped labels are EE only.
parent cfeea517
......@@ -25,3 +25,5 @@ module Labels
end
end
end
Labels::CreateService.prepend_if_ee('EE::Labels::CreateService')
# frozen_string_literal: true
module EE
module Labels
module CreateService
extend ::Gitlab::Utils::Override
override :execute
def execute(target_params)
label = super
if label.respond_to?(:group) && label.persisted? && label.scoped_label?
OnboardingProgressService.new(label.group).execute(action: :scoped_label_created)
end
label
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Labels::CreateService do
describe '#execute' do
let_it_be(:project) { create(:project) }
let_it_be(:namespace) { create(:group) }
let(:params) do
{
title: title,
color: '#000000'
}
end
subject { described_class.new(params).execute(execute_params) }
context 'for scoped labels' do
let(:title) { 'scoped::label' }
context 'for a project' do
let(:execute_params) { { project: project } }
let(:namespace) { project.group }
it_behaves_like 'records an onboarding progress action', :scoped_label_created
end
context 'for a group' do
let(:execute_params) { { group: namespace } }
it_behaves_like 'records an onboarding progress action', :scoped_label_created
end
context 'without a group or project' do
let(:execute_params) { {} }
it_behaves_like 'does not record an onboarding progress action'
end
end
context 'without scoped label' do
let(:title) { 'not scoped label' }
let(:execute_params) { { group: namespace } }
it_behaves_like 'does not record an onboarding progress action'
end
end
end
# frozen_string_literal: true
RSpec.shared_examples 'records an onboarding progress action' do |action|
include AfterNextHelpers
it do
expect_next(OnboardingProgressService, namespace)
.to receive(:execute).with(action: action).and_call_original
subject
end
end
RSpec.shared_examples 'does not record an onboarding progress action' do
it do
expect(OnboardingProgressService).not_to receive(:new)
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