diff options
author | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2016-03-03 18:38:44 +0100 |
---|---|---|
committer | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2016-03-03 18:38:44 +0100 |
commit | 1764e1b7cb2bffb9b4c4a69991fe2c4d21ce5459 (patch) | |
tree | b48ca1bad0532a37a19f00f0903a778109a16a3d /spec/helpers/diff_helper_spec.rb | |
parent | e1bc808746523309476913033b104345c06c4816 (diff) | |
download | gitlab-ce-1764e1b7cb2bffb9b4c4a69991fe2c4d21ce5459.tar.gz |
Use Gitlab::Git::DiffCollections
Diffstat (limited to 'spec/helpers/diff_helper_spec.rb')
-rw-r--r-- | spec/helpers/diff_helper_spec.rb | 57 |
1 files changed, 3 insertions, 54 deletions
diff --git a/spec/helpers/diff_helper_spec.rb b/spec/helpers/diff_helper_spec.rb index 14986a74c2e..982c113e84b 100644 --- a/spec/helpers/diff_helper_spec.rb +++ b/spec/helpers/diff_helper_spec.rb @@ -22,65 +22,14 @@ describe DiffHelper do end end - describe 'allowed_diff_size' do + describe 'diff_options' do it 'should return hard limit for a diff if force diff is true' do allow(controller).to receive(:params) { { force_show_diff: true } } - expect(allowed_diff_size).to eq(1000) + expect(diff_options).to include(Commit.max_diff_options) end it 'should return safe limit for a diff if force diff is false' do - expect(allowed_diff_size).to eq(100) - end - end - - describe 'allowed_diff_lines' do - it 'should return hard limit for number of lines in a diff if force diff is true' do - allow(controller).to receive(:params) { { force_show_diff: true } } - expect(allowed_diff_lines).to eq(50000) - end - - it 'should return safe limit for numbers of lines a diff if force diff is false' do - expect(allowed_diff_lines).to eq(5000) - end - end - - describe 'safe_diff_files' do - it 'should return all files from a commit that is smaller than safe limits' do - expect(safe_diff_files(diffs, diff_refs).length).to eq(2) - end - - it 'should return only the first file if the diff line count in the 2nd file takes the total beyond safe limits' do - allow(diffs[1].diff).to receive(:lines).and_return([""] * 4999) #simulate 4999 lines - expect(safe_diff_files(diffs, diff_refs).length).to eq(1) - end - - it 'should return all files from a commit that is beyond safe limit for numbers of lines if force diff is true' do - allow(controller).to receive(:params) { { force_show_diff: true } } - allow(diffs[1].diff).to receive(:lines).and_return([""] * 4999) #simulate 4999 lines - expect(safe_diff_files(diffs, diff_refs).length).to eq(2) - end - - it 'should return only the first file if the diff line count in the 2nd file takes the total beyond hard limits' do - allow(controller).to receive(:params) { { force_show_diff: true } } - allow(diffs[1].diff).to receive(:lines).and_return([""] * 49999) #simulate 49999 lines - expect(safe_diff_files(diffs, diff_refs).length).to eq(1) - end - - it 'should return only a safe number of file diffs if a commit touches more files than the safe limits' do - large_diffs = diffs * 100 #simulate 200 diffs - expect(safe_diff_files(large_diffs, diff_refs).length).to eq(100) - end - - it 'should return all file diffs if a commit touches more files than the safe limits but force diff is true' do - allow(controller).to receive(:params) { { force_show_diff: true } } - large_diffs = diffs * 100 #simulate 200 diffs - expect(safe_diff_files(large_diffs, diff_refs).length).to eq(200) - end - - it 'should return a limited file diffs if a commit touches more files than the hard limits and force diff is true' do - allow(controller).to receive(:params) { { force_show_diff: true } } - very_large_diffs = diffs * 1000 #simulate 2000 diffs - expect(safe_diff_files(very_large_diffs, diff_refs).length).to eq(1000) + expect(diff_options).not_to include(:max_lines, :max_files) end end |