diff options
Diffstat (limited to 'spec/experiments/new_project_readme_experiment_spec.rb')
-rw-r--r-- | spec/experiments/new_project_readme_experiment_spec.rb | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/spec/experiments/new_project_readme_experiment_spec.rb b/spec/experiments/new_project_readme_experiment_spec.rb index 87446394bff..e5ecc4662f6 100644 --- a/spec/experiments/new_project_readme_experiment_spec.rb +++ b/spec/experiments/new_project_readme_experiment_spec.rb @@ -29,24 +29,19 @@ RSpec.describe NewProjectReadmeExperiment, :experiment do context "when tracking initial writes" do let!(:project) { create(:project, :repository) } - def stub_gitaly_count(count = 1) - allow(Gitlab::GitalyClient).to receive(:call).and_call_original - allow(Gitlab::GitalyClient).to receive(:call).with(anything, :commit_service, :count_commits, anything, anything) - .and_return(double(count: count)) - end - before do - stub_gitaly_count + 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 subject.track_initial_writes(project) end it "tracks an event for the second commit on a project with a repository" do - stub_gitaly_count(2) + allow(subject).to receive(:commit_count_for).and_return(2) expect(subject).to receive(:track).with(:write, property: project.created_at.to_s, value: 2).and_call_original @@ -54,7 +49,7 @@ RSpec.describe NewProjectReadmeExperiment, :experiment do end it "doesn't track if the repository has more then 2 commits" do - stub_gitaly_count(3) + allow(subject).to receive(:commit_count_for).and_return(3) expect(subject).not_to receive(:track) @@ -76,14 +71,5 @@ RSpec.describe NewProjectReadmeExperiment, :experiment do subject.track_initial_writes(project) end - - it "handles exceptions by logging them" do - allow(Gitlab::GitalyClient).to receive(:call).with(anything, :commit_service, :count_commits, anything, anything) - .and_raise(e = StandardError.new('_message_')) - - expect(Gitlab::ErrorTracking).to receive(:track_exception).with(e, experiment: 'new_project_readme') - - subject.track_initial_writes(project) - end end end |