diff options
Diffstat (limited to 'spec/lib/gitlab/usage_data_spec.rb')
-rw-r--r-- | spec/lib/gitlab/usage_data_spec.rb | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/spec/lib/gitlab/usage_data_spec.rb b/spec/lib/gitlab/usage_data_spec.rb index 214331e15e8..592ac280d32 100644 --- a/spec/lib/gitlab/usage_data_spec.rb +++ b/spec/lib/gitlab/usage_data_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Gitlab::UsageData, :aggregate_failures do +RSpec.describe Gitlab::UsageData, :aggregate_failures, feature_category: :service_ping do include UsageDataHelpers before do @@ -1122,12 +1122,20 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do end end - describe ".with_duration" do + describe ".with_metadata" do it 'records duration' do - expect(::Gitlab::Usage::ServicePing::LegacyMetricTimingDecorator) - .to receive(:new).with(2, kind_of(Float)) + result = described_class.with_metadata { 1 + 1 } - described_class.with_duration { 1 + 1 } + expect(result.duration).to be_an(Float) + end + + it 'records error and returns nil', :aggregated_errors do + allow(Gitlab::ErrorTracking).to receive(:track_and_raise_for_dev_exception) + + result = described_class.with_metadata { raise } + + expect(result.error).to be_an(StandardError) + expect(result).to be_nil end end |