Commit 672dcce2 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'use-commit-author-if-possible' into 'master'

Use Commit#author so we share logic and cache

See merge request !7715
parents 7100b769 9ad2dba2
...@@ -21,10 +21,8 @@ module Gitlab ...@@ -21,10 +21,8 @@ module Gitlab
return if !commit || !commit.author_email return if !commit || !commit.author_email
email = commit.author_email identify_with_cache(:email, commit.author_email) do
commit.author
identify_with_cache(:email, email) do
User.find_by_any_email(email)
end end
end end
......
...@@ -40,7 +40,7 @@ describe Gitlab::Identifier do ...@@ -40,7 +40,7 @@ describe Gitlab::Identifier do
describe '#identify_using_commit' do describe '#identify_using_commit' do
it "returns the User for an existing commit author's Email address" 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) expect(project).to receive(:commit).with('123').and_return(commit)
...@@ -62,10 +62,9 @@ describe Gitlab::Identifier do ...@@ -62,10 +62,9 @@ describe Gitlab::Identifier do
end end
it 'caches the found users per Email' do 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(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 2.times do
expect(identifier.identify_using_commit(project, '123')).to eq(user) expect(identifier.identify_using_commit(project, '123')).to eq(user)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment