Commit 8cd83a82 authored by Gary Holtz's avatar Gary Holtz

Adds some style changes and fixes a performance issue

parent cec88ba6
...@@ -16,7 +16,7 @@ class DiffsEntity < Grape::Entity ...@@ -16,7 +16,7 @@ class DiffsEntity < Grape::Entity
end end
expose :commit do |diffs, options| expose :commit do |diffs, options|
CommitEntity.represent options[:commit], commit_options(options) CommitEntity.represent(options[:commit], commit_options(options))
end end
expose :context_commits, using: API::Entities::Commit, if: -> (diffs, options) { merge_request&.project&.context_commits_enabled? } do |diffs| expose :context_commits, using: API::Entities::Commit, if: -> (diffs, options) { merge_request&.project&.context_commits_enabled? } do |diffs|
...@@ -79,7 +79,7 @@ class DiffsEntity < Grape::Entity ...@@ -79,7 +79,7 @@ class DiffsEntity < Grape::Entity
private private
def commit_ids def commit_ids
@commit_ids ||= merge_request.commits.collect(&:id) @commit_ids ||= merge_request.recent_commits.map(&:id)
end end
def commit_neighbors(commit_id) def commit_neighbors(commit_id)
......
...@@ -54,7 +54,7 @@ describe DiffsEntity do ...@@ -54,7 +54,7 @@ describe DiffsEntity do
let(:commit) { commits.first } let(:commit) { commits.first }
it 'includes commit references for nil and next' do it 'includes commit references for nil and next' do
expect(subject[:commit][:prev_commit_id]).to eq(nil) expect(subject[:commit][:prev_commit_id]).to be_nil
expect(subject[:commit][:next_commit_id]).to eq(commits.second.id) expect(subject[:commit][:next_commit_id]).to eq(commits.second.id)
end end
end end
...@@ -64,7 +64,7 @@ describe DiffsEntity do ...@@ -64,7 +64,7 @@ describe DiffsEntity do
it 'includes commit references for previous and nil' do it 'includes commit references for previous and nil' do
expect(subject[:commit][:prev_commit_id]).to eq(commits[-2].id) expect(subject[:commit][:prev_commit_id]).to eq(commits[-2].id)
expect(subject[:commit][:next_commit_id]).to eq(nil) expect(subject[:commit][:next_commit_id]).to be_nil
end end
end end
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