From cdcc196c1fb602303a4fae36a584005ef212b9c8 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Sat, 26 Aug 2017 11:17:47 +0200 Subject: Make it possible to access deployment details from pipeline --- spec/models/ci/pipeline_spec.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'spec/models/ci/pipeline_spec.rb') diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index ac75c6501ee..eea494a22b6 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -27,6 +27,14 @@ describe Ci::Pipeline, :mailer do it { is_expected.to respond_to :git_author_email } it { is_expected.to respond_to :short_sha } + describe '#project_deployment_variables' do + it 'delegates deployment variables to project' do + expect(pipeline) + .to delegate_method(:deployment_variables) + .to(:project).with_prefix + end + end + describe '#source' do context 'when creating new pipeline' do let(:pipeline) do -- cgit v1.2.1 From 326dc7da3bb7e6537095277dc8ee8ae880774b62 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Sat, 26 Aug 2017 12:45:36 +0200 Subject: Check if kubernetes required before creating a job --- spec/models/ci/pipeline_spec.rb | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'spec/models/ci/pipeline_spec.rb') diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index eea494a22b6..b298b0b1354 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -542,6 +542,46 @@ describe Ci::Pipeline, :mailer do end end + context 'when kubernetes is configured' do + let(:project) { create(:kubernetes_project) } + + before do + create(:ci_variable, key: 'KUBE_DOMAIN', + protected: false, + project: project) + end + + describe '#variables' do + it 'returns kubernetes-related variables' do + variables = pipeline.variables.map { |v| v.fetch(:key) } + + expect(variables).to include 'KUBECONFIG', 'KUBE_DOMAIN' + end + end + + describe '#has_kubernetes_available?' do + it 'returns true' do + expect(pipeline).to have_kubernetes_available + end + end + end + + context 'when kubernetes is not configured' do + describe '#variables' do + it 'does not return kubernetes related variables' do + variables = pipeline.variables.map { |v| v.fetch(:key) } + + expect(variables).not_to include 'KUBECONFIG', 'KUBE_DOMAIN' + end + end + + describe '#has_kubernetes_available?' do + it 'returns false' do + expect(pipeline).not_to have_kubernetes_available + end + end + end + describe '#has_stage_seeds?' do context 'when pipeline has stage seeds' do subject { build(:ci_pipeline_with_one_job) } -- cgit v1.2.1 From 96a7e1628a895dcc39e6299052cb78e62d59459d Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Thu, 31 Aug 2017 13:24:03 +0200 Subject: Refactor context variables in pipeline model class --- spec/models/ci/pipeline_spec.rb | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'spec/models/ci/pipeline_spec.rb') diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index b298b0b1354..11838b1ee07 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -27,14 +27,6 @@ describe Ci::Pipeline, :mailer do it { is_expected.to respond_to :git_author_email } it { is_expected.to respond_to :short_sha } - describe '#project_deployment_variables' do - it 'delegates deployment variables to project' do - expect(pipeline) - .to delegate_method(:deployment_variables) - .to(:project).with_prefix - end - end - describe '#source' do context 'when creating new pipeline' do let(:pipeline) do @@ -551,9 +543,9 @@ describe Ci::Pipeline, :mailer do project: project) end - describe '#variables' do + describe '#context_variables' do it 'returns kubernetes-related variables' do - variables = pipeline.variables.map { |v| v.fetch(:key) } + variables = pipeline.context_variables.map { |v| v.fetch(:key) } expect(variables).to include 'KUBECONFIG', 'KUBE_DOMAIN' end @@ -567,9 +559,9 @@ describe Ci::Pipeline, :mailer do end context 'when kubernetes is not configured' do - describe '#variables' do + describe '#context_variables' do it 'does not return kubernetes related variables' do - variables = pipeline.variables.map { |v| v.fetch(:key) } + variables = pipeline.context_variables.map { |v| v.fetch(:key) } expect(variables).not_to include 'KUBECONFIG', 'KUBE_DOMAIN' end -- cgit v1.2.1 From 73d0cafbe4acf5a14ec196c3cfb38be4e84b67d9 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Fri, 1 Sep 2017 12:58:22 +0200 Subject: Check if service active when using CI/CD kubernetes policy --- spec/models/ci/pipeline_spec.rb | 36 ++++++------------------------------ 1 file changed, 6 insertions(+), 30 deletions(-) (limited to 'spec/models/ci/pipeline_spec.rb') diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 7898bdbe2ff..cf4896ff188 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -546,42 +546,18 @@ describe Ci::Pipeline, :mailer do end end - context 'when kubernetes is configured' do - let(:project) { create(:kubernetes_project) } + describe '#has_kubernetes_active?' do + context 'when kubernetes is configured' do + let(:project) { create(:kubernetes_project) } - before do - create(:ci_variable, key: 'KUBE_DOMAIN', - protected: false, - project: project) - end - - describe '#context_variables' do - it 'returns kubernetes-related variables' do - variables = pipeline.context_variables.map { |v| v.fetch(:key) } - - expect(variables).to include 'KUBECONFIG', 'KUBE_DOMAIN' - end - end - - describe '#has_kubernetes_available?' do it 'returns true' do - expect(pipeline).to have_kubernetes_available - end - end - end - - context 'when kubernetes is not configured' do - describe '#context_variables' do - it 'does not return kubernetes related variables' do - variables = pipeline.context_variables.map { |v| v.fetch(:key) } - - expect(variables).not_to include 'KUBECONFIG', 'KUBE_DOMAIN' + expect(pipeline).to have_kubernetes_active end end - describe '#has_kubernetes_available?' do + context 'when kubernetes is not configured' do it 'returns false' do - expect(pipeline).not_to have_kubernetes_available + expect(pipeline).not_to have_kubernetes_active end end end -- cgit v1.2.1 From fc4fb6e4d212d5cf406a08c96ba8c423477a5408 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Fri, 1 Sep 2017 13:03:43 +0200 Subject: Change CI/CD kubernetes policy keyword to `active` --- spec/models/ci/pipeline_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'spec/models/ci/pipeline_spec.rb') diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index cf4896ff188..84656ffe0b9 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -547,7 +547,7 @@ describe Ci::Pipeline, :mailer do end describe '#has_kubernetes_active?' do - context 'when kubernetes is configured' do + context 'when kubernetes is active' do let(:project) { create(:kubernetes_project) } it 'returns true' do @@ -555,7 +555,7 @@ describe Ci::Pipeline, :mailer do end end - context 'when kubernetes is not configured' do + context 'when kubernetes is not active' do it 'returns false' do expect(pipeline).not_to have_kubernetes_active end -- cgit v1.2.1