Commit af19d56f authored by Rémy Coutable's avatar Rémy Coutable

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
parents 2df878f1 f5d7a617
---
title: 'Fixes "ActionView::Template::Error: undefined method `text?` for nil:NilClass"
on MR pages'
merge_request:
author:
......@@ -61,7 +61,7 @@ module Gitlab
end
def cacheable?(diff_file)
@merge_request_diff.present? && diff_file.blob.text?
@merge_request_diff.present? && diff_file.blob && diff_file.blob.text?
end
def cache_key
......
......@@ -10,4 +10,12 @@ describe Gitlab::Diff::FileCollection::MergeRequestDiff do
described_class.new(merge_request.merge_request_diff, diff_options: nil).diff_files
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
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