Commit f98e6652 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'nicolasdular/call-snowplow-for-gitlab-experiment-tracking' into 'master'

Call snowplow for gitlab-experiment specs  [RUN ALL RSPEC]

See merge request gitlab-org/gitlab!55072
parents 9c4e1472 70a0d5ff
......@@ -2,6 +2,7 @@
# Require the provided spec helper and matchers.
require 'gitlab/experiment/rspec'
require_relative 'stub_snowplow'
# This is a temporary fix until we have a larger discussion around the
# challenges raised in https://gitlab.com/gitlab-org/gitlab/-/issues/300104
......@@ -10,11 +11,21 @@ class ApplicationExperiment # rubocop:disable Gitlab/NamespacedClass
super(...)
Feature.persist_used!(feature_flag_name)
end
def should_track?
true
end
end
RSpec.configure do |config|
config.include StubSnowplow, :experiment
# Disable all caching for experiments in tests.
config.before do
allow(Gitlab::Experiment::Configuration).to receive(:cache).and_return(nil)
end
config.before(:each, :experiment) do
stub_snowplow
end
end
# frozen_string_literal: true
require_relative 'stub_snowplow'
RSpec.configure do |config|
config.include SnowplowHelpers, :snowplow
config.include StubSnowplow, :snowplow
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'
allow_any_instance_of(Gitlab::Tracking::Destinations::ProductAnalytics).to receive(:event)
allow_any_instance_of(Gitlab::Tracking::Destinations::Snowplow)
.to receive(:emitter)
.and_return(SnowplowTracker::Emitter.new(host, buffer_size: buffer_size))
stub_application_setting(snowplow_enabled: true)
allow(SnowplowTracker::SelfDescribingJson).to receive(:new).and_call_original
allow(Gitlab::Tracking).to receive(:event).and_call_original # rubocop:disable RSpec/ExpectGitlabTracking
stub_snowplow
end
config.after(:each, :snowplow) do
......
# frozen_string_literal: true
module StubSnowplow
def stub_snowplow
# Using a high buffer size to not cause early flushes
buffer_size = 100
# WebMock is set up to allow requests to `localhost`
host = 'localhost'
# rubocop:disable RSpec/AnyInstanceOf
allow_any_instance_of(Gitlab::Tracking::Destinations::ProductAnalytics).to receive(:event)
allow_any_instance_of(Gitlab::Tracking::Destinations::Snowplow)
.to receive(:emitter)
.and_return(SnowplowTracker::Emitter.new(host, buffer_size: buffer_size))
# rubocop:enable RSpec/AnyInstanceOf
stub_application_setting(snowplow_enabled: true)
allow(SnowplowTracker::SelfDescribingJson).to receive(:new).and_call_original
allow(Gitlab::Tracking).to receive(:event).and_call_original # rubocop:disable RSpec/ExpectGitlabTracking
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