summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/lib/sidebars/your_work/menus/menu_item_examples.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/support/shared_examples/lib/sidebars/your_work/menus/menu_item_examples.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/support/shared_examples/lib/sidebars/your_work/menus/menu_item_examples.rb')
-rw-r--r--spec/support/shared_examples/lib/sidebars/your_work/menus/menu_item_examples.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/support/shared_examples/lib/sidebars/your_work/menus/menu_item_examples.rb b/spec/support/shared_examples/lib/sidebars/your_work/menus/menu_item_examples.rb
new file mode 100644
index 00000000000..19c94a3ba5b
--- /dev/null
+++ b/spec/support/shared_examples/lib/sidebars/your_work/menus/menu_item_examples.rb
@@ -0,0 +1,38 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.shared_examples 'menu item shows pill based on count' do |count|
+ describe '#has_pill?' do
+ context 'when count is zero' do
+ it 'returns false' do
+ allow(user).to receive(count).and_return(0)
+ expect(subject.has_pill?).to eq false
+ end
+ end
+
+ context 'when count is larger than zero' do
+ it 'returns true' do
+ allow(user).to receive(count).and_return(3)
+ expect(subject.has_pill?).to eq true
+ end
+ end
+ end
+
+ describe '#pill_count' do
+ it "returns the #{count} of the user" do
+ allow(user).to receive(count).and_return(123)
+ expect(subject.pill_count).to eq 123
+ end
+
+ it 'memoizes the query' do
+ subject.pill_count
+
+ control = ActiveRecord::QueryRecorder.new do
+ subject.pill_count
+ end
+
+ expect(control.count).to eq 0
+ end
+ end
+end