debian-mirror-gitlab/spec/lib/gitlab/data_builder/pipeline_spec.rb

38 lines
1.2 KiB
Ruby
Raw Normal View History

2016-09-13 17:45:13 +05:30
require 'spec_helper'
describe Gitlab::DataBuilder::Pipeline do
let(:user) { create(:user) }
2017-08-17 22:00:37 +05:30
let(:project) { create(:project, :repository) }
2016-09-13 17:45:13 +05:30
let(:pipeline) do
create(:ci_pipeline,
project: project,
status: 'success',
sha: project.commit.sha,
ref: project.default_branch)
end
let!(:build) { create(:ci_build, pipeline: pipeline) }
describe '.build' do
let(:data) { described_class.build(pipeline) }
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-03-27 19:54:05 +05:30
it { expect(attributes[:detailed_status]).to eq('passed') }
2016-09-13 17:45:13 +05:30
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