summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2017-11-27 21:48:54 +0900
committerShinya Maeda <shinya@gitlab.com>2017-11-28 20:47:59 +0900
commit1d7e3ef1a55991e057213add556926eb13e0bd48 (patch)
tree42a63fbc0cb956d2207340aa86ba57dd1e39d572 /spec/models
parent5324383dba07d60407a5b947f27695867ad45843 (diff)
downloadgitlab-ce-1d7e3ef1a55991e057213add556926eb13e0bd48.tar.gz
Duplicate spec for Platform::Kubernetes with kubernetes_project
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/ci/pipeline_spec.rb19
-rw-r--r--spec/models/environment_spec.rb25
2 files changed, 35 insertions, 9 deletions
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb
index 3a19a0753e2..c53942ed61c 100644
--- a/spec/models/ci/pipeline_spec.rb
+++ b/spec/models/ci/pipeline_spec.rb
@@ -557,10 +557,23 @@ describe Ci::Pipeline, :mailer do
describe '#has_kubernetes_active?' do
context 'when kubernetes is active' do
- let(:project) { create(:kubernetes_project) }
+ shared_examples 'correct behavior with has_kubernetes_active?' do
+ it 'returns true' do
+ expect(pipeline).to have_kubernetes_active
+ end
+ end
- it 'returns true' do
- expect(pipeline).to have_kubernetes_active
+ context 'when user configured kubernetes from Integration > Kubernetes' do
+ let(:project) { create(:kubernetes_project) }
+
+ it_behaves_like 'correct behavior with has_kubernetes_active?'
+ end
+
+ context 'when user configured kubernetes from CI/CD > Clusters' do
+ let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
+ let(:project) { cluster.project }
+
+ it_behaves_like 'correct behavior with has_kubernetes_active?'
end
end
diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb
index 1ce1d595c60..de030844a28 100644
--- a/spec/models/environment_spec.rb
+++ b/spec/models/environment_spec.rb
@@ -327,15 +327,28 @@ describe Environment do
context 'when the enviroment is available' do
context 'with a deployment service' do
- let(:project) { create(:kubernetes_project) }
+ shared_examples 'correct behavior for has_terminals?' do
+ context 'and a deployment' do
+ let!(:deployment) { create(:deployment, environment: environment) }
+ it { is_expected.to be_truthy }
+ end
- context 'and a deployment' do
- let!(:deployment) { create(:deployment, environment: environment) }
- it { is_expected.to be_truthy }
+ context 'but no deployments' do
+ it { is_expected.to be_falsy }
+ end
end
- context 'but no deployments' do
- it { is_expected.to be_falsy }
+ context 'when user configured kubernetes from Integration > Kubernetes' do
+ let(:project) { create(:kubernetes_project) }
+
+ it_behaves_like 'correct behavior for has_terminals?'
+ end
+
+ context 'when user configured kubernetes from CI/CD > Clusters' do
+ let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
+ let(:project) { cluster.project }
+
+ it_behaves_like 'correct behavior for has_terminals?'
end
end