diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-18 11:17:02 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-18 11:17:02 +0300 |
commit | b39512ed755239198a9c294b6a45e65c05900235 (patch) | |
tree | d234a3efade1de67c46b9e5a38ce813627726aa7 /spec/finders/fork_targets_finder_spec.rb | |
parent | d31474cf3b17ece37939d20082b07f6657cc79a9 (diff) |
Add latest changes from gitlab-org/gitlab@15-3-stable-eev15.3.0-rc42
Diffstat (limited to 'spec/finders/fork_targets_finder_spec.rb')
-rw-r--r-- | spec/finders/fork_targets_finder_spec.rb | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/spec/finders/fork_targets_finder_spec.rb b/spec/finders/fork_targets_finder_spec.rb index fe5b50ef030..1acc38bb492 100644 --- a/spec/finders/fork_targets_finder_spec.rb +++ b/spec/finders/fork_targets_finder_spec.rb @@ -5,27 +5,27 @@ require 'spec_helper' RSpec.describe ForkTargetsFinder do subject(:finder) { described_class.new(project, user) } - let(:project) { create(:project, namespace: create(:group)) } - let(:user) { create(:user) } - let!(:maintained_group) do + let_it_be(:project) { create(:project, namespace: create(:group)) } + let_it_be(:user) { create(:user) } + let_it_be(:maintained_group) do create(:group).tap { |g| g.add_maintainer(user) } end - let!(:owned_group) do + let_it_be(:owned_group) do create(:group).tap { |g| g.add_owner(user) } end - let!(:developer_group) do + let_it_be(:developer_group) do create(:group, project_creation_level: ::Gitlab::Access::DEVELOPER_MAINTAINER_PROJECT_ACCESS).tap do |g| g.add_developer(user) end end - let!(:reporter_group) do + let_it_be(:reporter_group) do create(:group).tap { |g| g.add_reporter(user) } end - let!(:guest_group) do + let_it_be(:guest_group) do create(:group).tap { |g| g.add_guest(user) } end @@ -33,7 +33,7 @@ RSpec.describe ForkTargetsFinder do project.namespace.add_owner(user) end - describe '#execute' do + shared_examples 'returns namespaces and groups' do it 'returns all user manageable namespaces' do expect(finder.execute).to match_array([user.namespace, maintained_group, owned_group, project.namespace, developer_group]) end @@ -46,4 +46,28 @@ RSpec.describe ForkTargetsFinder do expect(finder.execute(only_groups: true)).to include(a_kind_of(Group)) end end + + describe '#execute' do + it_behaves_like 'returns namespaces and groups' + + context 'when search is provided' do + it 'filters the targets by the param' do + expect(finder.execute(search: maintained_group.path)).to eq([maintained_group]) + end + end + + context 'when searchable_fork_targets feature flag is disabled' do + before do + stub_feature_flags(searchable_fork_targets: false) + end + + it_behaves_like 'returns namespaces and groups' + + context 'when search is provided' do + it 'ignores the param and returns all user manageable namespaces' do + expect(finder.execute).to match_array([user.namespace, maintained_group, owned_group, project.namespace, developer_group]) + end + end + end + end end |