diff --git a/app/models/clusters/cluster.rb b/app/models/clusters/cluster.rb index 185d9473aabbef260483f0cdb9a56d8ff880b1d9..bc3bb9d00d7808783bcafb5aba95e107c51d4326 100644 --- a/app/models/clusters/cluster.rb +++ b/app/models/clusters/cluster.rb @@ -62,6 +62,10 @@ module Clusters end end + def created? + status_name == :created + end + def applications [ application_helm || build_application_helm, diff --git a/spec/models/clusters/cluster_spec.rb b/spec/models/clusters/cluster_spec.rb index b91a5e7a272a9c9aa0089a1a01f98946758d331b..beb0e83f97af70c4d0fbb766d29627e4c47d5d50 100644 --- a/spec/models/clusters/cluster_spec.rb +++ b/spec/models/clusters/cluster_spec.rb @@ -199,4 +199,26 @@ describe Clusters::Cluster do end end end + + describe '#created?' do + let(:cluster) { create(:cluster, :provided_by_gcp) } + + subject { cluster.created? } + + context 'when status_name is :created' do + before do + allow(cluster).to receive_message_chain(:provider, :status_name).and_return(:created) + end + + it { is_expected.to eq(true) } + end + + context 'when status_name is not :created' do + before do + allow(cluster).to receive_message_chain(:provider, :status_name).and_return(:creating) + end + + it { is_expected.to eq(false) } + end + end end