2016-11-04 12:23:06 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-04-20 10:21:24 +00:00
|
|
|
describe DeploymentEntity do
|
2017-03-06 18:22:23 +00:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:request) { double('request') }
|
2017-04-20 10:21:24 +00:00
|
|
|
let(:deployment) { create(:deployment) }
|
|
|
|
let(:entity) { described_class.new(deployment, request: request) }
|
|
|
|
subject { entity.as_json }
|
2017-03-06 18:22:23 +00:00
|
|
|
|
|
|
|
before do
|
2017-05-09 04:15:34 +00:00
|
|
|
allow(request).to receive(:current_user).and_return(user)
|
2017-03-06 18:22:23 +00:00
|
|
|
end
|
2017-03-11 17:22:08 +00:00
|
|
|
|
2016-11-04 12:23:06 +00:00
|
|
|
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'
|
|
|
|
end
|
2017-03-28 10:48:53 +00:00
|
|
|
|
|
|
|
it 'exposes creation date' do
|
|
|
|
expect(subject).to include(:created_at)
|
|
|
|
end
|
2018-10-10 01:47:31 +00:00
|
|
|
|
|
|
|
describe 'scheduled_actions' do
|
|
|
|
let(:project) { create(:project, :repository) }
|
|
|
|
let(:pipeline) { create(:ci_pipeline, project: project, user: user) }
|
|
|
|
let(:build) { create(:ci_build, :success, pipeline: pipeline) }
|
|
|
|
let(:deployment) { create(:deployment, deployable: build) }
|
|
|
|
|
2018-10-12 02:22:19 +00:00
|
|
|
context 'when the same pipeline has a scheduled action' do
|
|
|
|
let(:other_build) { create(:ci_build, :schedulable, :success, pipeline: pipeline, name: 'other build') }
|
2018-10-10 01:47:31 +00:00
|
|
|
let!(:other_deployment) { create(:deployment, deployable: other_build) }
|
|
|
|
|
2018-10-12 02:22:19 +00:00
|
|
|
it 'returns other scheduled actions' do
|
2018-10-10 01:47:31 +00:00
|
|
|
expect(subject[:scheduled_actions][0][:name]).to eq 'other build'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-10-12 02:22:19 +00:00
|
|
|
context 'when the same pipeline does not have a scheduled action' do
|
2018-10-10 01:47:31 +00:00
|
|
|
it 'does not return other actions' do
|
|
|
|
expect(subject[:scheduled_actions]).to be_empty
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-11-04 12:23:06 +00:00
|
|
|
end
|