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

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

48 lines
1.2 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 ClusterSerializer do
2020-05-24 23:13:21 +05:30
let(:cluster) { create(:cluster, :project, provider_type: :user) }
describe '#represent_list' do
2020-07-28 23:09:34 +05:30
subject { described_class.new(current_user: nil).represent_list(cluster).keys }
2020-05-24 23:13:21 +05:30
it 'serializes attrs correctly' do
is_expected.to contain_exactly(
:cluster_type,
:enabled,
:environment_scope,
2021-01-03 14:25:43 +05:30
:id,
2020-10-24 23:57:45 +05:30
:kubernetes_errors,
2020-05-24 23:13:21 +05:30
:name,
:nodes,
:path,
2020-06-23 00:09:42 +05:30
:provider_type,
2020-05-24 23:13:21 +05:30
:status)
end
end
2018-03-17 18:26:18 +05:30
describe '#represent_status' do
2020-07-28 23:09:34 +05:30
subject { described_class.new(current_user: nil).represent_status(cluster).keys }
2020-05-24 23:13:21 +05:30
context 'when provider type is gcp and cluster is errored' do
let(:cluster) do
errored_provider = create(:cluster_provider_gcp, :errored)
2018-03-17 18:26:18 +05:30
2020-05-24 23:13:21 +05:30
create(:cluster, provider_type: :gcp, provider_gcp: errored_provider)
end
2018-03-17 18:26:18 +05:30
2020-05-24 23:13:21 +05:30
it 'serializes attrs correctly' do
2023-05-27 22:25:52 +05:30
is_expected.to contain_exactly(:status, :status_reason)
2018-03-17 18:26:18 +05:30
end
end
context 'when provider type is user' do
2020-05-24 23:13:21 +05:30
it 'serializes attrs correctly' do
2023-05-27 22:25:52 +05:30
is_expected.to contain_exactly(:status, :status_reason)
2018-03-17 18:26:18 +05:30
end
end
end
end