summaryrefslogtreecommitdiff
path: root/spec/models/project_services
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2017-05-08 17:28:05 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2017-05-25 15:03:39 +0200
commit911e1c2d07947bba38856c1e033f344d0753f5cf (patch)
treeb24d6af8bbdc076cab3cd4a6600e6ec40c5a3950 /spec/models/project_services
parent7c7fe22c27820b941af51bdef84c3832dda0683e (diff)
downloadgitlab-ce-911e1c2d07947bba38856c1e033f344d0753f5cf.tar.gz
Fix terminals support for Kubernetes service
It was broken, because we introduced a default namespace, which was not used by terminal methods.
Diffstat (limited to 'spec/models/project_services')
-rw-r--r--spec/models/project_services/kubernetes_service_spec.rb31
1 files changed, 30 insertions, 1 deletions
diff --git a/spec/models/project_services/kubernetes_service_spec.rb b/spec/models/project_services/kubernetes_service_spec.rb
index c1c2f2a7219..57c51ebea7b 100644
--- a/spec/models/project_services/kubernetes_service_spec.rb
+++ b/spec/models/project_services/kubernetes_service_spec.rb
@@ -13,7 +13,7 @@ describe KubernetesService, models: true, caching: true do
let(:discovery_url) { service.api_url + '/api/v1' }
let(:discovery_response) { { body: kube_discovery_body.to_json } }
- let(:pods_url) { service.api_url + "/api/v1/namespaces/#{service.namespace}/pods" }
+ let(:pods_url) { service.api_url + "/api/v1/namespaces/#{service.actual_namespace}/pods" }
let(:pods_response) { { body: kube_pods_body(kube_pod).to_json } }
def stub_kubeclient_discover
@@ -105,6 +105,34 @@ describe KubernetesService, models: true, caching: true do
end
end
+ describe '#actual_namespace' do
+ subject { service.actual_namespace }
+
+ it "returns the default namespace" do
+ is_expected.to eq(service.send(:default_namespace))
+ end
+
+ context 'when namespace is specified' do
+ before do
+ service.namespace = 'my-namespace'
+ end
+
+ it "returns the user-namespace" do
+ is_expected.to eq('my-namespace')
+ end
+ end
+
+ context 'when service is not assigned to project' do
+ before do
+ service.project = nil
+ end
+
+ it "does not return namespace" do
+ is_expected.to be_nil
+ end
+ end
+ end
+
describe '#test' do
before do
stub_kubeclient_discover
@@ -194,6 +222,7 @@ describe KubernetesService, models: true, caching: true do
describe '#terminals' do
let(:environment) { build(:environment, project: project, name: "env", slug: "env-000000") }
+
subject { service.terminals(environment) }
context 'with invalid pods' do