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

32 lines
858 B
Ruby
Raw Normal View History

2017-11-27 15:21:18 +00:00
require 'spec_helper'
describe ClustersFinder do
let(:project) { create(:project) }
set(:user) { create(:user) }
describe '#execute' do
let(:enabled_cluster) { create(:cluster, :provided_by_gcp, projects: [project]) }
let(:disabled_cluster) { create(:cluster, :disabled, :provided_by_gcp, :production_environment, projects: [project]) }
2017-11-27 15:21:18 +00:00
subject { described_class.new(project, user, scope).execute }
context 'when scope is all' do
let(:scope) { :all }
it { is_expected.to match_array([enabled_cluster, disabled_cluster]) }
2017-11-27 15:21:18 +00:00
end
context 'when scope is active' do
2017-11-28 13:22:29 +00:00
let(:scope) { :active }
2017-11-27 15:21:18 +00:00
it { is_expected.to match_array([enabled_cluster]) }
2017-11-27 15:21:18 +00:00
end
context 'when scope is inactive' do
2017-11-28 13:22:29 +00:00
let(:scope) { :inactive }
2017-11-27 15:21:18 +00:00
it { is_expected.to match_array([disabled_cluster]) }
2017-11-27 15:21:18 +00:00
end
end
end