diff options
author | Stan Hu <stanhu@gmail.com> | 2016-10-08 08:48:23 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2016-10-10 23:05:09 +0300 |
commit | d4fab17d7c8c2b233248295755a6277fdee09c9f (patch) | |
tree | 4ee583bb9ef541d5e6975d9e36b5b22ffec8b763 /spec | |
parent | a5cd9c9a596c4160bbdc7645f57266655488386c (diff) |
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
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) |