2019-10-16 05:07:51 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
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
|
2017-12-01 10:27:53 -05:00
|
|
|
let(:enabled_cluster) { create(:cluster, :provided_by_gcp, projects: [project]) }
|
2018-03-21 10:59:40 -04:00
|
|
|
let(:disabled_cluster) { create(:cluster, :disabled, :provided_by_gcp, :production_environment, projects: [project]) }
|
2017-11-27 10:21:18 -05:00
|
|
|
|
|
|
|
subject { described_class.new(project, user, scope).execute }
|
|
|
|
|
|
|
|
context 'when scope is all' do
|
|
|
|
let(:scope) { :all }
|
|
|
|
|
2017-12-01 10:27:53 -05:00
|
|
|
it { is_expected.to match_array([enabled_cluster, disabled_cluster]) }
|
2017-11-27 10:21:18 -05:00
|
|
|
end
|
|
|
|
|
2017-12-01 10:27:53 -05:00
|
|
|
context 'when scope is active' do
|
2017-11-28 08:22:29 -05:00
|
|
|
let(:scope) { :active }
|
2017-11-27 10:21:18 -05:00
|
|
|
|
2017-12-01 10:27:53 -05:00
|
|
|
it { is_expected.to match_array([enabled_cluster]) }
|
2017-11-27 10:21:18 -05:00
|
|
|
end
|
|
|
|
|
2017-12-01 10:27:53 -05:00
|
|
|
context 'when scope is inactive' do
|
2017-11-28 08:22:29 -05:00
|
|
|
let(:scope) { :inactive }
|
2017-11-27 10:21:18 -05:00
|
|
|
|
2017-12-01 10:27:53 -05:00
|
|
|
it { is_expected.to match_array([disabled_cluster]) }
|
2017-11-27 10:21:18 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|