Add status entity prototype and expose in pipeline
This commit is contained in:
parent
ad19de1949
commit
e4efb135e8
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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
|
Loading…
Reference in New Issue