diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-12 03:07:43 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-12 03:07:43 +0300 |
commit | 2e3cbf7d89815e2915f77677388c49b48f8d20c3 (patch) | |
tree | 03bdbc99e829295e8077b2ec4032300c15b48e37 /spec/lib/gitlab/error_tracking | |
parent | e44bb86539a8fb4cfb06dfe281632b6f206bd0a7 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/error_tracking')
-rw-r--r-- | spec/lib/gitlab/error_tracking/stack_trace_highlight_decorator_spec.rb | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/spec/lib/gitlab/error_tracking/stack_trace_highlight_decorator_spec.rb b/spec/lib/gitlab/error_tracking/stack_trace_highlight_decorator_spec.rb new file mode 100644 index 00000000000..04ef5ba516e --- /dev/null +++ b/spec/lib/gitlab/error_tracking/stack_trace_highlight_decorator_spec.rb @@ -0,0 +1,58 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Gitlab::ErrorTracking::StackTraceHighlightDecorator do + let(:error_event) { build(:error_tracking_error_event) } + + describe '.decorate' do + subject(:decorate) { described_class.decorate(error_event) } + + it 'does not change issue_id' do + expect(decorate.issue_id).to eq(error_event.issue_id) + end + + it 'does not change date_received' do + expect(decorate.date_received).to eq(error_event.date_received) + end + + it 'decorates the stack trace context' do + expect(decorate.stack_trace_entries).to eq( + [ + { + 'function' => 'puts', + 'lineNo' => 14, + 'filename' => 'hello_world.rb', + 'context' => [ + [10, '<span id="LC1" class="line" lang="ruby"><span class="c1"># Ruby example</span></span>'], + [11, '<span id="LC1" class="line" lang="ruby"><span class="k">class</span> <span class="nc">HelloWorld</span></span>'], + [12, '<span id="LC1" class="line" lang="ruby"> <span class="k">def</span> <span class="nc">self</span><span class="o">.</span><span class="nf">message</span></span>'], + [13, '<span id="LC1" class="line" lang="ruby"> <span class="vi">@name</span> <span class="o">=</span> <span class="s1">\'World\'</span></span>'], + [14, %Q[<span id="LC1" class="line" lang="ruby"> <span class="nb">puts</span> <span class="s2">"Hello </span><span class="si">\#{</span><span class="vi">@name</span><span class="si">}</span><span class="s2">"</span></span>]], + [15, '<span id="LC1" class="line" lang="ruby"> <span class="k">end</span></span>'], + [16, '<span id="LC1" class="line" lang="ruby"><span class="k">end</span></span>'] + ] + }, + { + 'function' => 'print', + 'lineNo' => 6, + 'filename' => 'HelloWorld.swift', + 'context' => [ + [1, '<span id="LC1" class="line" lang="swift"><span class="c1">// Swift example</span></span>'], + [2, '<span id="LC1" class="line" lang="swift"><span class="kd">struct</span> <span class="kt">HelloWorld</span> <span class="p">{</span></span>'], + [3, '<span id="LC1" class="line" lang="swift"> <span class="k">let</span> <span class="nv">name</span> <span class="o">=</span> <span class="s">"World"</span></span>'], + [4, '<span id="LC1" class="line" lang="swift"></span>'], + [5, '<span id="LC1" class="line" lang="swift"> <span class="kd">static</span> <span class="kd">func</span> <span class="nf">message</span><span class="p">()</span> <span class="p">{</span></span>'], + [6, '<span id="LC1" class="line" lang="swift"> <span class="nf">print</span><span class="p">(</span><span class="s">"Hello, </span><span class="se">\\(</span><span class="k">self</span><span class="o">.</span><span class="n">name</span><span class="se">)</span><span class="s">"</span><span class="p">)</span></span>'], + [7, '<span id="LC1" class="line" lang="swift"> <span class="p">}</span></span>'], + [8, '<span id="LC1" class="line" lang="swift"><span class="p">}</span></span>'] + ] + }, + { + 'filename' => 'blank.txt' + } + ] + ) + end + end +end |