Commit 024f7fe29023c07482e245a0c355f092abb51a5a
1 parent
fabe99ad
Exists in
master
and in
1 other branch
Protect against nil methods in BacktraceLineNormalizer, and test same.
Showing
2 changed files
with
7 additions
and
3 deletions
Show diff stats
app/models/backtrace_line_normalizer.rb
@@ -13,7 +13,7 @@ class BacktraceLineNormalizer | @@ -13,7 +13,7 @@ class BacktraceLineNormalizer | ||
13 | end | 13 | end |
14 | 14 | ||
15 | def normalized_method | 15 | def normalized_method |
16 | - @raw_line['method'].gsub(/[0-9_]{10,}+/, "__FRAGMENT__") | 16 | + @raw_line['method'].blank? ? "[unknown method]" : @raw_line['method'].gsub(/[0-9_]{10,}+/, "__FRAGMENT__") |
17 | end | 17 | end |
18 | 18 | ||
19 | end | 19 | end |
spec/models/backtrace_line_normalizer_spec.rb
@@ -3,12 +3,16 @@ require 'spec_helper' | @@ -3,12 +3,16 @@ require 'spec_helper' | ||
3 | describe BacktraceLineNormalizer do | 3 | describe BacktraceLineNormalizer do |
4 | subject { described_class.new(raw_line).call } | 4 | subject { described_class.new(raw_line).call } |
5 | 5 | ||
6 | - describe "sanitize file" do | ||
7 | - let(:raw_line) { { 'number' => rand(999), 'file' => nil, 'method' => ActiveSupport.methods.shuffle.first.to_s } } | 6 | + describe "sanitize file and method" do |
7 | + let(:raw_line) { { 'number' => rand(999), 'file' => nil, 'method' => nil } } | ||
8 | 8 | ||
9 | it "should replace nil file with [unknown source]" do | 9 | it "should replace nil file with [unknown source]" do |
10 | subject['file'].should == "[unknown source]" | 10 | subject['file'].should == "[unknown source]" |
11 | end | 11 | end |
12 | 12 | ||
13 | + it "should replace nil method with [unknown method]" do | ||
14 | + subject['method'].should == "[unknown method]" | ||
15 | + end | ||
16 | + | ||
13 | end | 17 | end |
14 | end | 18 | end |