Commit 5c4306e7 authored by Rémy Coutable's avatar Rémy Coutable Committed by Alejandro Rodríguez

Merge branch '25251-actionview-template-error-undefined-method-text-for-nil-nilclass' into 'master'

Fixes ActionView::Template::Error: undefined method `text?` for nil:NilClass

Closes #25251

See merge request !7893
parent f087b999
---
title: 'Fixes "ActionView::Template::Error: undefined method `text?` for nil:NilClass"
on MR pages'
merge_request:
author:
...@@ -61,7 +61,7 @@ module Gitlab ...@@ -61,7 +61,7 @@ module Gitlab
end end
def cacheable?(diff_file) def cacheable?(diff_file)
@merge_request_diff.present? && diff_file.blob.text? @merge_request_diff.present? && diff_file.blob && diff_file.blob.text?
end end
def cache_key def cache_key
......
...@@ -10,4 +10,12 @@ describe Gitlab::Diff::FileCollection::MergeRequestDiff do ...@@ -10,4 +10,12 @@ describe Gitlab::Diff::FileCollection::MergeRequestDiff do
described_class.new(merge_request.merge_request_diff, diff_options: nil).diff_files described_class.new(merge_request.merge_request_diff, diff_options: nil).diff_files
end end
it 'does not hightlight file if blob is not accessable' do
allow_any_instance_of(Gitlab::Diff::File).to receive(:blob).and_return(nil)
expect_any_instance_of(Gitlab::Diff::File).not_to receive(:highlighted_diff_lines)
described_class.new(merge_request.merge_request_diff, diff_options: nil).diff_files
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment