Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancisco Javier López <fjlopez@gitlab.com>2019-07-19 20:04:33 +0300
committerNick Thomas <nick@gitlab.com>2019-07-19 20:04:33 +0300
commit351bc078ca079a95445b54f01a72c34cf5a946bb (patch)
tree76e6d0ad0378553e3309eddbed7c804c0efa7d94 /spec/lib/gitlab/usage_data_counters
parent2db1317b92a62b8f1b4089c44d85442f0d8263f8 (diff)
Avoid increasing redis counters when usage_ping is disabled
Diffstat (limited to 'spec/lib/gitlab/usage_data_counters')
-rw-r--r--spec/lib/gitlab/usage_data_counters/redis_counter_spec.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/lib/gitlab/usage_data_counters/redis_counter_spec.rb b/spec/lib/gitlab/usage_data_counters/redis_counter_spec.rb
new file mode 100644
index 00000000000..c34ac7867ab
--- /dev/null
+++ b/spec/lib/gitlab/usage_data_counters/redis_counter_spec.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Gitlab::UsageDataCounters::RedisCounter, :clean_gitlab_redis_shared_state do
+ let(:redis_key) { 'foobar' }
+
+ subject { Class.new.extend(described_class) }
+
+ before do
+ stub_application_setting(usage_ping_enabled: setting_value)
+ end
+
+ context 'when usage_ping is disabled' do
+ let(:setting_value) { false }
+
+ it 'counter is not increased' do
+ expect do
+ subject.increment(redis_key)
+ end.not_to change { subject.total_count(redis_key) }
+ end
+ end
+
+ context 'when usage_ping is enabled' do
+ let(:setting_value) { true }
+
+ it 'counter is increased' do
+ expect do
+ subject.increment(redis_key)
+ end.to change { subject.total_count(redis_key) }.by(1)
+ end
+ end
+end