Restore User.from_gitaly
This commit is contained in:
parent
69fd4f9486
commit
bfd53aa6d0
2 changed files with 19 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in a new issue