diff options
Diffstat (limited to 'spec/models/error_tracking/error_event_spec.rb')
-rw-r--r-- | spec/models/error_tracking/error_event_spec.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/models/error_tracking/error_event_spec.rb b/spec/models/error_tracking/error_event_spec.rb index 8e20eb25353..9cf5a405e74 100644 --- a/spec/models/error_tracking/error_event_spec.rb +++ b/spec/models/error_tracking/error_event_spec.rb @@ -11,7 +11,10 @@ RSpec.describe ErrorTracking::ErrorEvent, type: :model do describe 'validations' do it { is_expected.to validate_presence_of(:description) } + it { is_expected.to validate_length_of(:description).is_at_most(1024) } it { is_expected.to validate_presence_of(:occurred_at) } + it { is_expected.to validate_length_of(:level).is_at_most(255) } + it { is_expected.to validate_length_of(:environment).is_at_most(255) } end describe '#stacktrace' do @@ -37,6 +40,23 @@ RSpec.describe ErrorTracking::ErrorEvent, type: :model do expect(event.stacktrace).to be_kind_of(Array) expect(event.stacktrace.first).to eq(expected_entry) end + + context 'error context is missing' do + let(:event) { create(:error_tracking_error_event, :browser) } + + it 'generates a stacktrace without context' do + expected_entry = { + 'lineNo' => 6395, + 'context' => [], + 'filename' => 'webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js', + 'function' => 'hydrate', + 'colNo' => 0 + } + + expect(event.stacktrace).to be_kind_of(Array) + expect(event.stacktrace.first).to eq(expected_entry) + end + end end describe '#to_sentry_error_event' do |