summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@gitlab.com>2018-10-01 16:48:00 +0000
committerBob Van Landuyt <bob@gitlab.com>2018-10-01 16:48:00 +0000
commit7cb9957a33d37394cd884106865e4aedef519e97 (patch)
treef7eb746219c254d0bd0e139a0a382d5baf9aed2c /spec
parentbfd3062cd3479beedb327e8fed04767f52c5c135 (diff)
parent3bfc08be9130fef1f07462d543d559f5c7f533a6 (diff)
downloadgitlab-ce-7cb9957a33d37394cd884106865e4aedef519e97.tar.gz
Merge branch 'security-2697-code-highlight-timeout' into 'master'
[master] Fix syntax highlight taking too long Closes #2697 See merge request gitlab/gitlabhq!2467
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/highlight_spec.rb17
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