Merge branch 'restore-user-from-gitaly' into 'master'

Restore User.from_gitaly

See merge request gitlab-org/gitlab-ce!14662
This commit is contained in:
Douwe Maan 2017-10-03 16:53:11 +00:00
commit 6e0d17b8c6
2 changed files with 19 additions and 0 deletions

View file

@ -7,6 +7,11 @@ module Gitlab
new(gitlab_user.username, gitlab_user.name, gitlab_user.email, Gitlab::GlId.gl_id(gitlab_user))
end
# TODO support the username field in Gitaly https://gitlab.com/gitlab-org/gitaly/issues/628
def self.from_gitaly(gitaly_user)
new('', gitaly_user.name, gitaly_user.email, gitaly_user.gl_id)
end
def initialize(username, name, email, gl_id)
@username = username
@name = name

View file

@ -8,6 +8,20 @@ describe Gitlab::Git::User do
subject { described_class.new(username, name, email, gl_id) }
describe '.from_gitaly' do
let(:gitaly_user) { Gitaly::User.new(name: name, email: email, gl_id: gl_id) }
subject { described_class.from_gitaly(gitaly_user) }
it { expect(subject).to eq(described_class.new('', name, email, gl_id)) }
end
describe '.from_gitlab' do
let(:user) { build(:user) }
subject { described_class.from_gitlab(user) }
it { expect(subject).to eq(described_class.new(user.username, user.name, user.email, 'user-')) }
end
describe '#==' do
def eq_other(username, name, email, gl_id)
eq(described_class.new(username, name, email, gl_id))