summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/models/update_project_statistics_shared_examples.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/shared_examples/models/update_project_statistics_shared_examples.rb')
-rw-r--r--spec/support/shared_examples/models/update_project_statistics_shared_examples.rb110
1 files changed, 0 insertions, 110 deletions
diff --git a/spec/support/shared_examples/models/update_project_statistics_shared_examples.rb b/spec/support/shared_examples/models/update_project_statistics_shared_examples.rb
index 7b591ad84d1..2e01de2ea84 100644
--- a/spec/support/shared_examples/models/update_project_statistics_shared_examples.rb
+++ b/spec/support/shared_examples/models/update_project_statistics_shared_examples.rb
@@ -22,116 +22,6 @@ RSpec.shared_examples 'UpdateProjectStatistics' do |with_counter_attribute|
it { is_expected.to be_new_record }
- context 'when feature flag efficient_counter_attribute is disabled' do
- before do
- stub_feature_flags(efficient_counter_attribute: false)
- end
-
- context 'when creating' do
- it 'updates the project statistics' do
- delta0 = reload_stat
-
- subject.save!
-
- delta1 = reload_stat
-
- expect(delta1).to eq(delta0 + read_attribute)
- expect(delta1).to be > delta0
- end
-
- it 'schedules a namespace statistics worker' do
- expect(Namespaces::ScheduleAggregationWorker)
- .to receive(:perform_async).once
-
- subject.save!
- end
- end
-
- context 'when updating' do
- let(:delta) { 42 }
-
- before do
- subject.save!
- end
-
- it 'updates project statistics' do
- expect(ProjectStatistics)
- .to receive(:increment_statistic)
- .and_call_original
-
- subject.write_attribute(statistic_attribute, read_attribute + delta)
-
- expect { subject.save! }
- .to change { reload_stat }
- .by(delta)
- end
-
- it 'schedules a namespace statistics worker' do
- expect(Namespaces::ScheduleAggregationWorker)
- .to receive(:perform_async).once
-
- subject.write_attribute(statistic_attribute, read_attribute + delta)
- subject.save!
- end
-
- it 'avoids N + 1 queries' do
- subject.write_attribute(statistic_attribute, read_attribute + delta)
-
- control_count = ActiveRecord::QueryRecorder.new do
- subject.save!
- end
-
- subject.write_attribute(statistic_attribute, read_attribute + delta)
-
- expect do
- subject.save!
- end.not_to exceed_query_limit(control_count)
- end
- end
-
- context 'when destroying' do
- before do
- subject.save!
- end
-
- it 'updates the project statistics' do
- delta0 = reload_stat
-
- subject.destroy!
-
- delta1 = reload_stat
-
- expect(delta1).to eq(delta0 - read_attribute)
- expect(delta1).to be < delta0
- end
-
- it 'schedules a namespace statistics worker' do
- expect(Namespaces::ScheduleAggregationWorker)
- .to receive(:perform_async).once
-
- subject.destroy!
- end
-
- context 'when it is destroyed from the project level' do
- it 'does not update the project statistics' do
- expect(ProjectStatistics)
- .not_to receive(:increment_statistic)
-
- project.update!(pending_delete: true)
- project.destroy!
- end
-
- it 'does not schedule a namespace statistics worker' do
- expect(Namespaces::ScheduleAggregationWorker)
- .not_to receive(:perform_async)
-
- project.update!(pending_delete: true)
- project.destroy!
- end
- end
- end
- end
-
def expect_flush_counter_increments_worker_performed
expect(FlushCounterIncrementsWorker)
.to receive(:perform_in)