summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2018-01-30 15:17:44 +0000
committerSean McGivern <sean@gitlab.com>2018-01-30 15:17:44 +0000
commit382421a9bed1ef0fd1e97f6dcec8a104342ae1d8 (patch)
tree2be2a81e676fadc4d12e7e2a2e76e7433759da93 /spec
parente74e6fcb5eecb7841a412cb0d3e9627556d83eaf (diff)
downloadgitlab-ce-382421a9bed1ef0fd1e97f6dcec8a104342ae1d8.tar.gz
Fix truncated_diff_lines for legacy notes without a line42160-error-500-loading-merge-request-undefined-method-index-for-nil-nilclass
It appears that some legacy diff notes on GitLab.com have invalid line codes, which means truncated_diff_lines won't work. This is just a band-aid solution, as neither the diff nor the discussion will display correctly for these notes, but they won't cause a 500 error.
Diffstat (limited to 'spec')
-rw-r--r--spec/models/concerns/discussion_on_diff_spec.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/spec/models/concerns/discussion_on_diff_spec.rb b/spec/models/concerns/discussion_on_diff_spec.rb
index 2322eb206fb..30572ce9332 100644
--- a/spec/models/concerns/discussion_on_diff_spec.rb
+++ b/spec/models/concerns/discussion_on_diff_spec.rb
@@ -20,6 +20,16 @@ describe DiscussionOnDiff do
expect(truncated_lines).not_to include(be_meta)
end
end
+
+ context "when the diff line does not exist on a legacy diff note" do
+ it "returns an empty array" do
+ legacy_note = LegacyDiffNote.new
+
+ allow(subject).to receive(:first_note).and_return(legacy_note)
+
+ expect(truncated_lines).to eq([])
+ end
+ end
end
describe '#line_code_in_diffs' do