2019-12-21 20:55:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe ClustersFinder do
|
|
|
|
let(:project) { create(:project) }
|
2020-01-01 13:55:28 +05:30
|
|
|
|
2020-03-09 13:42:32 +05:30
|
|
|
let_it_be(:user) { create(:user) }
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
describe '#execute' do
|
|
|
|
let(:enabled_cluster) { create(:cluster, :provided_by_gcp, projects: [project]) }
|
2018-05-01 15:08:00 +05:30
|
|
|
let(:disabled_cluster) { create(:cluster, :disabled, :provided_by_gcp, :production_environment, projects: [project]) }
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
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]) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when scope is active' do
|
|
|
|
let(:scope) { :active }
|
|
|
|
|
|
|
|
it { is_expected.to match_array([enabled_cluster]) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when scope is inactive' do
|
|
|
|
let(:scope) { :inactive }
|
|
|
|
|
|
|
|
it { is_expected.to match_array([disabled_cluster]) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|