Commit fd4faf34 authored by Tiger's avatar Tiger

Move Clusters::AgentsFinder to core

parent dbf27167
...@@ -22,7 +22,7 @@ module Clusters ...@@ -22,7 +22,7 @@ module Clusters
attr_reader :project, :current_user, :params attr_reader :project, :current_user, :params
def can_read_cluster_agents? def can_read_cluster_agents?
project.feature_available?(:cluster_agents) && current_user.can?(:read_cluster, project) current_user.can?(:read_cluster, project)
end end
end end
end end
...@@ -6,25 +6,14 @@ RSpec.describe Clusters::AgentsFinder do ...@@ -6,25 +6,14 @@ RSpec.describe Clusters::AgentsFinder do
describe '#execute' do describe '#execute' do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:user) { create(:user, maintainer_projects: [project]) } let(:user) { create(:user, maintainer_projects: [project]) }
let(:feature_available) { true }
let!(:matching_agent) { create(:cluster_agent, project: project) } let!(:matching_agent) { create(:cluster_agent, project: project) }
let!(:wrong_project) { create(:cluster_agent) } let!(:wrong_project) { create(:cluster_agent) }
subject { described_class.new(project, user).execute } subject { described_class.new(project, user).execute }
before do
stub_licensed_features(cluster_agents: feature_available)
end
it { is_expected.to contain_exactly(matching_agent) } it { is_expected.to contain_exactly(matching_agent) }
context 'feature is not available' do
let(:feature_available) { false }
it { is_expected.to be_empty }
end
context 'user does not have permission' do context 'user does not have permission' do
let(:user) { create(:user, developer_projects: [project]) } let(:user) { create(:user, developer_projects: [project]) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment