From e49fb264e6cb5eff44330d69d34b5f74ef262659 Mon Sep 17 00:00:00 2001
From: Grzegorz Bizon <grzesiek.bizon@gmail.com>
Date: Fri, 4 Nov 2016 13:23:06 +0100
Subject: [PATCH] Add tests for deployment and environment entitites

---
 spec/serializers/deployment_entity_spec.rb  | 20 ++++++++++++++++++++
 spec/serializers/environment_entity_spec.rb | 18 ++++++++++++++++++
 2 files changed, 38 insertions(+)
 create mode 100644 spec/serializers/deployment_entity_spec.rb
 create mode 100644 spec/serializers/environment_entity_spec.rb

diff --git a/spec/serializers/deployment_entity_spec.rb b/spec/serializers/deployment_entity_spec.rb
new file mode 100644
index 00000000000..51b6de91571
--- /dev/null
+++ b/spec/serializers/deployment_entity_spec.rb
@@ -0,0 +1,20 @@
+require 'spec_helper'
+
+describe DeploymentEntity do
+  let(:entity) do
+    described_class.new(deployment, request: double)
+  end
+
+  let(:deployment) { create(:deployment) }
+
+  subject { entity.as_json }
+
+  it 'exposes internal deployment id'  do
+    expect(subject).to include(:iid)
+  end
+
+  it 'exposes nested information about branch' do
+    expect(subject[:ref][:name]).to eq 'master'
+    expect(subject[:ref][:ref_url]).not_to be_empty
+  end
+end
diff --git a/spec/serializers/environment_entity_spec.rb b/spec/serializers/environment_entity_spec.rb
new file mode 100644
index 00000000000..4ca8c299147
--- /dev/null
+++ b/spec/serializers/environment_entity_spec.rb
@@ -0,0 +1,18 @@
+require 'spec_helper'
+
+describe EnvironmentEntity do
+  let(:entity) do
+    described_class.new(environment, request: double)
+  end
+
+  let(:environment) { create(:environment) }
+  subject { entity.as_json }
+
+  it 'exposes latest deployment' do
+    expect(subject).to include(:last_deployment)
+  end
+
+  it 'exposes core elements of environment' do
+    expect(subject).to include(:id, :name, :state, :environment_url)
+  end
+end
-- 
GitLab