2015-12-07 07:23:23 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2016-08-12 04:09:29 -04:00
|
|
|
describe Gitlab::DataBuilder::Build do
|
2015-12-07 07:23:23 -05:00
|
|
|
let(:build) { create(:ci_build) }
|
|
|
|
|
2016-07-11 18:12:31 -04:00
|
|
|
describe '.build' do
|
2015-12-07 07:23:23 -05:00
|
|
|
let(:data) do
|
2016-08-12 03:16:14 -04:00
|
|
|
described_class.build(build)
|
2015-12-07 07:23:23 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(data).to be_a(Hash) }
|
|
|
|
it { expect(data[:ref]).to eq(build.ref) }
|
|
|
|
it { expect(data[:sha]).to eq(build.sha) }
|
|
|
|
it { expect(data[:tag]).to eq(build.tag) }
|
|
|
|
it { expect(data[:build_id]).to eq(build.id) }
|
|
|
|
it { expect(data[:build_status]).to eq(build.status) }
|
2015-12-22 15:15:06 -05:00
|
|
|
it { expect(data[:build_allow_failure]).to eq(false) }
|
2015-12-04 06:55:23 -05:00
|
|
|
it { expect(data[:project_id]).to eq(build.project.id) }
|
2018-03-05 09:15:26 -05:00
|
|
|
it { expect(data[:project_name]).to eq(build.project.full_name) }
|
2017-01-18 05:38:59 -05:00
|
|
|
|
|
|
|
context 'commit author_url' do
|
|
|
|
context 'when no commit present' do
|
|
|
|
let(:build) { create(:ci_build) }
|
|
|
|
|
|
|
|
it 'sets to mailing address of git_author_email' do
|
|
|
|
expect(data[:commit][:author_url]).to eq("mailto:#{build.pipeline.git_author_email}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when commit present but has no author' do
|
|
|
|
let(:build) { create(:ci_build, :with_commit) }
|
|
|
|
|
|
|
|
it 'sets to mailing address of git_author_email' do
|
|
|
|
expect(data[:commit][:author_url]).to eq("mailto:#{build.pipeline.git_author_email}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when commit and author are present' do
|
|
|
|
let(:build) { create(:ci_build, :with_commit_and_author) }
|
|
|
|
|
|
|
|
it 'sets to GitLab user url' do
|
|
|
|
expect(data[:commit][:author_url]).to eq(Gitlab::Routing.url_helpers.user_url(username: build.commit.author.username))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-12-07 07:23:23 -05:00
|
|
|
end
|
|
|
|
end
|