summaryrefslogtreecommitdiff
path: root/spec/finders/admin
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-03-16 18:18:33 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-03-16 18:18:33 +0000
commitf64a639bcfa1fc2bc89ca7db268f594306edfd7c (patch)
treea2c3c2ebcc3b45e596949db485d6ed18ffaacfa1 /spec/finders/admin
parentbfbc3e0d6583ea1a91f627528bedc3d65ba4b10f (diff)
downloadgitlab-ce-f64a639bcfa1fc2bc89ca7db268f594306edfd7c.tar.gz
Add latest changes from gitlab-org/gitlab@13-10-stable-eev13.10.0-rc40
Diffstat (limited to 'spec/finders/admin')
-rw-r--r--spec/finders/admin/plans_finder_spec.rb54
1 files changed, 54 insertions, 0 deletions
diff --git a/spec/finders/admin/plans_finder_spec.rb b/spec/finders/admin/plans_finder_spec.rb
new file mode 100644
index 00000000000..9ea5944147c
--- /dev/null
+++ b/spec/finders/admin/plans_finder_spec.rb
@@ -0,0 +1,54 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Admin::PlansFinder do
+ let_it_be(:plan1) { create(:plan, name: 'plan1') }
+ let_it_be(:plan2) { create(:plan, name: 'plan2') }
+
+ describe '#execute' do
+ context 'with no params' do
+ it 'returns all plans' do
+ found = described_class.new.execute
+
+ expect(found).to match_array([plan1, plan2])
+ end
+ end
+
+ context 'with missing name in params' do
+ before do
+ @params = { title: 'plan2' }
+ end
+
+ it 'returns all plans' do
+ found = described_class.new(@params).execute
+
+ expect(found).to match_array([plan1, plan2])
+ end
+ end
+
+ context 'with existing name in params' do
+ before do
+ @params = { name: 'plan2' }
+ end
+
+ it 'returns the plan' do
+ found = described_class.new(@params).execute
+
+ expect(found).to match(plan2)
+ end
+ end
+
+ context 'with non-existing name in params' do
+ before do
+ @params = { name: 'non-existing-plan' }
+ end
+
+ it 'returns nil' do
+ found = described_class.new(@params).execute
+
+ expect(found).to be_nil
+ end
+ end
+ end
+end