Add status entity prototype and expose in pipeline

This commit is contained in:
Grzegorz Bizon 2016-12-07 16:46:37 +01:00
parent ad19de1949
commit e4efb135e8
3 changed files with 33 additions and 1 deletions

View File

@ -12,7 +12,7 @@ class PipelineEntity < Grape::Entity
end
expose :details do
expose :status
expose :detailed_status, as: :status, using: StatusEntity
expose :duration
expose :finished_at
expose :stages_with_statuses, as: :stages, using: PipelineStageEntity

View File

@ -0,0 +1,8 @@
class StatusEntity < Grape::Entity
include RequestAwareEntity
expose :icon, :text, :label, :title
expose :has_details?, as: :has_details
expose :details_path
end

View File

@ -0,0 +1,24 @@
require 'spec_helper'
describe StatusEntity do
let(:entity) do
described_class.new(status)
end
let(:status) do # TODO, add statuses factory
Gitlab::Ci::Status::Success.new(double('object'))
end
before do
allow(status).to receive(:has_details?).and_return(true)
allow(status).to receive(:details_path).and_return('some/path')
end
subject { entity.as_json }
it 'contains status details' do
expect(subject).to include :text, :icon, :label, :title
expect(subject).to include :has_details
expect(subject).to include :details_path
end
end