Commit e79bebec authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch '5911-extract-ee-specific-files-lines-for-spec-models-clusters' into 'master'

Resolve "Extract EE specific files/lines for spec/models/clusters"

Closes #5911

See merge request gitlab-org/gitlab-ee!5638
parents efd8cff2 87a62563
require 'spec_helper'
describe Clusters::Cluster do
it { is_expected.to include_module(HasEnvironmentScope) }
describe 'validation' do
subject { cluster.valid? }
context 'when validates unique_environment_scope' do
let(:project) { create(:project) }
before do
create(:cluster, projects: [project], environment_scope: 'product/*')
end
context 'when identical environment scope exists in project' do
let(:cluster) { build(:cluster, projects: [project], environment_scope: 'product/*') }
it { is_expected.to be_falsey }
end
context 'when identical environment scope does not exist in project' do
let(:cluster) { build(:cluster, projects: [project], environment_scope: '*') }
it { is_expected.to be_truthy }
end
context 'when identical environment scope exists in different project' do
let(:project2) { create(:project) }
let(:cluster) { build(:cluster, projects: [project2], environment_scope: 'product/*') }
it { is_expected.to be_truthy }
end
end
end
end
require 'spec_helper'
describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching do
include KubernetesHelpers
include ReactiveCachingHelpers
describe '#calculate_reactive_cache' do
subject { service.calculate_reactive_cache }
let!(:cluster) { create(:cluster, :project, enabled: true, platform_kubernetes: service) }
let(:service) { create(:cluster_platform_kubernetes, :configured) }
context 'when kubernetes responds with valid pods and deployments' do
before do
stub_kubeclient_pods
stub_kubeclient_deployments
end
it { is_expected.to eq(pods: [kube_pod], deployments: [kube_deployment]) }
end
context 'when kubernetes responds with 404s' do
before do
stub_kubeclient_pods(status: 404)
stub_kubeclient_deployments(status: 404)
end
it { is_expected.to eq(pods: [], deployments: []) }
end
end
end
......@@ -14,7 +14,6 @@ describe Clusters::Cluster do
it { is_expected.to delegate_method(:status_name).to(:provider) }
it { is_expected.to delegate_method(:on_creation?).to(:provider) }
it { is_expected.to respond_to :project }
it { is_expected.to include_module(HasEnvironmentScope) }
describe '.enabled' do
subject { described_class.enabled }
......@@ -168,33 +167,6 @@ describe Clusters::Cluster do
it { expect(cluster.update(enabled: false)).to be_truthy }
end
end
context 'when validates unique_environment_scope' do
let(:project) { create(:project) }
before do
create(:cluster, projects: [project], environment_scope: 'product/*')
end
context 'when identical environment scope exists in project' do
let(:cluster) { build(:cluster, projects: [project], environment_scope: 'product/*') }
it { is_expected.to be_falsey }
end
context 'when identical environment scope does not exist in project' do
let(:cluster) { build(:cluster, projects: [project], environment_scope: '*') }
it { is_expected.to be_truthy }
end
context 'when identical environment scope exists in different project' do
let(:project2) { create(:project) }
let(:cluster) { build(:cluster, projects: [project2], environment_scope: 'product/*') }
it { is_expected.to be_truthy }
end
end
end
describe '#provider' do
......
......@@ -245,7 +245,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
stub_kubeclient_deployments
end
it { is_expected.to eq(pods: [kube_pod], deployments: [kube_deployment]) }
it { is_expected.to include(pods: [kube_pod]) }
end
context 'when kubernetes responds with 500s' do
......@@ -263,7 +263,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
stub_kubeclient_deployments(status: 404)
end
it { is_expected.to eq(pods: [], deployments: []) }
it { is_expected.to include(pods: []) }
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment