diff options
author | Mark Chao <mchao@gitlab.com> | 2018-08-16 18:27:20 +0300 |
---|---|---|
committer | Mark Chao <mchao@gitlab.com> | 2018-09-03 06:02:43 +0300 |
commit | 3bfc08be9130fef1f07462d543d559f5c7f533a6 (patch) | |
tree | 642a48769adb0eb6942680b166a1500ebcc8e75b /spec/lib/gitlab/highlight_spec.rb | |
parent | ba99dfcde262c91e33b5bf7f86ba7c0e3b6f7e52 (diff) |
Fix syntax highlight taking too long
Use Timeout to switch to plain rendering
Diffstat (limited to 'spec/lib/gitlab/highlight_spec.rb')
-rw-r--r-- | spec/lib/gitlab/highlight_spec.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/lib/gitlab/highlight_spec.rb b/spec/lib/gitlab/highlight_spec.rb index 29e61d15726..88f7099ff3c 100644 --- a/spec/lib/gitlab/highlight_spec.rb +++ b/spec/lib/gitlab/highlight_spec.rb @@ -56,5 +56,22 @@ describe Gitlab::Highlight do described_class.highlight('file.name', 'Contents') end + + context 'timeout' do + subject { described_class.new('file.name', 'Contents') } + + it 'utilizes timeout for web' do + expect(Timeout).to receive(:timeout).with(described_class::TIMEOUT_FOREGROUND).and_call_original + + subject.highlight("Content") + end + + it 'utilizes longer timeout for sidekiq' do + allow(Sidekiq).to receive(:server?).and_return(true) + expect(Timeout).to receive(:timeout).with(described_class::TIMEOUT_BACKGROUND).and_call_original + + subject.highlight("Content") + end + end end end |