debian-mirror-gitlab/spec/serializers/cluster_entity_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

46 lines
1.3 KiB
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe ClusterEntity do
include Gitlab::Routing.url_helpers
2018-03-17 18:26:18 +05:30
describe '#as_json' do
2020-07-28 23:09:34 +05:30
let(:user) { nil }
let(:request) { EntityRequest.new({ current_user: user }) }
subject { described_class.new(cluster, request: request).as_json }
2018-03-17 18:26:18 +05:30
context 'when provider type is gcp' do
2020-05-24 23:13:21 +05:30
let(:cluster) { create(:cluster, :instance, provider_type: :gcp, provider_gcp: provider) }
2018-03-17 18:26:18 +05:30
context 'when status is creating' do
let(:provider) { create(:cluster_provider_gcp, :creating) }
it 'has corresponded data' do
expect(subject[:status]).to eq(:creating)
expect(subject[:status_reason]).to be_nil
end
end
context 'when status is errored' do
let(:provider) { create(:cluster_provider_gcp, :errored) }
it 'has corresponded data' do
expect(subject[:status]).to eq(:errored)
expect(subject[:status_reason]).to eq(provider.status_reason)
end
end
end
context 'when provider type is user' do
2020-05-24 23:13:21 +05:30
let(:cluster) { create(:cluster, :instance, provider_type: :user) }
2018-03-17 18:26:18 +05:30
it 'has corresponded data' do
expect(subject[:status]).to eq(:created)
expect(subject[:status_reason]).to be_nil
end
end
end
end