2016-08-02 06:06:31 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2016-08-12 04:09:29 -04:00
|
|
|
describe Gitlab::DataBuilder::Pipeline do
|
2016-08-02 06:06:31 -04:00
|
|
|
let(:user) { create(:user) }
|
2017-01-24 18:42:12 -05:00
|
|
|
let(:project) { create(:project, :repository) }
|
2016-08-11 11:23:35 -04:00
|
|
|
|
2016-08-02 06:06:31 -04:00
|
|
|
let(:pipeline) do
|
|
|
|
create(:ci_pipeline,
|
2016-08-11 11:23:35 -04:00
|
|
|
project: project,
|
|
|
|
status: 'success',
|
|
|
|
sha: project.commit.sha,
|
|
|
|
ref: project.default_branch)
|
2016-08-02 06:06:31 -04:00
|
|
|
end
|
2016-08-11 11:23:35 -04:00
|
|
|
|
2016-08-02 06:06:31 -04:00
|
|
|
let!(:build) { create(:ci_build, pipeline: pipeline) }
|
|
|
|
|
|
|
|
describe '.build' do
|
2016-08-12 03:16:14 -04:00
|
|
|
let(:data) { described_class.build(pipeline) }
|
2016-08-02 06:06:31 -04:00
|
|
|
let(:attributes) { data[:object_attributes] }
|
|
|
|
let(:build_data) { data[:builds].first }
|
|
|
|
let(:project_data) { data[:project] }
|
|
|
|
|
|
|
|
it { expect(attributes).to be_a(Hash) }
|
|
|
|
it { expect(attributes[:ref]).to eq(pipeline.ref) }
|
|
|
|
it { expect(attributes[:sha]).to eq(pipeline.sha) }
|
|
|
|
it { expect(attributes[:tag]).to eq(pipeline.tag) }
|
|
|
|
it { expect(attributes[:id]).to eq(pipeline.id) }
|
|
|
|
it { expect(attributes[:status]).to eq(pipeline.status) }
|
2018-02-18 18:47:37 -05:00
|
|
|
it { expect(attributes[:detailed_status]).to eq('passed') }
|
2016-08-02 06:06:31 -04:00
|
|
|
|
|
|
|
it { expect(build_data).to be_a(Hash) }
|
|
|
|
it { expect(build_data[:id]).to eq(build.id) }
|
|
|
|
it { expect(build_data[:status]).to eq(build.status) }
|
|
|
|
|
|
|
|
it { expect(project_data).to eq(project.hook_attrs(backward: false)) }
|
|
|
|
end
|
|
|
|
end
|