summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/usage_data_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-01-18 19:00:14 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-18 19:00:14 +0000
commit05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch)
tree11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /spec/lib/gitlab/usage_data_spec.rb
parentec73467c23693d0db63a797d10194da9e72a74af (diff)
downloadgitlab-ce-05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2.tar.gz
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'spec/lib/gitlab/usage_data_spec.rb')
-rw-r--r--spec/lib/gitlab/usage_data_spec.rb18
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