2019-07-07 11:18:12 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe ClustersHelper do
|
|
|
|
describe '#has_rbac_enabled?' do
|
|
|
|
context 'when kubernetes platform has been created' do
|
|
|
|
let(:platform_kubernetes) { build_stubbed(:cluster_platform_kubernetes) }
|
|
|
|
let(:cluster) { build_stubbed(:cluster, :provided_by_gcp, platform_kubernetes: platform_kubernetes) }
|
|
|
|
|
|
|
|
it 'returns kubernetes platform value' do
|
|
|
|
expect(helper.has_rbac_enabled?(cluster)).to be_truthy
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when kubernetes platform has not been created yet' do
|
|
|
|
let(:cluster) { build_stubbed(:cluster, :providing_by_gcp) }
|
|
|
|
|
|
|
|
it 'delegates to cluster provider' do
|
|
|
|
expect(helper.has_rbac_enabled?(cluster)).to be_truthy
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when ABAC cluster is created' do
|
|
|
|
let(:provider) { build_stubbed(:cluster_provider_gcp, :abac_enabled) }
|
|
|
|
let(:cluster) { build_stubbed(:cluster, :providing_by_gcp, provider_gcp: provider) }
|
|
|
|
|
|
|
|
it 'delegates to cluster provider' do
|
|
|
|
expect(helper.has_rbac_enabled?(cluster)).to be_falsy
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-12-26 22:10:19 +05:30
|
|
|
|
|
|
|
describe '#create_new_cluster_label' do
|
|
|
|
subject { helper.create_new_cluster_label(provider: provider) }
|
|
|
|
|
|
|
|
context 'GCP provider' do
|
|
|
|
let(:provider) { 'gcp' }
|
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
it { is_expected.to eq('Create new cluster on GKE') }
|
2019-12-26 22:10:19 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context 'AWS provider' do
|
|
|
|
let(:provider) { 'aws' }
|
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
it { is_expected.to eq('Create new cluster on EKS') }
|
2019-12-26 22:10:19 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context 'other provider' do
|
|
|
|
let(:provider) { 'other' }
|
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
it { is_expected.to eq('Create new cluster') }
|
2019-12-26 22:10:19 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context 'no provider' do
|
|
|
|
let(:provider) { nil }
|
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
it { is_expected.to eq('Create new cluster') }
|
2019-12-26 22:10:19 +05:30
|
|
|
end
|
|
|
|
end
|
2019-07-07 11:18:12 +05:30
|
|
|
end
|