Commit c277aac9 authored by Alejandro Rodríguez's avatar Alejandro Rodríguez

Don't do a commit lookup to present the MR entity, just return the sha

The MergeRequestWidgetEntity is used a lot in AJAX requests, and shaving
that git operation will hopefully translate in a performance improvement
parent bc365bd1
......@@ -38,7 +38,7 @@ class MergeRequestWidgetEntity < IssuableEntity
# Diff sha's
expose :diff_head_sha do |merge_request|
merge_request.diff_head_sha if merge_request.diff_head_commit
merge_request.diff_head_sha.presence
end
expose :merge_commit_message
......
......@@ -147,9 +147,9 @@ describe MergeRequestWidgetEntity do
allow(resource).to receive(:diff_head_sha) { 'sha' }
end
context 'when no diff head commit' do
context 'when diff head commit is empty' do
it 'returns nil' do
allow(resource).to receive(:diff_head_commit) { nil }
allow(resource).to receive(:diff_head_sha) { '' }
expect(subject[:diff_head_sha]).to be_nil
end
......@@ -157,8 +157,6 @@ describe MergeRequestWidgetEntity do
context 'when diff head commit present' do
it 'returns diff head commit short id' do
allow(resource).to receive(:diff_head_commit) { double }
expect(subject[:diff_head_sha]).to eq('sha')
end
end
......
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