2020-09-03 14:08:29 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
RSpec.configure do |config|
|
2020-11-09 16:08:48 -05:00
|
|
|
config.include SnowplowHelpers, :snowplow
|
|
|
|
|
2020-09-03 14:08:29 -04:00
|
|
|
config.before(:each, :snowplow) do
|
|
|
|
# Using a high buffer size to not cause early flushes
|
|
|
|
buffer_size = 100
|
|
|
|
# WebMock is set up to allow requests to `localhost`
|
|
|
|
host = 'localhost'
|
|
|
|
|
2020-11-21 01:09:33 -05:00
|
|
|
allow_any_instance_of(Gitlab::Tracking::Destinations::ProductAnalytics).to receive(:event)
|
|
|
|
|
2020-11-04 10:08:41 -05:00
|
|
|
allow_any_instance_of(Gitlab::Tracking::Destinations::Snowplow)
|
2020-09-03 14:08:29 -04:00
|
|
|
.to receive(:emitter)
|
|
|
|
.and_return(SnowplowTracker::Emitter.new(host, buffer_size: buffer_size))
|
|
|
|
|
|
|
|
stub_application_setting(snowplow_enabled: true)
|
|
|
|
|
2020-12-10 19:09:41 -05:00
|
|
|
allow(SnowplowTracker::SelfDescribingJson).to receive(:new).and_call_original
|
2021-01-26 10:08:58 -05:00
|
|
|
allow(Gitlab::Tracking::StandardContext).to receive(:new).and_call_original
|
2020-10-22 08:08:41 -04:00
|
|
|
allow(Gitlab::Tracking).to receive(:event).and_call_original # rubocop:disable RSpec/ExpectGitlabTracking
|
2020-09-03 14:08:29 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
config.after(:each, :snowplow) do
|
2020-11-04 10:08:41 -05:00
|
|
|
Gitlab::Tracking.send(:snowplow).send(:tracker).flush
|
2020-09-03 14:08:29 -04:00
|
|
|
end
|
|
|
|
end
|