diff options
author | Jacob Vosmaer (GitLab) <jacob@gitlab.com> | 2017-10-03 19:53:11 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-10-03 19:53:11 +0300 |
commit | bfd53aa6d087448548c60ec834b7a41dc87ca1e9 (patch) | |
tree | f6cf6b78541efe52423084370bb4bf6c731a80d1 | |
parent | 69fd4f948686f2d0381d5690ac5dbd6e4e411270 (diff) |
Restore User.from_gitaly
-rw-r--r-- | lib/gitlab/git/user.rb | 5 | ||||
-rw-r--r-- | spec/lib/gitlab/git/user_spec.rb | 14 |
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/gitlab/git/user.rb b/lib/gitlab/git/user.rb index cb1af5f3b7c..da74719ae87 100644 --- a/lib/gitlab/git/user.rb +++ b/lib/gitlab/git/user.rb @@ -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 diff --git a/spec/lib/gitlab/git/user_spec.rb b/spec/lib/gitlab/git/user_spec.rb index ab64b041187..31d5f59a562 100644 --- a/spec/lib/gitlab/git/user_spec.rb +++ b/spec/lib/gitlab/git/user_spec.rb @@ -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)) |