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
path: root/spec/lib
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2019-08-19 17:45:24 +0300
committerNick Thomas <nick@gitlab.com>2019-08-19 17:45:24 +0300
commit3028cd687a256b593272248e50a3174811594e64 (patch)
tree5777662f6eae8e530912a8fad12bd23d2bc748fc /spec/lib
parent4d4e88df01554336daf245a68653b80ca00989a5 (diff)
parentf53112de5931144ac74819f87c227f06e115ba58 (diff)
Merge branch '39-count-unique-users-for-more-accurate-smau-reporting' into 'master'
Allow UsageData.count to use count_by: See merge request gitlab-org/gitlab-ce!30770
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/usage_data_spec.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/spec/lib/gitlab/usage_data_spec.rb b/spec/lib/gitlab/usage_data_spec.rb
index 9bbd9394d57..64254674157 100644
--- a/spec/lib/gitlab/usage_data_spec.rb
+++ b/spec/lib/gitlab/usage_data_spec.rb
@@ -266,6 +266,12 @@ describe Gitlab::UsageData do
expect(described_class.count(relation)).to eq(1)
end
+ it 'returns the count for count_by when provided' do
+ allow(relation).to receive(:count).with(:creator_id).and_return(2)
+
+ expect(described_class.count(relation, count_by: :creator_id)).to eq(2)
+ end
+
it 'returns the fallback value when counting fails' do
allow(relation).to receive(:count).and_raise(ActiveRecord::StatementInvalid.new(''))