summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2017-11-07 14:52:11 +0100
committerKamil Trzcinski <ayufan@ayufan.eu>2017-11-07 14:52:11 +0100
commit760a154a032319a90e15dcf4d54ec1c1cdde9e1c (patch)
tree15de9ed0cdb9f4aa09f6c25a642971d186da2119
parent55d098c94b4f7e39931d5e4084be19872386fa18 (diff)
downloadgitlab-ce-760a154a032319a90e15dcf4d54ec1c1cdde9e1c.tar.gz
Fix tests for initial status
-rw-r--r--app/models/clusters/applications/helm.rb2
-rw-r--r--spec/factories/clusters/applications/helm.rb4
-rw-r--r--spec/models/clusters/applications/helm_spec.rb16
3 files changed, 20 insertions, 2 deletions
diff --git a/app/models/clusters/applications/helm.rb b/app/models/clusters/applications/helm.rb
index 0bbe5219715..7ea84841118 100644
--- a/app/models/clusters/applications/helm.rb
+++ b/app/models/clusters/applications/helm.rb
@@ -18,6 +18,8 @@ module Clusters
end
def set_initial_status
+ return unless not_installable?
+
self.status = 'installable' if cluster&.platform_kubernetes_active?
end
diff --git a/spec/factories/clusters/applications/helm.rb b/spec/factories/clusters/applications/helm.rb
index 23818f19edf..a0c874b103b 100644
--- a/spec/factories/clusters/applications/helm.rb
+++ b/spec/factories/clusters/applications/helm.rb
@@ -2,6 +2,10 @@ FactoryGirl.define do
factory :cluster_applications_helm, class: Clusters::Applications::Helm do
cluster factory: %i(cluster provided_by_gcp)
+ trait :not_installable do
+ status -2
+ end
+
trait :installable do
status 0
end
diff --git a/spec/models/clusters/applications/helm_spec.rb b/spec/models/clusters/applications/helm_spec.rb
index 2b1922fdd5b..beb10bf38c9 100644
--- a/spec/models/clusters/applications/helm_spec.rb
+++ b/spec/models/clusters/applications/helm_spec.rb
@@ -21,8 +21,20 @@ describe Clusters::Applications::Helm do
end
describe '#status' do
- it 'defaults to :installable' do
- expect(subject.status_name).to be(:installable)
+ let(:cluster) { create(:cluster) }
+
+ subject { described_class.new(cluster: cluster) }
+
+ it 'defaults to :not_installable' do
+ expect(subject.status_name).to be(:not_installable)
+ end
+
+ context 'when platform kubernetes is defined' do
+ let(:cluster) { create(:cluster, :provided_by_gcp) }
+
+ it 'defaults to :installable' do
+ expect(subject.status_name).to be(:installable)
+ end
end
end