summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-12-21 15:47:03 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-12-21 15:47:03 +0100
commit2bb49182fe5037f262ff26251461be5d5fed6441 (patch)
tree372357d9dc24a3663e1dfa66f32ecdeaf40a5106 /spec
parente072a2740e4b4112830f16f061704a88d5a9cabb (diff)
downloadgitlab-ce-2bb49182fe5037f262ff26251461be5d5fed6441.tar.gz
Add missing specs for CI pipeline stage entity
[ci skip]
Diffstat (limited to 'spec')
-rw-r--r--spec/serializers/stage_entity_spec.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/serializers/stage_entity_spec.rb b/spec/serializers/stage_entity_spec.rb
new file mode 100644
index 00000000000..807e09f860a
--- /dev/null
+++ b/spec/serializers/stage_entity_spec.rb
@@ -0,0 +1,40 @@
+require 'spec_helper'
+
+describe StageEntity do
+ let(:pipeline) { create(:ci_pipeline) }
+ let(:request) { double('request') }
+ let(:user) { create(:user) }
+
+ let(:entity) do
+ described_class.new(stage, request: request)
+ end
+
+ let(:stage) do
+ build(:ci_stage, pipeline: pipeline, name: 'test')
+ end
+
+ before do
+ allow(request).to receive(:user).and_return(user)
+ end
+
+ describe '#as_json' do
+ subject { entity.as_json }
+
+ it 'contains relevant fields' do
+ expect(subject).to include :name, :status, :path
+ end
+
+ it 'contains detailed status' do
+ expect(subject[:status]).to include :text, :label, :group, :icon
+ end
+
+ it 'contains valid name' do
+ expect(subject[:name]).to eq 'test'
+ end
+
+ it 'contains path to the stage' do
+ expect(subject[:path])
+ .to include "pipelines/#{pipeline.id}##{stage.name}"
+ end
+ end
+end