Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThong Kuah <tkuah@gitlab.com>2019-02-06 14:05:21 +0300
committerThong Kuah <tkuah@gitlab.com>2019-02-06 14:25:33 +0300
commitd204ec3d37f9fa422876072402f57028231ee2f4 (patch)
tree1beb6c6d4a6df2f59ad98924cb0a7c69e0cfeeea
parente72f24d27be911ffce943929b7ca2f6df7051083 (diff)
Refactor specs to run shared parts only when used
All applications except for Jupyter have the same #set_initial_status, so create a new shared example which we include in all application specs except for juptyer_spec. Juptyer specs already have specs for it's version of #set_initial_status
-rw-r--r--spec/models/clusters/applications/cert_manager_spec.rb1
-rw-r--r--spec/models/clusters/applications/ingress_spec.rb1
-rw-r--r--spec/models/clusters/applications/knative_spec.rb1
-rw-r--r--spec/models/clusters/applications/prometheus_spec.rb1
-rw-r--r--spec/models/clusters/applications/runner_spec.rb1
-rw-r--r--spec/support/shared_examples/models/cluster_application_initial_status.rb29
-rw-r--r--spec/support/shared_examples/models/cluster_application_status_shared_examples.rb24
7 files changed, 34 insertions, 24 deletions
diff --git a/spec/models/clusters/applications/cert_manager_spec.rb b/spec/models/clusters/applications/cert_manager_spec.rb
index 6b1bcce1081..79a06c35459 100644
--- a/spec/models/clusters/applications/cert_manager_spec.rb
+++ b/spec/models/clusters/applications/cert_manager_spec.rb
@@ -5,6 +5,7 @@ describe Clusters::Applications::CertManager do
include_examples 'cluster application core specs', :clusters_applications_cert_managers
include_examples 'cluster application status specs', :clusters_applications_cert_managers
+ include_examples 'cluster application initial status specs'
describe '#install_command' do
let(:cluster_issuer_file) { { "cluster_issuer.yaml": "---\napiVersion: certmanager.k8s.io/v1alpha1\nkind: ClusterIssuer\nmetadata:\n name: letsencrypt-prod\nspec:\n acme:\n server: https://acme-v02.api.letsencrypt.org/directory\n email: admin@example.com\n privateKeySecretRef:\n name: letsencrypt-prod\n http01: {}\n" } }
diff --git a/spec/models/clusters/applications/ingress_spec.rb b/spec/models/clusters/applications/ingress_spec.rb
index 811d0026535..6d48131d1cc 100644
--- a/spec/models/clusters/applications/ingress_spec.rb
+++ b/spec/models/clusters/applications/ingress_spec.rb
@@ -8,6 +8,7 @@ describe Clusters::Applications::Ingress do
include_examples 'cluster application core specs', :clusters_applications_ingress
include_examples 'cluster application status specs', :clusters_applications_ingress
include_examples 'cluster application helm specs', :clusters_applications_ingress
+ include_examples 'cluster application initial status specs'
before do
allow(ClusterWaitForIngressIpAddressWorker).to receive(:perform_in)
diff --git a/spec/models/clusters/applications/knative_spec.rb b/spec/models/clusters/applications/knative_spec.rb
index 55443bb2d4f..5519615d52d 100644
--- a/spec/models/clusters/applications/knative_spec.rb
+++ b/spec/models/clusters/applications/knative_spec.rb
@@ -9,6 +9,7 @@ describe Clusters::Applications::Knative do
include_examples 'cluster application core specs', :clusters_applications_knative
include_examples 'cluster application status specs', :clusters_applications_knative
include_examples 'cluster application helm specs', :clusters_applications_knative
+ include_examples 'cluster application initial status specs'
before do
allow(ClusterWaitForIngressIpAddressWorker).to receive(:perform_in)
diff --git a/spec/models/clusters/applications/prometheus_spec.rb b/spec/models/clusters/applications/prometheus_spec.rb
index 36a6e4c347b..073fbded8ac 100644
--- a/spec/models/clusters/applications/prometheus_spec.rb
+++ b/spec/models/clusters/applications/prometheus_spec.rb
@@ -6,6 +6,7 @@ describe Clusters::Applications::Prometheus do
include_examples 'cluster application core specs', :clusters_applications_prometheus
include_examples 'cluster application status specs', :clusters_applications_prometheus
include_examples 'cluster application helm specs', :clusters_applications_prometheus
+ include_examples 'cluster application initial status specs'
describe '.installed' do
subject { described_class.installed }
diff --git a/spec/models/clusters/applications/runner_spec.rb b/spec/models/clusters/applications/runner_spec.rb
index 3e6daf8a167..96b7b02dbaf 100644
--- a/spec/models/clusters/applications/runner_spec.rb
+++ b/spec/models/clusters/applications/runner_spec.rb
@@ -6,6 +6,7 @@ describe Clusters::Applications::Runner do
include_examples 'cluster application core specs', :clusters_applications_runner
include_examples 'cluster application status specs', :clusters_applications_runner
include_examples 'cluster application helm specs', :clusters_applications_runner
+ include_examples 'cluster application initial status specs'
it { is_expected.to belong_to(:runner) }
diff --git a/spec/support/shared_examples/models/cluster_application_initial_status.rb b/spec/support/shared_examples/models/cluster_application_initial_status.rb
new file mode 100644
index 00000000000..9775d87953c
--- /dev/null
+++ b/spec/support/shared_examples/models/cluster_application_initial_status.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+shared_examples 'cluster application initial status specs' do
+ describe '#status' do
+ let(:cluster) { create(:cluster, :provided_by_gcp) }
+
+ subject { described_class.new(cluster: cluster) }
+
+ context 'when application helm is scheduled' do
+ before do
+ create(:clusters_applications_helm, :scheduled, cluster: cluster)
+ end
+
+ it 'defaults to :not_installable' do
+ expect(subject.status_name).to be(:not_installable)
+ end
+ end
+
+ context 'when application is scheduled' do
+ before do
+ create(:clusters_applications_helm, :installed, cluster: cluster)
+ end
+
+ it 'sets a default status' do
+ expect(subject.status_name).to be(:installable)
+ end
+ end
+ end
+end
diff --git a/spec/support/shared_examples/models/cluster_application_status_shared_examples.rb b/spec/support/shared_examples/models/cluster_application_status_shared_examples.rb
index af6147bed39..554f2e747bc 100644
--- a/spec/support/shared_examples/models/cluster_application_status_shared_examples.rb
+++ b/spec/support/shared_examples/models/cluster_application_status_shared_examples.rb
@@ -7,30 +7,6 @@ shared_examples 'cluster application status specs' do |application_name|
it 'sets a default status' do
expect(subject.status_name).to be(:not_installable)
end
-
- context 'when application helm is scheduled' do
- before do
- create(:clusters_applications_helm, :scheduled, cluster: cluster)
- end
-
- it 'defaults to :not_installable' do
- expect(subject.status_name).to be(:not_installable)
- end
- end
-
- context 'when application is scheduled' do
- before do
- create(:clusters_applications_helm, :installed, cluster: cluster)
-
- if described_class == Clusters::Applications::Jupyter
- create(:clusters_applications_ingress, :installed, external_ip: '127.0.0.1', cluster: cluster)
- end
- end
-
- it 'sets a default status' do
- expect(subject.status_name).to be(:installable)
- end
- end
end
describe 'status state machine' do