summaryrefslogtreecommitdiff
path: root/spec/models/concerns/counter_attribute_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-01-18 19:00:14 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-18 19:00:14 +0000
commit05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch)
tree11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /spec/models/concerns/counter_attribute_spec.rb
parentec73467c23693d0db63a797d10194da9e72a74af (diff)
downloadgitlab-ce-05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2.tar.gz
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'spec/models/concerns/counter_attribute_spec.rb')
-rw-r--r--spec/models/concerns/counter_attribute_spec.rb44
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/models/concerns/counter_attribute_spec.rb b/spec/models/concerns/counter_attribute_spec.rb
index 1dd9b78d642..c8224c64ba2 100644
--- a/spec/models/concerns/counter_attribute_spec.rb
+++ b/spec/models/concerns/counter_attribute_spec.rb
@@ -37,6 +37,50 @@ RSpec.describe CounterAttribute, :counter_attribute, :clean_gitlab_redis_shared_
end
end
+ describe '#initiate_refresh!' do
+ context 'when counter attribute is enabled' do
+ let(:attribute) { :build_artifacts_size }
+
+ it 'initiates refresh on the BufferedCounter' do
+ expect_next_instance_of(Gitlab::Counters::BufferedCounter, model, attribute) do |counter|
+ expect(counter).to receive(:initiate_refresh!)
+ end
+
+ model.initiate_refresh!(attribute)
+ end
+ end
+
+ context 'when counter attribute is not enabled' do
+ let(:attribute) { :snippets_size }
+
+ it 'raises error' do
+ expect { model.initiate_refresh!(attribute) }.to raise_error(ArgumentError)
+ end
+ end
+ end
+
+ describe '#finalize_refresh' do
+ let(:attribute) { :build_artifacts_size }
+
+ context 'when counter attribute is enabled' do
+ it 'initiates refresh on the BufferedCounter' do
+ expect_next_instance_of(Gitlab::Counters::BufferedCounter, model, attribute) do |counter|
+ expect(counter).to receive(:finalize_refresh)
+ end
+
+ model.finalize_refresh(attribute)
+ end
+ end
+
+ context 'when counter attribute is not enabled' do
+ let(:attribute) { :snippets_size }
+
+ it 'raises error' do
+ expect { model.finalize_refresh(attribute) }.to raise_error(ArgumentError)
+ end
+ end
+ end
+
describe '#counter' do
using RSpec::Parameterized::TableSyntax