diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /spec/services/packages/create_event_service_spec.rb | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'spec/services/packages/create_event_service_spec.rb')
-rw-r--r-- | spec/services/packages/create_event_service_spec.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/services/packages/create_event_service_spec.rb b/spec/services/packages/create_event_service_spec.rb index 4db7687bb24..f581d704087 100644 --- a/spec/services/packages/create_event_service_spec.rb +++ b/spec/services/packages/create_event_service_spec.rb @@ -70,12 +70,34 @@ RSpec.describe Packages::CreateEventService do end it 'tracks the event' do + expect(::Gitlab::UsageDataCounters::GuestPackageEventCounter).not_to receive(:count) expect(::Gitlab::UsageDataCounters::HLLRedisCounter).to receive(:track_event).with(user.id, Packages::Event.allowed_event_name(expected_scope, event_name, originator_type)) subject end end + shared_examples 'redis package guest event creation' do |originator_type, expected_scope| + context 'with feature flag disabled' do + before do + stub_feature_flags(collect_package_events_redis: false) + end + + it 'does not track the event' do + expect(::Gitlab::UsageDataCounters::GuestPackageEventCounter).not_to receive(:count) + + subject + end + end + + it 'tracks the event' do + expect(::Gitlab::UsageDataCounters::HLLRedisCounter).not_to receive(:track_event) + expect(::Gitlab::UsageDataCounters::GuestPackageEventCounter).to receive(:count).with(Packages::Event.allowed_event_name(expected_scope, event_name, originator_type)) + + subject + end + end + context 'with a user' do let(:user) { create(:user) } @@ -94,6 +116,7 @@ RSpec.describe Packages::CreateEventService do let(:user) { nil } it_behaves_like 'db package event creation', 'guest', 'container' + it_behaves_like 'redis package guest event creation', 'guest', 'container' end context 'with a package as scope' do @@ -103,6 +126,7 @@ RSpec.describe Packages::CreateEventService do let(:user) { nil } it_behaves_like 'db package event creation', 'guest', 'npm' + it_behaves_like 'redis package guest event creation', 'guest', 'npm' end context 'with user' do |