Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
98604065
Commit
98604065
authored
Oct 26, 2020
by
ggelatti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds feature flag to disable package events
Prevents package events from being created by default
parent
7729d4da
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
6 deletions
+40
-6
app/services/packages/create_event_service.rb
app/services/packages/create_event_service.rb
+2
-0
changelogs/unreleased/205578-feature-flag-pkg-events.yml
changelogs/unreleased/205578-feature-flag-pkg-events.yml
+5
-0
config/feature_flags/development/collect_package_events.yml
config/feature_flags/development/collect_package_events.yml
+7
-0
spec/services/packages/create_event_service_spec.rb
spec/services/packages/create_event_service_spec.rb
+22
-6
spec/support/shared_examples/requests/api/packages_shared_examples.rb
.../shared_examples/requests/api/packages_shared_examples.rb
+4
-0
No files found.
app/services/packages/create_event_service.rb
View file @
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!
(
...
...
changelogs/unreleased/205578-feature-flag-pkg-events.yml
0 → 100644
View file @
98604065
---
title
:
Adds feature flag to disable package events
merge_request
:
45802
author
:
type
:
changed
config/feature_flags/development/collect_package_events.yml
0 → 100644
View file @
98604065
---
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
spec/services/packages/create_event_service_spec.rb
View file @
98604065
...
...
@@ -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
...
...
spec/support/shared_examples/requests/api/packages_shared_examples.rb
View file @
98604065
...
...
@@ -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
,
{})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment