diff options
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/ci/pipeline_spec.rb | 19 | ||||
-rw-r--r-- | spec/models/environment_spec.rb | 25 |
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 |