diff options
author | Alessio Caiazza <acaiazza@gitlab.com> | 2017-11-06 17:02:28 +0100 |
---|---|---|
committer | Alessio Caiazza <acaiazza@gitlab.com> | 2017-11-06 17:02:28 +0100 |
commit | 2802b5bb52b6ba28e6eeb1813f3fd3a79d2c03c4 (patch) | |
tree | 57bb23f3ec8f808209059cf1b4791b5cefeb20f9 /spec/serializers | |
parent | b893a858808f1e2aefca4e3f665d633d31fa5937 (diff) | |
download | gitlab-ce-2802b5bb52b6ba28e6eeb1813f3fd3a79d2c03c4.tar.gz |
Add ClusterApplicationEntity tests
Diffstat (limited to 'spec/serializers')
-rw-r--r-- | spec/serializers/cluster_application_entity_spec.rb | 30 | ||||
-rw-r--r-- | spec/serializers/cluster_entity_spec.rb | 13 | ||||
-rw-r--r-- | spec/serializers/cluster_serializer_spec.rb | 2 |
3 files changed, 42 insertions, 3 deletions
diff --git a/spec/serializers/cluster_application_entity_spec.rb b/spec/serializers/cluster_application_entity_spec.rb new file mode 100644 index 00000000000..61cebcefa28 --- /dev/null +++ b/spec/serializers/cluster_application_entity_spec.rb @@ -0,0 +1,30 @@ +require 'spec_helper' + +describe ClusterApplicationEntity do + describe '#as_json' do + let(:application) { build(:applications_helm) } + 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(:installable) + end + + it 'has no status_reason' do + expect(subject[:status_reason]).to be_nil + end + + context 'when application is errored' do + let(:application) { build(: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 + end +end diff --git a/spec/serializers/cluster_entity_spec.rb b/spec/serializers/cluster_entity_spec.rb index abfc3731fb2..c58ee1a1ea6 100644 --- a/spec/serializers/cluster_entity_spec.rb +++ b/spec/serializers/cluster_entity_spec.rb @@ -35,8 +35,17 @@ describe ClusterEntity do end end - it 'contains applications' do - expect(subject[:applications]).to eq({}) + context 'when no application has been installed' do + let(:cluster) { create(:cluster) } + subject { described_class.new(cluster).as_json[:applications]} + + it 'contains helm as installable' do + expect(subject).not_to be_empty + + helm = subject[0] + expect(helm[:name]).to eq('helm') + expect(helm[:status]).to eq(:installable) + end end end end diff --git a/spec/serializers/cluster_serializer_spec.rb b/spec/serializers/cluster_serializer_spec.rb index 04d8728303c..a6dd2309663 100644 --- a/spec/serializers/cluster_serializer_spec.rb +++ b/spec/serializers/cluster_serializer_spec.rb @@ -9,7 +9,7 @@ describe ClusterSerializer do let(:provider) { create(:provider_gcp, :errored) } it 'serializes only status' do - expect(subject.keys).to contain_exactly(:status, :status_reason) + expect(subject.keys).to contain_exactly(:status, :status_reason, :applications) end end |