diff options
author | Robert Speicher <robert@gitlab.com> | 2016-10-11 11:41:02 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2016-10-11 11:41:02 +0000 |
commit | 79eb7e4e921e681daf36a225b267c36084160a93 (patch) | |
tree | c19c50f444c43612062b78b9bece3d72707596f5 /spec | |
parent | 2ef90053d8dfc3e5e88f0cee6548117f5dae6f67 (diff) | |
parent | d4fab17d7c8c2b233248295755a6277fdee09c9f (diff) | |
download | gitlab-ce-79eb7e4e921e681daf36a225b267c36084160a93.tar.gz |
Merge branch 'sh-fix-issue-20776' into 'master'
Fix Error 500 when viewing old merge requests with bad diff data
Customers running old versions of GitLab may have MergeRequestDiffs with the text ["--broken diff"] due to text generated by gitlab_git 1.0.3.
To avoid the Error 500, verify that each element is a type that gitlab_git will accept before attempting to create a DiffCollection.
Closes #20776
See merge request !6754
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/merge_request_diff_spec.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/spec/models/merge_request_diff_spec.rb b/spec/models/merge_request_diff_spec.rb index 530a7def553..96f1f60dbc0 100644 --- a/spec/models/merge_request_diff_spec.rb +++ b/spec/models/merge_request_diff_spec.rb @@ -44,6 +44,16 @@ describe MergeRequestDiff, models: true do end end + context 'when the raw diffs have invalid content' do + before { mr_diff.update_attributes(st_diffs: ["--broken-diff"]) } + + it 'returns an empty DiffCollection' do + expect(mr_diff.raw_diffs.to_a).to be_empty + expect(mr_diff.raw_diffs).to be_a(Gitlab::Git::DiffCollection) + expect(mr_diff.raw_diffs).to be_empty + end + end + context 'when the raw diffs exist' do it 'returns the diffs' do expect(mr_diff.raw_diffs).to be_a(Gitlab::Git::DiffCollection) |