debian-mirror-gitlab/spec/presenters/sentry_error_presenter_spec.rb

38 lines
972 B
Ruby
Raw Normal View History

2020-01-01 13:55:28 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe SentryErrorPresenter do
2021-10-27 15:23:28 +05:30
let(:error) { build(:error_tracking_sentry_detailed_error) }
2020-01-01 13:55:28 +05:30
let(:presenter) { described_class.new(error) }
describe '#frequency' do
subject { presenter.frequency }
it 'returns an array of frequency structs' do
2020-03-13 15:44:24 +05:30
expect(subject).to include(a_kind_of(SentryErrorPresenter::FrequencyStruct))
2020-01-01 13:55:28 +05:30
end
it 'converts the times into UTC time objects' do
time = subject.first.time
expect(time).to be_a(Time)
expect(time.strftime('%z')).to eq '+0000'
end
it 'returns the correct counts' do
count = subject.first.count
expect(count).to eq error.frequency.first[1]
end
end
2021-01-03 14:25:43 +05:30
describe '#project_id' do
subject { presenter.project_id }
it 'returns a global ID of the correct type' do
expect(subject).to eq(Gitlab::GlobalId.build(model_name: 'SentryProject', id: error.project_id).to_s)
end
end
2020-01-01 13:55:28 +05:30
end