summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancisco Javier López <fjlopez@gitlab.com>2019-07-17 19:49:46 +0200
committerFrancisco Javier López <fjlopez@gitlab.com>2019-07-17 19:49:46 +0200
commit26817a920f6ae8ad22f25a055542969caa0d05e5 (patch)
tree3dcbbac89a4d10e22f2b5d5375812f2785e0db91
parentf03805c0b28a8df846454e4c442719969cda6853 (diff)
downloadgitlab-ce-fj-refactor-web-ide-counter.tar.gz
Code review comments appliedfj-refactor-web-ide-counter
-rw-r--r--lib/gitlab/usage_data_counters/web_ide_counter.rb10
-rw-r--r--spec/lib/gitlab/usage_data_counters/web_ide_counter_spec.rb5
2 files changed, 6 insertions, 9 deletions
diff --git a/lib/gitlab/usage_data_counters/web_ide_counter.rb b/lib/gitlab/usage_data_counters/web_ide_counter.rb
index 10d94150afc..6fbffb94c58 100644
--- a/lib/gitlab/usage_data_counters/web_ide_counter.rb
+++ b/lib/gitlab/usage_data_counters/web_ide_counter.rb
@@ -5,17 +5,15 @@ module Gitlab
class WebIdeCounter
extend RedisCounter
+ COMMITS_COUNT_KEY = 'WEB_IDE_COMMITS_COUNT'
+
class << self
def increment_commits_count
- increment(redis_commits_key)
+ increment(COMMITS_COUNT_KEY)
end
def total_commits_count
- total_count(redis_commits_key)
- end
-
- def redis_commits_key
- 'WEB_IDE_COMMITS_COUNT'
+ total_count(COMMITS_COUNT_KEY)
end
end
end
diff --git a/spec/lib/gitlab/usage_data_counters/web_ide_counter_spec.rb b/spec/lib/gitlab/usage_data_counters/web_ide_counter_spec.rb
index 48da889a5d8..fa0cf15e1b2 100644
--- a/spec/lib/gitlab/usage_data_counters/web_ide_counter_spec.rb
+++ b/spec/lib/gitlab/usage_data_counters/web_ide_counter_spec.rb
@@ -7,14 +7,13 @@ describe Gitlab::UsageDataCounters::WebIdeCounter, :clean_gitlab_redis_shared_st
it 'increments the web ide commits counter by 1' do
expect do
described_class.increment_commits_count
- end.to change { described_class.total_commits_count }.from(0).to(1)
+ end.to change { described_class.total_commits_count }.by(1)
end
end
describe '.total_commits_count' do
it 'returns the total amount of web ide commits' do
- described_class.increment_commits_count
- described_class.increment_commits_count
+ 2.times { described_class.increment_commits_count }
expect(described_class.total_commits_count).to eq(2)
end