Commit 401b51f7 authored by Sean McGivern's avatar Sean McGivern

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

Fix MR changes tab size count

Closes #27563

See merge request !9091
parents fae2650c 5a2c6881
......@@ -203,7 +203,11 @@ class MergeRequest < ActiveRecord::Base
end
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
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
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
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