Commit 86892ebc authored by Robert Speicher's avatar Robert Speicher

Merge branch '6516-extract-ee-specific-files-lines-for-spec-models-project_services' into 'master'

Extract EE specific files/lines for spec/models/project_services

See merge request gitlab-org/gitlab-ee!10023
parents 9893e227 9911e826
......@@ -66,4 +66,46 @@ describe KubernetesService, models: true, use_clean_rails_memory_store_caching:
it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
end
describe '#calculate_reactive_cache' do
let(:project) { create(:kubernetes_project) }
let(:service) { project.deployment_platform }
subject { service.calculate_reactive_cache }
context 'when service is inactive' do
before do
service.active = false
end
it { is_expected.to be_nil }
end
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 500s' do
before do
stub_kubeclient_pods(status: 500)
stub_kubeclient_deployments(status: 500)
end
it { expect { subject }.to raise_error(Kubeclient::HttpError) }
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
......@@ -357,19 +357,19 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do
it { is_expected.to be_nil }
end
context 'when kubernetes responds with valid pods and deployments' do
context 'when kubernetes responds with valid pods' do
before do
stub_kubeclient_pods
stub_kubeclient_deployments
stub_kubeclient_deployments # Used by EE
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
before do
stub_kubeclient_pods(status: 500)
stub_kubeclient_deployments(status: 500)
stub_kubeclient_deployments(status: 500) # Used by EE
end
it { expect { subject }.to raise_error(Kubeclient::HttpError) }
......@@ -378,48 +378,10 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do
context 'when kubernetes responds with 404s' do
before do
stub_kubeclient_pods(status: 404)
stub_kubeclient_deployments(status: 404)
stub_kubeclient_deployments(status: 404) # Used by EE
end
it { is_expected.to eq(pods: [], deployments: []) }
end
end
describe "#deprecated?" do
let(:kubernetes_service) { create(:kubernetes_service) }
context 'with an active kubernetes service' do
it 'should return false' do
expect(kubernetes_service.deprecated?).to be_falsy
end
end
context 'with a inactive kubernetes service' do
it 'should return true' do
kubernetes_service.update_attribute(:active, false)
expect(kubernetes_service.deprecated?).to be_truthy
end
end
end
describe "#deprecation_message" do
let(:kubernetes_service) { create(:kubernetes_service) }
it 'should indicate the service is deprecated' do
expect(kubernetes_service.deprecation_message).to match(/Kubernetes service integration has been deprecated/)
end
context 'if the services is active' do
it 'should return a message' do
expect(kubernetes_service.deprecation_message).to match(/Your Kubernetes cluster information on this page is still editable/)
end
end
context 'if the service is not active' do
it 'should return a message' do
kubernetes_service.update_attribute(:active, false)
expect(kubernetes_service.deprecation_message).to match(/Fields on this page are now uneditable/)
end
it { is_expected.to include(pods: []) }
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