diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-20 18:09:18 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-20 18:09:18 +0300 |
commit | 364f6f2e33e6f5eafe63b25d9256b88e72141b1c (patch) | |
tree | ee6dc003a354e7466d5c45e5587c0f8172312122 /spec/lib/gitlab/request_context_spec.rb | |
parent | 98252e0dd60cbcb316231085e206d9872f243b8a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/request_context_spec.rb')
-rw-r--r-- | spec/lib/gitlab/request_context_spec.rb | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/spec/lib/gitlab/request_context_spec.rb b/spec/lib/gitlab/request_context_spec.rb index 1290071549d..5785dbfd850 100644 --- a/spec/lib/gitlab/request_context_spec.rb +++ b/spec/lib/gitlab/request_context_spec.rb @@ -10,10 +10,12 @@ describe Gitlab::RequestContext, :request_store do describe '#request_deadline' do let(:request_start_time) { 1575982156.206008 } - it "sets the time to #{Settings.gitlab.max_request_duration_seconds} seconds in the future" do + before do allow(subject).to receive(:request_start_time).and_return(request_start_time) + end - expect(subject.request_deadline).to eq(1575982156.206008 + Settings.gitlab.max_request_duration_seconds) + it "sets the time to #{Settings.gitlab.max_request_duration_seconds} seconds in the future" do + expect(subject.request_deadline).to eq(request_start_time + Settings.gitlab.max_request_duration_seconds) expect(subject.request_deadline).to be_a(Float) end @@ -22,6 +24,18 @@ describe Gitlab::RequestContext, :request_store do expect(subject.request_deadline).to be_nil end + + it 'only checks the feature once per request-instance' do + expect(Feature).to receive(:enabled?).with(:request_deadline).once + + 2.times { subject.request_deadline } + end + + it 'returns nil when the feature is disabled' do + stub_feature_flags(request_deadline: false) + + expect(subject.request_deadline).to be_nil + end end describe '#ensure_request_deadline_not_exceeded!' do |