Commit 2aa4570a authored by Nicolas Dular's avatar Nicolas Dular

Stop overriding tracking check in experiment stub

With `gitlab-experiment` 0.5.2 a bug got fixed where stubbing
experiments in tests didn't work. With that fix, we can get rid of
overriding the `should_track?` method to always return true, since
we can now rely on the actual implemention, where it can exclude
actors.
parent 6abd47a3
......@@ -8,6 +8,11 @@ RSpec.describe EmptyRepoUploadExperiment, :experiment do
let(:project) { create(:project, :repository) }
describe '#track_initial_write' do
context 'when experiment is turned on' do
before do
stub_experiments(empty_repo_upload: :control)
end
it "tracks an event for the first commit on a project" do
expect(subject).to receive(:commit_count_for).with(project, max_count: described_class::INITIAL_COMMIT_COUNT, experiment: 'empty_repo_upload').and_return(1)
......@@ -24,20 +29,21 @@ RSpec.describe EmptyRepoUploadExperiment, :experiment do
subject.track_initial_write
end
it "doesn't track when we generally shouldn't" do
allow(subject).to receive(:should_track?).and_return(false)
it "doesn't track if the project is older" do
expect(project).to receive(:created_at).and_return(described_class::TRACKING_START_DATE - 1.minute)
expect(subject).not_to receive(:track)
subject.track_initial_write
end
end
it "doesn't track if the project is older" do
expect(project).to receive(:created_at).and_return(described_class::TRACKING_START_DATE - 1.minute)
context 'when experiment is turned off' do
it "doesn't track when we generally shouldn't" do
expect(subject).not_to receive(:track)
subject.track_initial_write
end
end
end
end
......@@ -29,6 +29,10 @@ RSpec.describe NewProjectReadmeExperiment, :experiment do
context "when tracking initial writes" do
let!(:project) { create(:project, :repository) }
before do
stub_experiments(new_project_readme: :control)
end
it "tracks an event for the first commit on a project with a repository" do
expect(subject).to receive(:commit_count_for).with(project, default_count: described_class::INITIAL_WRITE_LIMIT, max_count: described_class::INITIAL_WRITE_LIMIT, experiment: 'new_project_readme').and_return(1)
expect(subject).to receive(:track).with(:write, property: project.created_at.to_s, value: 1).and_call_original
......
......@@ -12,10 +12,6 @@ class ApplicationExperiment # rubocop:disable Gitlab/NamespacedClass
super(...)
Feature.persist_used!(feature_flag_name)
end
def should_track?
true
end
end
RSpec.configure do |config|
......
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