diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-01-17 15:56:10 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-01-17 15:56:10 +0000 |
commit | e324ccc20c52d492dd660097a4c72615c5621917 (patch) | |
tree | d3449ff9db8372a2e507e22c1924cd693e75c23f /spec | |
parent | cfdae8f103568d843afb3c714444c912510a5f1f (diff) | |
parent | ca0cf5a3cd2829db4cfac007c36d5588ed369f87 (diff) | |
download | gitlab-ce-e324ccc20c52d492dd660097a4c72615c5621917.tar.gz |
Merge branch 'issue_25017' into 'master'
Show 'too many changes' message for merge request
Closes #25017
See merge request !8444
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/merge_requests/diffs_spec.rb | 14 | ||||
-rw-r--r-- | spec/models/merge_request_diff_spec.rb | 26 |
2 files changed, 40 insertions, 0 deletions
diff --git a/spec/features/merge_requests/diffs_spec.rb b/spec/features/merge_requests/diffs_spec.rb index c9a0059645d..4a6c76a5caf 100644 --- a/spec/features/merge_requests/diffs_spec.rb +++ b/spec/features/merge_requests/diffs_spec.rb @@ -22,4 +22,18 @@ feature 'Diffs URL', js: true, feature: true do expect(page).to have_css('.diffs.tab-pane.active') end end + + context 'when merge request has overflow' do + it 'displays warning' do + allow_any_instance_of(MergeRequestDiff).to receive(:overflow?).and_return(true) + allow(Commit).to receive(:max_diff_options).and_return(max_files: 20, max_lines: 20) + + visit diffs_namespace_project_merge_request_path(@project.namespace, @project, @merge_request) + + page.within('.alert') do + expect(page).to have_text("Too many changes to show. Plain diff Email patch To preserve + performance only 3 of 3+ files are displayed.") + end + end + end end diff --git a/spec/models/merge_request_diff_spec.rb b/spec/models/merge_request_diff_spec.rb index eb876d105da..6d599e148a2 100644 --- a/spec/models/merge_request_diff_spec.rb +++ b/spec/models/merge_request_diff_spec.rb @@ -76,6 +76,32 @@ describe MergeRequestDiff, models: true do end end + describe '#save_diffs' do + it 'saves collected state' do + mr_diff = create(:merge_request).merge_request_diff + + expect(mr_diff.collected?).to be_truthy + end + + it 'saves overflow state' do + allow(Commit).to receive(:max_diff_options) + .and_return(max_lines: 0, max_files: 0) + + mr_diff = create(:merge_request).merge_request_diff + + expect(mr_diff.overflow?).to be_truthy + end + + it 'saves empty state' do + allow_any_instance_of(MergeRequestDiff).to receive(:commits) + .and_return([]) + + mr_diff = create(:merge_request).merge_request_diff + + expect(mr_diff.empty?).to be_truthy + end + end + describe '#commits_sha' do it 'returns all commits SHA using serialized commits' do subject.st_commits = [ |