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

action_view_spec.rb « subscribers « metrics « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 67cd863075884d0edace4e1dfa6cd0d67bff6ad8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Metrics::Subscribers::ActionView do
  let(:env) { {} }
  let(:transaction) { Gitlab::Metrics::WebTransaction.new(env) }

  let(:subscriber) { described_class.new }

  let(:event) do
    root = Rails.root.to_s

    double(:event, duration: 2.1,
                   payload: { identifier: "#{root}/app/views/x.html.haml" })
  end

  before do
    allow(subscriber).to receive(:current_transaction).and_return(transaction)
  end

  describe '#render_template' do
    it 'tracks rendering of a template' do
      expect(transaction).to receive(:increment)
        .with(:gitlab_transaction_view_duration_total, 2.1)

      subscriber.render_template(event)
    end

    it 'observes view rendering time' do
      expect(transaction)
        .to receive(:observe)
        .with(:gitlab_view_rendering_duration_seconds, 2.1, { view: "app/views/x.html.haml" })

      subscriber.render_template(event)
    end
  end
end