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:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-04-21 02:50:22 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-04-21 02:50:22 +0300
commit9dc93a4519d9d5d7be48ff274127136236a3adb3 (patch)
tree70467ae3692a0e35e5ea56bcb803eb512a10bedb /spec/support/shared_examples/helpers
parent4b0f34b6d759d6299322b3a54453e930c6121ff0 (diff)
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc43
Diffstat (limited to 'spec/support/shared_examples/helpers')
-rw-r--r--spec/support/shared_examples/helpers/groups_shared_examples.rb53
1 files changed, 53 insertions, 0 deletions
diff --git a/spec/support/shared_examples/helpers/groups_shared_examples.rb b/spec/support/shared_examples/helpers/groups_shared_examples.rb
new file mode 100644
index 00000000000..9c74d25b31f
--- /dev/null
+++ b/spec/support/shared_examples/helpers/groups_shared_examples.rb
@@ -0,0 +1,53 @@
+# frozen_string_literal: true
+
+# This shared_example requires the following variables:
+# - current_user
+# - group
+# - type, the issuable type (ie :issues, :merge_requests)
+# - count_service, the Service used by the specified issuable type
+
+RSpec.shared_examples 'cached issuables count' do
+ subject { helper.cached_issuables_count(group, type: type) }
+
+ before do
+ allow(helper).to receive(:current_user) { current_user }
+ allow(count_service).to receive(:new).and_call_original
+ end
+
+ it 'calls the correct service class' do
+ subject
+ expect(count_service).to have_received(:new).with(group, current_user)
+ end
+
+ it 'returns all digits for count value under 1000' do
+ allow_next_instance_of(count_service) do |service|
+ allow(service).to receive(:count).and_return(999)
+ end
+
+ expect(subject).to eq('999')
+ end
+
+ it 'returns truncated digits for count value over 1000' do
+ allow_next_instance_of(count_service) do |service|
+ allow(service).to receive(:count).and_return(2300)
+ end
+
+ expect(subject).to eq('2.3k')
+ end
+
+ it 'returns truncated digits for count value over 10000' do
+ allow_next_instance_of(count_service) do |service|
+ allow(service).to receive(:count).and_return(12560)
+ end
+
+ expect(subject).to eq('12.6k')
+ end
+
+ it 'returns truncated digits for count value over 100000' do
+ allow_next_instance_of(count_service) do |service|
+ allow(service).to receive(:count).and_return(112560)
+ end
+
+ expect(subject).to eq('112.6k')
+ end
+end