diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-05 00:07:31 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-05 00:07:31 +0300 |
commit | 71221554dd9ddf30f73035c89f78164e001aa96d (patch) | |
tree | c56e0b2fc3dd16602183b78cb3f68aed211c5e77 /spec/models/clusters | |
parent | b41cd8cb92d53454b2b160ba922d33801933a9cf (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/clusters')
-rw-r--r-- | spec/models/clusters/cluster_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/models/clusters/cluster_spec.rb b/spec/models/clusters/cluster_spec.rb index 7c419a195cd..807214dcc14 100644 --- a/spec/models/clusters/cluster_spec.rb +++ b/spec/models/clusters/cluster_spec.rb @@ -976,4 +976,38 @@ describe Clusters::Cluster, :use_clean_rails_memory_store_caching do expect(cluster.kubernetes_namespaces).to be_empty end end + + describe '#clusterable' do + subject { cluster.clusterable } + + context 'project type' do + let(:cluster) { create(:cluster, :project) } + + it { is_expected.to eq(cluster.project) } + end + + context 'group type' do + let(:cluster) { create(:cluster, :group) } + + it { is_expected.to eq(cluster.group) } + end + + context 'instance type' do + let(:cluster) { create(:cluster, :instance) } + + it { is_expected.to be_a(Clusters::Instance) } + end + + context 'unknown type' do + let(:cluster) { create(:cluster, :project) } + + before do + allow(cluster).to receive(:cluster_type).and_return('unknown_type') + end + + it 'raises NotImplementedError' do + expect { subject }.to raise_error(NotImplementedError) + end + end + end end |