From a5f9e49f1317345d1b72566ecff188dff5f74913 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20=C4=8Cupi=C4=87?= Date: Thu, 29 Mar 2018 21:17:18 +0200 Subject: Add user_provided and gcp_provided cluster scopes --- spec/models/clusters/cluster_spec.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'spec/models/clusters') diff --git a/spec/models/clusters/cluster_spec.rb b/spec/models/clusters/cluster_spec.rb index 8f12a0e3085..ae96e5d1aa2 100644 --- a/spec/models/clusters/cluster_spec.rb +++ b/spec/models/clusters/cluster_spec.rb @@ -39,6 +39,30 @@ describe Clusters::Cluster do it { is_expected.to contain_exactly(cluster) } end + describe '.user_provided' do + subject { described_class.user_provided } + + let!(:cluster) { create(:cluster, :provided_by_user) } + + before do + create(:cluster, :provided_by_gcp) + end + + it { is_expected.to contain_exactly(cluster) } + end + + describe '.gcp_provided' do + subject { described_class.gcp_provided } + + let!(:cluster) { create(:cluster, :provided_by_gcp) } + + before do + create(:cluster, :provided_by_user) + end + + it { is_expected.to contain_exactly(cluster) } + end + describe 'validation' do subject { cluster.valid? } -- cgit v1.2.1 From 982e5436e1ef9b309f8ee3a205f1e168273386b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20=C4=8Cupi=C4=87?= Date: Thu, 29 Mar 2018 21:24:10 +0200 Subject: Add installed scope to cluster applications --- spec/models/clusters/applications/helm_spec.rb | 12 ++++++++++++ spec/models/clusters/applications/ingress_spec.rb | 12 ++++++++++++ spec/models/clusters/applications/prometheus_spec.rb | 12 ++++++++++++ spec/models/clusters/applications/runner_spec.rb | 12 ++++++++++++ 4 files changed, 48 insertions(+) (limited to 'spec/models/clusters') diff --git a/spec/models/clusters/applications/helm_spec.rb b/spec/models/clusters/applications/helm_spec.rb index ba7bad617b4..0eb1e3876e2 100644 --- a/spec/models/clusters/applications/helm_spec.rb +++ b/spec/models/clusters/applications/helm_spec.rb @@ -3,6 +3,18 @@ require 'rails_helper' describe Clusters::Applications::Helm do include_examples 'cluster application core specs', :clusters_applications_helm + describe '.installed' do + subject { described_class.installed } + + let!(:cluster) { create(:clusters_applications_helm, :installed) } + + before do + create(:clusters_applications_helm, :errored) + end + + it { is_expected.to contain_exactly(cluster) } + end + describe '#install_command' do let(:helm) { create(:clusters_applications_helm) } diff --git a/spec/models/clusters/applications/ingress_spec.rb b/spec/models/clusters/applications/ingress_spec.rb index 03f5b88a525..a47a07d908d 100644 --- a/spec/models/clusters/applications/ingress_spec.rb +++ b/spec/models/clusters/applications/ingress_spec.rb @@ -11,6 +11,18 @@ describe Clusters::Applications::Ingress do allow(ClusterWaitForIngressIpAddressWorker).to receive(:perform_async) end + describe '.installed' do + subject { described_class.installed } + + let!(:cluster) { create(:clusters_applications_ingress, :installed) } + + before do + create(:clusters_applications_ingress, :errored) + end + + it { is_expected.to contain_exactly(cluster) } + end + describe '#make_installed!' 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 2905b58066b..aeca6ee903a 100644 --- a/spec/models/clusters/applications/prometheus_spec.rb +++ b/spec/models/clusters/applications/prometheus_spec.rb @@ -4,6 +4,18 @@ describe Clusters::Applications::Prometheus do include_examples 'cluster application core specs', :clusters_applications_prometheus include_examples 'cluster application status specs', :cluster_application_prometheus + describe '.installed' do + subject { described_class.installed } + + let!(:cluster) { create(:clusters_applications_prometheus, :installed) } + + before do + create(:clusters_applications_prometheus, :errored) + end + + it { is_expected.to contain_exactly(cluster) } + end + describe 'transition to installed' do let(:project) { create(:project) } let(:cluster) { create(:cluster, projects: [project]) } diff --git a/spec/models/clusters/applications/runner_spec.rb b/spec/models/clusters/applications/runner_spec.rb index a574779e39d..64d995a73c1 100644 --- a/spec/models/clusters/applications/runner_spec.rb +++ b/spec/models/clusters/applications/runner_spec.rb @@ -8,6 +8,18 @@ describe Clusters::Applications::Runner do it { is_expected.to belong_to(:runner) } + describe '.installed' do + subject { described_class.installed } + + let!(:cluster) { create(:clusters_applications_runner, :installed) } + + before do + create(:clusters_applications_runner, :errored) + end + + it { is_expected.to contain_exactly(cluster) } + end + describe '#install_command' do let(:kubeclient) { double('kubernetes client') } let(:gitlab_runner) { create(:clusters_applications_runner, runner: ci_runner) } -- cgit v1.2.1 From b26913a30c608f81c44abece263da8d01faf0126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20=C4=8Cupi=C4=87?= Date: Fri, 30 Mar 2018 17:34:10 +0200 Subject: Extract cluster installed query to scope --- spec/models/clusters/cluster_spec.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'spec/models/clusters') diff --git a/spec/models/clusters/cluster_spec.rb b/spec/models/clusters/cluster_spec.rb index ae96e5d1aa2..b942554d67b 100644 --- a/spec/models/clusters/cluster_spec.rb +++ b/spec/models/clusters/cluster_spec.rb @@ -63,6 +63,18 @@ describe Clusters::Cluster do it { is_expected.to contain_exactly(cluster) } end + describe '.gcp_installed' do + subject { described_class.gcp_installed } + + let!(:cluster) { create(:cluster, :provided_by_gcp) } + + before do + create(:cluster, :providing_by_gcp) + end + + it { is_expected.to contain_exactly(cluster) } + end + describe 'validation' do subject { cluster.valid? } -- cgit v1.2.1