clusters_finder_spec.rb 858 Bytes
Newer Older
1 2 3 4 5 6 7
require 'spec_helper'

describe ClustersFinder do
  let(:project) { create(:project) }
  set(:user) { create(:user) }

  describe '#execute' do
8
    let(:enabled_cluster) { create(:cluster, :provided_by_gcp, projects: [project]) }
9
    let(:disabled_cluster) { create(:cluster, :disabled, :provided_by_gcp, :production_environment, projects: [project]) }
10 11 12 13 14 15

    subject { described_class.new(project, user, scope).execute }

    context 'when scope is all' do
      let(:scope) { :all }

16
      it { is_expected.to match_array([enabled_cluster, disabled_cluster]) }
17 18
    end

19
    context 'when scope is active' do
Matija Čupić's avatar
Matija Čupić committed
20
      let(:scope) { :active }
21

22
      it { is_expected.to match_array([enabled_cluster]) }
23 24
    end

25
    context 'when scope is inactive' do
Matija Čupić's avatar
Matija Čupić committed
26
      let(:scope) { :inactive }
27

28
      it { is_expected.to match_array([disabled_cluster]) }
29 30 31
    end
  end
end