summaryrefslogtreecommitdiff
path: root/spec/serializers/cluster_application_entity_spec.rb
blob: f38a18fcf590dfe5c36c9c88dc3981c40c567309 (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
50
51
52
53
54
55
56
57
58
59
60
require 'spec_helper'

describe ClusterApplicationEntity do
  describe '#as_json' do
    let(:application) { build(:clusters_applications_helm, version: '0.1.1') }
    subject { described_class.new(application).as_json }

    it 'has name' do
      expect(subject[:name]).to eq(application.name)
    end

    it 'has status' do
      expect(subject[:status]).to eq(:not_installable)
    end

    it 'has version' do
      expect(subject[:version]).to eq('0.1.1')
    end

    it 'has no status_reason' do
      expect(subject[:status_reason]).to be_nil
    end

    it 'has can_uninstall' do
      expect(subject[:can_uninstall]).to be_falsey
    end

    context 'non-helm application' do
      let(:application) { build(:clusters_applications_runner, version: '0.0.0') }

      it 'has update_available' do
        expect(subject[:update_available]).to be_truthy
      end
    end

    context 'when application is errored' do
      let(:application) { build(:clusters_applications_helm, :errored) }

      it 'has corresponded data' do
        expect(subject[:status]).to eq(:errored)
        expect(subject[:status_reason]).not_to be_nil
        expect(subject[:status_reason]).to eq(application.status_reason)
      end
    end

    context 'for ingress application' do
      let(:application) do
        build(
          :clusters_applications_ingress,
          :installed,
          external_ip: '111.222.111.222'
        )
      end

      it 'includes external_ip' do
        expect(subject[:external_ip]).to eq('111.222.111.222')
      end
    end
  end
end