summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2016-11-23 19:34:53 +0000
committerSean McGivern <sean@mcgivern.me.uk>2016-11-23 19:34:53 +0000
commit672dcce21d8913fce6031132011f2c93e7650de1 (patch)
treeb609952bf3317067891f0189ef81441fe5cc381a
parent7100b76923fc88667b1bd22b34f0a43323fe84b0 (diff)
parent9ad2dba250e3facc18ff2f21217ebe006451dd8c (diff)
downloadgitlab-ce-672dcce21d8913fce6031132011f2c93e7650de1.tar.gz
Merge branch 'use-commit-author-if-possible' into 'master'
Use Commit#author so we share logic and cache See merge request !7715
-rw-r--r--lib/gitlab/identifier.rb6
-rw-r--r--spec/lib/gitlab/identifier_spec.rb5
2 files changed, 4 insertions, 7 deletions
diff --git a/lib/gitlab/identifier.rb b/lib/gitlab/identifier.rb
index c5acf18beb5..94678b6ec40 100644
--- a/lib/gitlab/identifier.rb
+++ b/lib/gitlab/identifier.rb
@@ -21,10 +21,8 @@ module Gitlab
return if !commit || !commit.author_email
- email = commit.author_email
-
- identify_with_cache(:email, email) do
- User.find_by_any_email(email)
+ identify_with_cache(:email, commit.author_email) do
+ commit.author
end
end
diff --git a/spec/lib/gitlab/identifier_spec.rb b/spec/lib/gitlab/identifier_spec.rb
index f42c4453dd1..bb758a8a202 100644
--- a/spec/lib/gitlab/identifier_spec.rb
+++ b/spec/lib/gitlab/identifier_spec.rb
@@ -40,7 +40,7 @@ describe Gitlab::Identifier do
describe '#identify_using_commit' do
it "returns the User for an existing commit author's Email address" do
- commit = double(:commit, author_email: user.email)
+ commit = double(:commit, author: user, author_email: user.email)
expect(project).to receive(:commit).with('123').and_return(commit)
@@ -62,10 +62,9 @@ describe Gitlab::Identifier do
end
it 'caches the found users per Email' do
- commit = double(:commit, author_email: user.email)
+ commit = double(:commit, author: user, author_email: user.email)
expect(project).to receive(:commit).with('123').twice.and_return(commit)
- expect(User).to receive(:find_by_any_email).once.and_call_original
2.times do
expect(identifier.identify_using_commit(project, '123')).to eq(user)