Commit a5f9e49f authored by Matija Čupić's avatar Matija Čupić

Add user_provided and gcp_provided cluster scopes

parent 427eeb43
......@@ -50,6 +50,8 @@ module Clusters
scope :enabled, -> { where(enabled: true) }
scope :disabled, -> { where(enabled: false) }
scope :user_provided, -> { where(provider_type: ::Clusters::Cluster.provider_types[:user]) }
scope :gcp_provided, -> { where(provider_type: ::Clusters::Cluster.provider_types[:gcp]) }
def status_name
if provider
......
......@@ -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? }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment