summaryrefslogtreecommitdiff
path: root/spec/serializers/cluster_serializer_spec.rb
blob: e65e97b6ae0e248c973cd2563255a6979ab4a638 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe ClusterSerializer do
  let(:cluster) { create(:cluster, :project, provider_type: :user) }

  describe '#represent_list' do
    subject { described_class.new(current_user: nil).represent_list(cluster).keys }

    it 'serializes attrs correctly' do
      is_expected.to contain_exactly(
        :cluster_type,
        :enabled,
        :environment_scope,
        :id,
        :gitlab_managed_apps_logs_path,
        :enable_advanced_logs_querying,
        :kubernetes_errors,
        :name,
        :nodes,
        :path,
        :provider_type,
        :status)
    end
  end

  describe '#represent_status' do
    subject { described_class.new(current_user: nil).represent_status(cluster).keys }

    context 'when provider type is gcp and cluster is errored' do
      let(:cluster) do
        errored_provider = create(:cluster_provider_gcp, :errored)

        create(:cluster, provider_type: :gcp, provider_gcp: errored_provider)
      end

      it 'serializes attrs correctly' do
        is_expected.to contain_exactly(:status, :status_reason, :applications)
      end
    end

    context 'when provider type is user' do
      it 'serializes attrs correctly' do
        is_expected.to contain_exactly(:status, :status_reason, :applications)
      end
    end
  end
end