gitlab-org--gitlab-foss/spec/lib/gitlab/metrics/subscribers/action_view_spec.rb
Yorick Peterse 7ed3a5a240 Revert "Store SQL/view timings in milliseconds"
This reverts commit 7549102bb7.

Apparently I was wrong about
ActiveSupport::Notifications::Event#duration returning the duration in
seconds, instead it returns it in milliseconds already.
2016-01-07 11:47:06 +01:00

40 lines
1 KiB
Ruby

require 'spec_helper'
describe Gitlab::Metrics::Subscribers::ActionView do
let(:transaction) { Gitlab::Metrics::Transaction.new }
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)
allow(Gitlab::Metrics).to receive(:last_relative_application_frame).
and_return(['app/views/x.html.haml', 4])
end
describe '#render_template' do
it 'tracks rendering of a template' do
values = { duration: 2.1 }
tags = {
view: 'app/views/x.html.haml',
file: 'app/views/x.html.haml',
line: 4
}
expect(transaction).to receive(:increment).
with(:view_duration, 2.1)
expect(transaction).to receive(:add_metric).
with(described_class::SERIES, values, tags)
subscriber.render_template(event)
end
end
end