Commit 853ecc0e authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre Committed by Michael Kozono

Does not track package events on a read-only instance

parent 44383761
......@@ -7,7 +7,7 @@ module Packages
::Gitlab::UsageDataCounters::HLLRedisCounter.track_event(current_user.id, redis_event_name)
end
if Feature.enabled?(:collect_package_events)
if Feature.enabled?(:collect_package_events) && Gitlab::Database.read_write?
::Packages::Event.create!(
event_type: event_name,
originator: current_user&.id,
......
---
title: Does not track package events on a read-only instance
merge_request: 48257
author:
type: fixed
......@@ -25,7 +25,7 @@ RSpec.describe Packages::CreateEventService do
stub_feature_flags(collect_package_events: false)
end
it 'does not create an event object' do
it 'does not create an event' do
expect { subject }.not_to change { Packages::Event.count }
end
end
......@@ -43,6 +43,16 @@ RSpec.describe Packages::CreateEventService do
expect(subject.event_scope).to eq(expected_scope)
expect(subject.event_type).to eq(event_name)
end
context 'on a read-only instance' do
before do
allow(Gitlab::Database).to receive(:read_only?).and_return(true)
end
it 'does not create an event' do
expect { subject }.not_to change { Packages::Event.count }
end
end
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