diff --git a/ee/app/finders/remote_development/organization_cluster_agents_finder.rb b/ee/app/finders/remote_development/organization_cluster_agents_finder.rb index 60487e6a9275839ef402f1e44b71f2374d47ff35..9945a7f036bfe34614833997de69d48ab9d5a2c7 100644 --- a/ee/app/finders/remote_development/organization_cluster_agents_finder.rb +++ b/ee/app/finders/remote_development/organization_cluster_agents_finder.rb @@ -7,8 +7,8 @@ class OrganizationClusterAgentsFinder # @param [User] user # @return [ActiveRecord::Relation] def self.execute(organization:, filter:, user:) - return Clusters::Agent.none unless organization && user.can?(:read_organization_cluster_agent_mapping, - organization) + return Clusters::Agent.none unless organization && + Ability.allowed?(user, :read_organization_cluster_agent_mapping, organization) fetch_agents(filter: filter, organization: organization).ordered_by_name end diff --git a/ee/spec/finders/remote_development/organization_cluster_agents_finder_spec.rb b/ee/spec/finders/remote_development/organization_cluster_agents_finder_spec.rb index bb3038e727c5f068a992ef3d90b83c7fc913669b..32bd2d3d409ca1543213642f2c1ecd5493a3ab2a 100644 --- a/ee/spec/finders/remote_development/organization_cluster_agents_finder_spec.rb +++ b/ee/spec/finders/remote_development/organization_cluster_agents_finder_spec.rb @@ -53,6 +53,14 @@ end end + context 'when user is empty' do + let(:user) { nil } + + it 'returns an empty response' do + expect(response).to eq([]) + end + end + context 'with filter_type set to all' do let(:filter) { :all }