2015-04-26 12:48:37 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2016-09-13 17:45:13 +05:30
|
|
|
describe Gitlab::DataBuilder::Push, lib: true do
|
2017-08-17 22:00:37 +05:30
|
|
|
let(:project) { create(:project, :repository) }
|
2015-04-26 12:48:37 +05:30
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
2016-04-02 18:10:28 +05:30
|
|
|
describe '.build_sample' do
|
|
|
|
let(:data) { described_class.build_sample(project, user) }
|
2015-04-26 12:48:37 +05:30
|
|
|
|
|
|
|
it { expect(data).to be_a(Hash) }
|
2016-11-03 12:29:30 +05:30
|
|
|
it { expect(data[:before]).to eq('1b12f15a11fc6e62177bef08f47bc7b5ce50b141') }
|
|
|
|
it { expect(data[:after]).to eq('b83d6e391c22777fca1ed3012fce84f633d7fed0') }
|
2015-04-26 12:48:37 +05:30
|
|
|
it { expect(data[:ref]).to eq('refs/heads/master') }
|
|
|
|
it { expect(data[:commits].size).to eq(3) }
|
|
|
|
it { expect(data[:total_commits_count]).to eq(3) }
|
2016-11-03 12:29:30 +05:30
|
|
|
it { expect(data[:commits].first[:added]).to eq(['bar/branch-test.txt']) }
|
|
|
|
it { expect(data[:commits].first[:modified]).to eq([]) }
|
2015-12-23 02:04:40 +05:30
|
|
|
it { expect(data[:commits].first[:removed]).to eq([]) }
|
2016-04-02 18:10:28 +05:30
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
include_examples 'project hook data with deprecateds'
|
2016-04-02 18:10:28 +05:30
|
|
|
include_examples 'deprecated repository hook data'
|
2015-04-26 12:48:37 +05:30
|
|
|
end
|
|
|
|
|
2016-04-02 18:10:28 +05:30
|
|
|
describe '.build' do
|
2015-04-26 12:48:37 +05:30
|
|
|
let(:data) do
|
2016-04-02 18:10:28 +05:30
|
|
|
described_class.build(project, user, Gitlab::Git::BLANK_SHA,
|
|
|
|
'8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b',
|
|
|
|
'refs/tags/v1.1.0')
|
2015-04-26 12:48:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(data).to be_a(Hash) }
|
|
|
|
it { expect(data[:before]).to eq(Gitlab::Git::BLANK_SHA) }
|
|
|
|
it { expect(data[:checkout_sha]).to eq('5937ac0a7beb003549fc5fd26fc247adbce4a52e') }
|
|
|
|
it { expect(data[:after]).to eq('8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b') }
|
|
|
|
it { expect(data[:ref]).to eq('refs/tags/v1.1.0') }
|
2016-06-02 11:05:42 +05:30
|
|
|
it { expect(data[:user_id]).to eq(user.id) }
|
|
|
|
it { expect(data[:user_name]).to eq(user.name) }
|
|
|
|
it { expect(data[:user_email]).to eq(user.email) }
|
|
|
|
it { expect(data[:user_avatar]).to eq(user.avatar_url) }
|
|
|
|
it { expect(data[:project_id]).to eq(project.id) }
|
|
|
|
it { expect(data[:project]).to be_a(Hash) }
|
2015-04-26 12:48:37 +05:30
|
|
|
it { expect(data[:commits]).to be_empty }
|
|
|
|
it { expect(data[:total_commits_count]).to be_zero }
|
2016-04-02 18:10:28 +05:30
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
include_examples 'project hook data with deprecateds'
|
|
|
|
include_examples 'deprecated repository hook data'
|
|
|
|
|
2016-04-02 18:10:28 +05:30
|
|
|
it 'does not raise an error when given nil commits' do
|
|
|
|
expect { described_class.build(spy, spy, spy, spy, spy, nil) }.
|
|
|
|
not_to raise_error
|
|
|
|
end
|
2015-04-26 12:48:37 +05:30
|
|
|
end
|
|
|
|
end
|