Commit 2784a285 authored by Doug Stull's avatar Doug Stull

Merge branch 'dreedy-fix-application_experiment-publish_to_database' into 'master'

Restore ApplicationExperiment#publish_to_database functionality

See merge request gitlab-org/gitlab!68389

Changelog: fixed
parents 1813a6a0 42be0ec7
......@@ -13,7 +13,7 @@ class ApplicationExperiment < Gitlab::Experiment # rubocop:disable Gitlab/Namesp
super
publish_to_client
publish_to_database
publish_to_database if @record
end
def publish_to_client
......@@ -25,7 +25,6 @@ class ApplicationExperiment < Gitlab::Experiment # rubocop:disable Gitlab/Namesp
end
def publish_to_database
return unless @record
return unless should_track?
# if the context contains a namespace, group, project, user, or actor
......
......@@ -80,6 +80,8 @@ RSpec.describe ApplicationExperiment, :experiment do
end
it "publishes to the database if we've opted for that" do
subject.record!
expect(subject).to receive(:publish_to_database)
subject.publish
......@@ -121,6 +123,8 @@ RSpec.describe ApplicationExperiment, :experiment do
end
describe '#publish_to_database' do
using RSpec::Parameterized::TableSyntax
shared_examples 'does not record to the database' do
it 'does not create an experiment record' do
expect { subject.publish_to_database }.not_to change(Experiment, :count)
......@@ -131,13 +135,6 @@ RSpec.describe ApplicationExperiment, :experiment do
end
end
context 'when we explicitly request to record' do
using RSpec::Parameterized::TableSyntax
before do
subject.record!
end
context 'when there is a usable subject' do
let(:context) { { context_key => context_value } }
......@@ -178,11 +175,6 @@ RSpec.describe ApplicationExperiment, :experiment do
include_examples 'does not record to the database'
end
end
context 'when we have not explicitly requested to record' do
include_examples 'does not record to the database'
end
end
end
describe "#track", :snowplow do
......
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