diff options
Diffstat (limited to 'spec/lib/gitlab/other_markup_spec.rb')
-rw-r--r-- | spec/lib/gitlab/other_markup_spec.rb | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/spec/lib/gitlab/other_markup_spec.rb b/spec/lib/gitlab/other_markup_spec.rb index 26e60251abb..6b24c8a8710 100644 --- a/spec/lib/gitlab/other_markup_spec.rb +++ b/spec/lib/gitlab/other_markup_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe Gitlab::OtherMarkup do let(:context) { {} } - context "XSS Checks" do + context 'XSS Checks' do links = { 'links' => { file: 'file.rdoc', @@ -20,6 +20,33 @@ RSpec.describe Gitlab::OtherMarkup do end end + context 'when rendering takes too long' do + let_it_be(:file_name) { 'foo.bar' } + let_it_be(:project) { create(:project, :repository) } + let_it_be(:context) { { project: project } } + let_it_be(:text) { +'Noël' } + + before do + stub_const('Gitlab::OtherMarkup::RENDER_TIMEOUT', 0.1) + allow(GitHub::Markup).to receive(:render) do + sleep(0.2) + text + end + end + + it 'times out' do + # expect twice because of timeout in SyntaxHighlightFilter + expect(Gitlab::RenderTimeout).to receive(:timeout).twice.and_call_original + expect(Gitlab::ErrorTracking).to receive(:track_exception).with( + instance_of(Timeout::Error), + project_id: context[:project].id, file_name: file_name, + class_name: described_class.name.demodulize + ) + + expect(render(file_name, text, context)).to eq("<p>#{text}</p>") + end + end + def render(*args) described_class.render(*args) end |