debian-mirror-gitlab/spec/support/snowplow.rb

28 lines
932 B
Ruby
Raw Normal View History

2020-11-24 15:15:51 +05:30
# frozen_string_literal: true
RSpec.configure do |config|
2021-01-29 00:20:46 +05:30
config.include SnowplowHelpers, :snowplow
2020-11-24 15:15:51 +05:30
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'
2021-02-22 17:27:13 +05:30
allow_any_instance_of(Gitlab::Tracking::Destinations::ProductAnalytics).to receive(:event)
2021-01-29 00:20:46 +05:30
allow_any_instance_of(Gitlab::Tracking::Destinations::Snowplow)
2020-11-24 15:15:51 +05:30
.to receive(:emitter)
.and_return(SnowplowTracker::Emitter.new(host, buffer_size: buffer_size))
stub_application_setting(snowplow_enabled: true)
2021-02-22 17:27:13 +05:30
allow(SnowplowTracker::SelfDescribingJson).to receive(:new).and_call_original
2021-01-29 00:20:46 +05:30
allow(Gitlab::Tracking).to receive(:event).and_call_original # rubocop:disable RSpec/ExpectGitlabTracking
2020-11-24 15:15:51 +05:30
end
config.after(:each, :snowplow) do
2021-01-29 00:20:46 +05:30
Gitlab::Tracking.send(:snowplow).send(:tracker).flush
2020-11-24 15:15:51 +05:30
end
end