diff options
author | Shinya Maeda <shinya@gitlab.com> | 2017-10-31 01:03:58 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2017-10-31 01:03:58 +0900 |
commit | c43a82cdfa8c5c1d045e2628330953227dcc9767 (patch) | |
tree | cb60c65b085979c380b8fa83e663b895e6cd3cc1 /spec/serializers/cluster_entity_spec.rb | |
parent | 709b8b6186b06372bf9bfebe9d36a0fea9226a1b (diff) | |
download | gitlab-ce-c43a82cdfa8c5c1d045e2628330953227dcc9767.tar.gz |
specs for serializers.
Diffstat (limited to 'spec/serializers/cluster_entity_spec.rb')
-rw-r--r-- | spec/serializers/cluster_entity_spec.rb | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/spec/serializers/cluster_entity_spec.rb b/spec/serializers/cluster_entity_spec.rb index 2c7f49974f1..7b132a1b84d 100644 --- a/spec/serializers/cluster_entity_spec.rb +++ b/spec/serializers/cluster_entity_spec.rb @@ -1,22 +1,38 @@ require 'spec_helper' describe ClusterEntity do - set(:cluster) { create(:gcp_cluster, :errored) } - let(:request) { double('request') } + describe '#as_json' do + subject { described_class.new(cluster).as_json } - let(:entity) do - described_class.new(cluster) - end + context 'when provider type is gcp' do + let(:cluster) { create(:cluster, provider_type: :gcp, provider_gcp: provider) } - describe '#as_json' do - subject { entity.as_json } + context 'when status is creating' do + let(:provider) { create(:provider_gcp, :creating) } - it 'contains status' do - expect(subject[:status]).to eq(:errored) + 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(: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 - it 'contains status reason' do - expect(subject[:status_reason]).to eq('general error') + context 'when provider type is user' do + let(:cluster) { create(:cluster, provider_type: :user) } + + it 'has nil' do + expect(subject[:status]).to be_nil + expect(subject[:status_reason]).to be_nil + end end end end |