debian-mirror-gitlab/spec/finders/admin/plans_finder_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

55 lines
1.2 KiB
Ruby
Raw Normal View History

2021-04-17 20:07:23 +05:30
# 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