diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-20 11:43:02 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-20 11:43:02 +0300 |
commit | d9ab72d6080f594d0b3cae15f14b3ef2c6c638cb (patch) | |
tree | 2341ef426af70ad1e289c38036737e04b0aa5007 /spec/finders/clusters | |
parent | d6e514dd13db8947884cd58fe2a9c2a063400a9b (diff) |
Add latest changes from gitlab-org/gitlab@14-4-stable-eev14.4.0-rc42
Diffstat (limited to 'spec/finders/clusters')
-rw-r--r-- | spec/finders/clusters/agents_finder_spec.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/finders/clusters/agents_finder_spec.rb b/spec/finders/clusters/agents_finder_spec.rb new file mode 100644 index 00000000000..0996d76b723 --- /dev/null +++ b/spec/finders/clusters/agents_finder_spec.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Clusters::AgentsFinder do + describe '#execute' do + let(:project) { create(:project) } + let(:user) { create(:user, maintainer_projects: [project]) } + + let!(:matching_agent) { create(:cluster_agent, project: project) } + let!(:wrong_project) { create(:cluster_agent) } + + subject { described_class.new(project, user).execute } + + it { is_expected.to contain_exactly(matching_agent) } + + context 'user does not have permission' do + let(:user) { create(:user, developer_projects: [project]) } + + it { is_expected.to be_empty } + end + + context 'filtering by name' do + let(:params) { Hash(name: name_param) } + + subject { described_class.new(project, user, params: params).execute } + + context 'name does not match' do + let(:name_param) { 'other-name' } + + it { is_expected.to be_empty } + end + + context 'name does match' do + let(:name_param) { matching_agent.name } + + it { is_expected.to contain_exactly(matching_agent) } + end + end + end +end |