diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2016-04-20 23:42:52 +0300 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2016-04-20 23:42:52 +0300 |
commit | a257d117a05e0a9eaaef305990335ee7c85cd7a8 (patch) | |
tree | 474384dce916b4d5ae3888b2ecb199bfec401e71 /spec/lib | |
parent | 832cdd3d516698d0e6a7257b3d94292819a0436a (diff) |
Fix setting of "action" for Grape transactions
Merely setting the "action" tag will only result in the transaction
itself containing a value for this tag. To ensure other metrics also
contain this tag we must set the action using Transaction#action=
instead.
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/metrics_spec.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/lib/gitlab/metrics_spec.rb b/spec/lib/gitlab/metrics_spec.rb index 10177c0e8dd..96f7eabbca6 100644 --- a/spec/lib/gitlab/metrics_spec.rb +++ b/spec/lib/gitlab/metrics_spec.rb @@ -123,4 +123,28 @@ describe Gitlab::Metrics do end end end + + describe '.action=' do + context 'without a transaction' do + it 'does nothing' do + expect_any_instance_of(Gitlab::Metrics::Transaction). + not_to receive(:action=) + + Gitlab::Metrics.action = 'foo' + end + end + + context 'with a transaction' do + it 'sets the action of a transaction' do + trans = Gitlab::Metrics::Transaction.new + + expect(Gitlab::Metrics).to receive(:current_transaction). + and_return(trans) + + expect(trans).to receive(:action=).with('foo') + + Gitlab::Metrics.action = 'foo' + end + end + end end |