diff options
author | João Cunha <j.a.cunha@gmail.com> | 2019-02-14 12:50:50 +0000 |
---|---|---|
committer | João Cunha <j.a.cunha@gmail.com> | 2019-02-14 15:22:48 +0000 |
commit | 26c7d04cd06d1126e4a4a7a1c9308d12de77172e (patch) | |
tree | 082d5f9d03110596120adfbc681e219c279c42d5 | |
parent | 24ee46d6adc5e4381a49d40fb3fe9e7f082c9f5a (diff) | |
download | gitlab-ce-26c7d04cd06d1126e4a4a7a1c9308d12de77172e.tar.gz |
Refactor .available spec into a shared_example
- Uses shared_exampels to DRY up duplicated specs
6 files changed, 13 insertions, 65 deletions
diff --git a/spec/models/clusters/applications/cert_manager_spec.rb b/spec/models/clusters/applications/cert_manager_spec.rb index 7c87c5aaddf..cf5cbf8ec5c 100644 --- a/spec/models/clusters/applications/cert_manager_spec.rb +++ b/spec/models/clusters/applications/cert_manager_spec.rb @@ -8,19 +8,6 @@ describe Clusters::Applications::CertManager do include_examples 'cluster application version specs', :clusters_applications_cert_managers include_examples 'cluster application initial status specs' - describe '.available' do - subject { described_class.available } - - let!(:installed_cluster) { create(:clusters_applications_cert_managers, :installed) } - let!(:updated_cluster) { create(:clusters_applications_cert_managers, :updated) } - - before do - create(:clusters_applications_cert_managers, :errored) - end - - it { is_expected.to contain_exactly(installed_cluster, updated_cluster) } - end - 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" } } subject { cert_manager.install_command } diff --git a/spec/models/clusters/applications/ingress_spec.rb b/spec/models/clusters/applications/ingress_spec.rb index a978f1d6f57..d5fd42509a3 100644 --- a/spec/models/clusters/applications/ingress_spec.rb +++ b/spec/models/clusters/applications/ingress_spec.rb @@ -16,19 +16,6 @@ describe Clusters::Applications::Ingress do allow(ClusterWaitForIngressIpAddressWorker).to receive(:perform_async) end - describe '.available' do - subject { described_class.available } - - let!(:installed_cluster) { create(:clusters_applications_ingress, :installed) } - let!(:updated_cluster) { create(:clusters_applications_ingress, :updated) } - - before do - create(:clusters_applications_ingress, :errored) - end - - it { is_expected.to contain_exactly(installed_cluster, updated_cluster) } - end - describe '#make_installed!' do before do application.make_installed! diff --git a/spec/models/clusters/applications/knative_spec.rb b/spec/models/clusters/applications/knative_spec.rb index 21b215cd9d2..006b922ab27 100644 --- a/spec/models/clusters/applications/knative_spec.rb +++ b/spec/models/clusters/applications/knative_spec.rb @@ -24,19 +24,6 @@ describe Clusters::Applications::Knative do it { expect(knative_no_rbac).to be_not_installable } end - describe '.installed' do - subject { described_class.available } - - let!(:installed_cluster) { create(:clusters_applications_knative, :installed) } - let!(:updated_cluster) { create(:clusters_applications_knative, :updated) } - - before do - create(:clusters_applications_knative, :errored) - end - - it { is_expected.to contain_exactly(installed_cluster, updated_cluster) } - end - describe 'make_installed with external_ip' do before do application.make_installed! diff --git a/spec/models/clusters/applications/prometheus_spec.rb b/spec/models/clusters/applications/prometheus_spec.rb index 4442dc6d0c9..2250ef301aa 100644 --- a/spec/models/clusters/applications/prometheus_spec.rb +++ b/spec/models/clusters/applications/prometheus_spec.rb @@ -9,19 +9,6 @@ describe Clusters::Applications::Prometheus do include_examples 'cluster application helm specs', :clusters_applications_prometheus include_examples 'cluster application initial status specs' - describe '.available' do - subject { described_class.available } - - let!(:installed_cluster) { create(:clusters_applications_prometheus, :installed) } - let!(:updated_cluster) { create(:clusters_applications_prometheus, :updated) } - - before do - create(:clusters_applications_prometheus, :errored) - end - - it { is_expected.to contain_exactly(installed_cluster, updated_cluster) } - end - describe 'transition to installed' do let(:project) { create(:project) } let(:cluster) { create(:cluster, :with_installed_helm, projects: [project]) } diff --git a/spec/models/clusters/applications/runner_spec.rb b/spec/models/clusters/applications/runner_spec.rb index bea919f73ea..5e5b25cbf8a 100644 --- a/spec/models/clusters/applications/runner_spec.rb +++ b/spec/models/clusters/applications/runner_spec.rb @@ -11,19 +11,6 @@ describe Clusters::Applications::Runner do it { is_expected.to belong_to(:runner) } - describe '.available' do - subject { described_class.available } - - let!(:installed_cluster) { create(:clusters_applications_runner, :installed) } - let!(:updated_cluster) { create(:clusters_applications_runner, :updated) } - - before do - create(:clusters_applications_runner, :errored) - end - - it { is_expected.to contain_exactly(installed_cluster, updated_cluster) } - end - describe '#install_command' do let(:kubeclient) { double('kubernetes client') } let(:gitlab_runner) { create(:clusters_applications_runner, runner: ci_runner) } 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 c96a65cb56a..b8c19cab0c4 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 @@ -9,6 +9,19 @@ shared_examples 'cluster application status specs' do |application_name| end end + describe '.available' do + subject { described_class.available } + + let!(:installed_cluster) { create(application_name, :installed) } + let!(:updated_cluster) { create(application_name, :updated) } + + before do + create(application_name, :errored) + end + + it { is_expected.to contain_exactly(installed_cluster, updated_cluster) } + end + describe 'status state machine' do describe '#make_installing' do subject { create(application_name, :scheduled) } |