Commit 5621392d authored by Fabio Pitino's avatar Fabio Pitino

Merge branch '205578-feature-flag-pkg-events' into 'master'

Adds feature flag to disable package events

See merge request gitlab-org/gitlab!45802
parents dee53416 98604065
......@@ -3,6 +3,8 @@
module Packages
class CreateEventService < BaseService
def execute
return unless Feature.enabled?(:collect_package_events, default_enabled: false)
event_scope = scope.is_a?(::Packages::Package) ? scope.package_type : scope
::Packages::Event.create!(
......
---
title: Adds feature flag to disable package events
merge_request: 45802
author:
type: changed
---
name: collect_package_events
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/45802
rollout_issue_url:
group: group::package
type: development
default_enabled: false
......@@ -16,13 +16,29 @@ RSpec.describe Packages::CreateEventService do
describe '#execute' do
shared_examples 'package event creation' do |originator_type, expected_scope|
it 'creates the event' do
expect { subject }.to change { Packages::Event.count }.by(1)
context 'with feature flag disable' do
before do
stub_feature_flags(collect_package_events: false)
end
expect(subject.originator_type).to eq(originator_type)
expect(subject.originator).to eq(user&.id)
expect(subject.event_scope).to eq(expected_scope)
expect(subject.event_type).to eq(event_name)
it 'returns nil' do
expect(subject).to be nil
end
end
context 'with feature flag enabled' do
before do
stub_feature_flags(collect_package_events: true)
end
it 'creates the event' do
expect { subject }.to change { Packages::Event.count }.by(1)
expect(subject.originator_type).to eq(originator_type)
expect(subject.originator).to eq(user&.id)
expect(subject.event_scope).to eq(expected_scope)
expect(subject.event_type).to eq(event_name)
end
end
end
......
......@@ -128,6 +128,10 @@ RSpec.shared_examples 'job token for package uploads' do
end
RSpec.shared_examples 'a package tracking event' do |category, action|
before do
stub_feature_flags(collect_package_events: true)
end
it "creates a gitlab tracking event #{action}" do
expect(Gitlab::Tracking).to receive(:event).with(category, action)
......
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