Commit 01deb116 authored by Sean McGivern's avatar Sean McGivern Committed by Ruben Davila

Merge branch 'fix-mr-size-with-over-100-files' into 'master'

Fix MR changes tab size count

Closes #27563

See merge request !9091
parent 4269d6bc
...@@ -203,7 +203,11 @@ class MergeRequest < ActiveRecord::Base ...@@ -203,7 +203,11 @@ class MergeRequest < ActiveRecord::Base
end end
def diff_size def diff_size
opts = diff_options || {} # The `#diffs` method ends up at an instance of a class inheriting from
# `Gitlab::Diff::FileCollection::Base`, so use those options as defaults
# here too, to get the same diff size without performing highlighting.
#
opts = Gitlab::Diff::FileCollection::Base.default_options.merge(diff_options || {})
raw_diffs(opts).size raw_diffs(opts).size
end end
......
---
title: Fix MR changes tab size count when there are over 100 files in the diff
merge_request:
author:
...@@ -209,6 +209,50 @@ describe MergeRequest, models: true do ...@@ -209,6 +209,50 @@ describe MergeRequest, models: true do
end end
end end
describe '#diff_size' do
let(:merge_request) do
build(:merge_request, source_branch: 'expand-collapse-files', target_branch: 'master')
end
context 'when there are MR diffs' do
before do
merge_request.save
end
it 'returns the correct count' do
expect(merge_request.diff_size).to eq(105)
end
it 'does not perform highlighting' do
expect(Gitlab::Diff::Highlight).not_to receive(:new)
merge_request.diff_size
end
end
context 'when there are no MR diffs' do
before do
merge_request.compare = CompareService.new(
merge_request.source_project,
merge_request.source_branch
).execute(
merge_request.target_project,
merge_request.target_branch
)
end
it 'returns the correct count' do
expect(merge_request.diff_size).to eq(105)
end
it 'does not perform highlighting' do
expect(Gitlab::Diff::Highlight).not_to receive(:new)
merge_request.diff_size
end
end
end
describe "#related_notes" do describe "#related_notes" do
let!(:merge_request) { create(:merge_request) } let!(:merge_request) { create(:merge_request) }
......
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