Commit 2bb49182 authored by Grzegorz Bizon's avatar Grzegorz Bizon 🔴

Add missing specs for CI pipeline stage entity

[ci skip]
parent e072a274
Pipeline #5495098 skipped
......@@ -2,6 +2,7 @@ class StageEntity < Grape::Entity
include RequestAwareEntity
expose :name
expose :status do |stage, options|
StatusEntity.represent(
stage.detailed_status(request.user),
......
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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment