Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/sherlock/middleware_spec.rb')
-rw-r--r--spec/lib/gitlab/sherlock/middleware_spec.rb81
1 files changed, 0 insertions, 81 deletions
diff --git a/spec/lib/gitlab/sherlock/middleware_spec.rb b/spec/lib/gitlab/sherlock/middleware_spec.rb
deleted file mode 100644
index 645bde6681d..00000000000
--- a/spec/lib/gitlab/sherlock/middleware_spec.rb
+++ /dev/null
@@ -1,81 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Gitlab::Sherlock::Middleware do
- let(:app) { double(:app) }
- let(:middleware) { described_class.new(app) }
-
- describe '#call' do
- describe 'when instrumentation is enabled' do
- it 'instruments a request' do
- allow(middleware).to receive(:instrument?).and_return(true)
- allow(middleware).to receive(:call_with_instrumentation)
-
- middleware.call({})
- end
- end
-
- describe 'when instrumentation is disabled' do
- it "doesn't instrument a request" do
- allow(middleware).to receive(:instrument).and_return(false)
- allow(app).to receive(:call)
-
- middleware.call({})
- end
- end
- end
-
- describe '#call_with_instrumentation' do
- it 'instruments a request' do
- trans = double(:transaction)
- retval = 'cats are amazing'
- env = {}
-
- allow(app).to receive(:call).with(env).and_return(retval)
- allow(middleware).to receive(:transaction_from_env).and_return(trans)
- allow(trans).to receive(:run).and_yield.and_return(retval)
- allow(Gitlab::Sherlock.collection).to receive(:add).with(trans)
-
- middleware.call_with_instrumentation(env)
- end
- end
-
- describe '#instrument?' do
- it 'returns false for a text/css request' do
- env = { 'HTTP_ACCEPT' => 'text/css', 'REQUEST_URI' => '/' }
-
- expect(middleware.instrument?(env)).to eq(false)
- end
-
- it 'returns false for a request to a Sherlock route' do
- env = {
- 'HTTP_ACCEPT' => 'text/html',
- 'REQUEST_URI' => '/sherlock/transactions'
- }
-
- expect(middleware.instrument?(env)).to eq(false)
- end
-
- it 'returns true for a request that should be instrumented' do
- env = {
- 'HTTP_ACCEPT' => 'text/html',
- 'REQUEST_URI' => '/cats'
- }
-
- expect(middleware.instrument?(env)).to eq(true)
- end
- end
-
- describe '#transaction_from_env' do
- it 'returns a Transaction' do
- env = {
- 'HTTP_ACCEPT' => 'text/html',
- 'REQUEST_URI' => '/cats'
- }
-
- expect(middleware.transaction_from_env(env))
- .to be_an_instance_of(Gitlab::Sherlock::Transaction)
- end
- end
-end