提交 9eeca2db 编写于 作者: T Thong Kuah

Move common method to application concern

This could be potentially useful to all cluster applications.

Address followup issue https://gitlab.com/gitlab-org/gitlab-ce/issues/56524
上级 e2a56bd1
......@@ -6,7 +6,6 @@ module Clusters
include PrometheusAdapter
VERSION = '6.7.3'
READY_STATUS = [:installed, :updating, :updated, :update_errored].freeze
self.table_name = 'clusters_applications_prometheus'
......@@ -25,10 +24,6 @@ module Clusters
end
end
def ready?
READY_STATUS.include?(status_name)
end
def chart
'stable/prometheus'
end
......
......@@ -80,6 +80,10 @@ module Clusters
installed? || updated?
end
def ready?
installed? || updating? || updated? || update_errored?
end
def update_in_progress?
updating?
end
......
......@@ -39,65 +39,6 @@ describe Clusters::Applications::Prometheus do
end
end
describe '#ready' do
let(:project) { create(:project) }
let(:cluster) { create(:cluster, projects: [project]) }
it 'returns true when installed' do
application = build(:clusters_applications_prometheus, :installed, cluster: cluster)
expect(application).to be_ready
end
it 'returns false when not_installable' do
application = build(:clusters_applications_prometheus, :not_installable, cluster: cluster)
expect(application).not_to be_ready
end
it 'returns false when installable' do
application = build(:clusters_applications_prometheus, :installable, cluster: cluster)
expect(application).not_to be_ready
end
it 'returns false when scheduled' do
application = build(:clusters_applications_prometheus, :scheduled, cluster: cluster)
expect(application).not_to be_ready
end
it 'returns false when installing' do
application = build(:clusters_applications_prometheus, :installing, cluster: cluster)
expect(application).not_to be_ready
end
it 'returns false when errored' do
application = build(:clusters_applications_prometheus, :errored, cluster: cluster)
expect(application).not_to be_ready
end
it 'returns true when updating' do
application = build(:clusters_applications_prometheus, :updating, cluster: cluster)
expect(application).to be_ready
end
it 'returns true when updated' do
application = build(:clusters_applications_prometheus, :updated, cluster: cluster)
expect(application).to be_ready
end
it 'returns true when errored' do
application = build(:clusters_applications_prometheus, :update_errored, cluster: cluster)
expect(application).to be_ready
end
end
describe '#prometheus_client' do
context 'cluster is nil' do
it 'returns nil' do
......
......@@ -138,6 +138,32 @@ shared_examples 'cluster application status specs' do |application_name|
end
end
describe '#ready?' do
using RSpec::Parameterized::TableSyntax
where(:trait, :ready) do
:not_installable | false
:installable | false
:scheduled | false
:installing | false
:installed | true
:updating | true
:updated | true
:errored | false
:update_errored | true
end
with_them do
subject { build(application_name, trait) }
if params[:ready]
it { is_expected.to be_ready }
else
it { is_expected.not_to be_ready }
end
end
end
describe '#available?' do
using RSpec::Parameterized::TableSyntax
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册