Fix the incorrect value being used to set GL_USERNAME on hooks
This commit is contained in:
parent
3ddffec0d6
commit
42a45392a9
|
@ -8,7 +8,7 @@ module Gitlab
|
|||
def execute(pusher, repository, oldrev, newrev, ref)
|
||||
@repository = repository
|
||||
@gl_id = pusher.gl_id
|
||||
@gl_username = pusher.name
|
||||
@gl_username = pusher.username
|
||||
@oldrev = oldrev
|
||||
@newrev = newrev
|
||||
@ref = ref
|
||||
|
|
|
@ -1,24 +1,26 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::Git::HooksService, seed_helper: true do
|
||||
let(:user) { Gitlab::Git::User.new('janedoe', 'Jane Doe', 'janedoe@example.com', 'user-456') }
|
||||
let(:gl_id) { 'user-456' }
|
||||
let(:gl_username) { 'janedoe' }
|
||||
let(:user) { Gitlab::Git::User.new(gl_username, 'Jane Doe', 'janedoe@example.com', gl_id) }
|
||||
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, 'project-123') }
|
||||
let(:service) { described_class.new }
|
||||
|
||||
before do
|
||||
@blankrev = Gitlab::Git::BLANK_SHA
|
||||
@oldrev = SeedRepo::Commit::PARENT_ID
|
||||
@newrev = SeedRepo::Commit::ID
|
||||
@ref = 'refs/heads/feature'
|
||||
end
|
||||
let(:blankrev) { Gitlab::Git::BLANK_SHA }
|
||||
let(:oldrev) { SeedRepo::Commit::PARENT_ID }
|
||||
let(:newrev) { SeedRepo::Commit::ID }
|
||||
let(:ref) { 'refs/heads/feature' }
|
||||
|
||||
describe '#execute' do
|
||||
context 'when receive hooks were successful' do
|
||||
it 'calls post-receive hook' do
|
||||
hook = double(trigger: [true, nil])
|
||||
expect(Gitlab::Git::Hook).to receive(:new).exactly(3).times.and_return(hook)
|
||||
let(:hook) { double(:hook) }
|
||||
|
||||
service.execute(user, repository, @blankrev, @newrev, @ref) { }
|
||||
it 'calls all three hooks' do
|
||||
expect(Gitlab::Git::Hook).to receive(:new).exactly(3).times.and_return(hook)
|
||||
expect(hook).to receive(:trigger).with(gl_id, gl_username, blankrev, newrev, ref)
|
||||
.exactly(3).times.and_return([true, nil])
|
||||
|
||||
service.execute(user, repository, blankrev, newrev, ref) { }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -28,7 +30,7 @@ describe Gitlab::Git::HooksService, seed_helper: true do
|
|||
expect(service).not_to receive(:run_hook).with('post-receive')
|
||||
|
||||
expect do
|
||||
service.execute(user, repository, @blankrev, @newrev, @ref)
|
||||
service.execute(user, repository, blankrev, newrev, ref)
|
||||
end.to raise_error(Gitlab::Git::HooksService::PreReceiveError)
|
||||
end
|
||||
end
|
||||
|
@ -40,7 +42,7 @@ describe Gitlab::Git::HooksService, seed_helper: true do
|
|||
expect(service).not_to receive(:run_hook).with('post-receive')
|
||||
|
||||
expect do
|
||||
service.execute(user, repository, @blankrev, @newrev, @ref)
|
||||
service.execute(user, repository, blankrev, newrev, ref)
|
||||
end.to raise_error(Gitlab::Git::HooksService::PreReceiveError)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue