Commit 8469644a authored by Eduardo Bonet's avatar Eduardo Bonet Committed by Alex Kalderimis

Resolve "ActionView::Template::Error: 4:Deadline Exceeded."

Changelog: performance
parent bb7d9a36
......@@ -375,7 +375,7 @@ module Gitlab
end
def rendered
return unless use_renderable_diff? && ipynb?
return unless use_renderable_diff? && ipynb? && modified_file? && !too_large?
strong_memoize(:rendered) { Rendered::Notebook::DiffFile.new(self) }
end
......@@ -410,7 +410,7 @@ module Gitlab
end
def ipynb?
modified_file? && file_path.ends_with?('.ipynb')
file_path.ends_with?('.ipynb')
end
# We can't use Object#try because Blob doesn't inherit from Object, but
......
......@@ -76,10 +76,34 @@ RSpec.describe Gitlab::Diff::File do
end
describe '#rendered' do
let(:commit) { project.commit("532c837") }
context 'when not ipynb' do
it 'is nil' do
expect(diff_file.rendered).to be_nil
end
end
context 'when ipynb' do
let(:commit) { project.commit("532c837") }
it 'creates a NotebookDiffFile for rendering' do
expect(diff_file.rendered).to be_kind_of(Gitlab::Diff::Rendered::Notebook::DiffFile)
end
it 'creates a NotebookDiffFile for rendering' do
expect(diff_file.rendered).to be_kind_of(Gitlab::Diff::Rendered::Notebook::DiffFile)
context 'when too large' do
it 'is nil' do
expect(diff).to receive(:too_large?).and_return(true)
expect(diff_file.rendered).to be_nil
end
end
context 'when not modified' do
it 'is nil' do
expect(diff_file).to receive(:modified_file?).and_return(false)
expect(diff_file.rendered).to be_nil
end
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