gitlab-org--gitlab-foss/spec/finders/clusters_finder_spec.rb

34 lines
754 B
Ruby
Raw Normal View History

2017-11-27 10:21:18 -05:00
require 'spec_helper'
describe ClustersFinder do
let(:project) { create(:project) }
set(:user) { create(:user) }
describe '#execute' do
before do
create_list(:cluster, 2, :provided_by_gcp, projects: [project])
project.clusters.last.enabled = false
end
subject { described_class.new(project, user, scope).execute }
context 'when scope is all' do
let(:scope) { :all }
2017-11-28 08:22:29 -05:00
it { is_expected.to eq(project.clusters) }
2017-11-27 10:21:18 -05:00
end
context 'when scope is enabled' do
2017-11-28 08:22:29 -05:00
let(:scope) { :active }
2017-11-27 10:21:18 -05:00
2017-11-28 08:22:29 -05:00
it { is_expected.to eq(project.clusters.enabled) }
2017-11-27 10:21:18 -05:00
end
context 'when scope is disabled' do
2017-11-28 08:22:29 -05:00
let(:scope) { :inactive }
2017-11-27 10:21:18 -05:00
2017-11-28 08:22:29 -05:00
it { is_expected.to eq(project.clusters.disabled) }
2017-11-27 10:21:18 -05:00
end
end
end