Commit 864745a4f9811a4741f1d6f837273c6b06e54853
1 parent
de5ece03
Exists in
master
and in
1 other branch
Unused Notice#top_in_app_backtrace_line method cleaned. Notice.in_app_backtrace_…
…line? have boolean value.
Showing
2 changed files
with
13 additions
and
17 deletions
Show diff stats
app/models/notice.rb
... | ... | @@ -57,7 +57,7 @@ class Notice |
57 | 57 | end |
58 | 58 | |
59 | 59 | def self.in_app_backtrace_line? line |
60 | - line['file'] =~ %r{^\[PROJECT_ROOT\]/(?!(vendor))} | |
60 | + !!(line['file'] =~ %r{^\[PROJECT_ROOT\]/(?!(vendor))}) | |
61 | 61 | end |
62 | 62 | |
63 | 63 | def request |
... | ... | @@ -84,10 +84,6 @@ class Notice |
84 | 84 | err.update_attributes(:last_notice_at => created_at) |
85 | 85 | end |
86 | 86 | |
87 | - def top_in_app_backtrace_line | |
88 | - @top_in_app_backtrace_line ||= self.backtrace.find {|line| Notice.in_app_backtrace_line?(line) } | |
89 | - end | |
90 | - | |
91 | 87 | protected |
92 | 88 | |
93 | 89 | def should_notify? | ... | ... |
spec/models/notice_spec.rb
... | ... | @@ -22,9 +22,8 @@ describe Notice do |
22 | 22 | end |
23 | 23 | end |
24 | 24 | |
25 | - context '#top_in_app_backtrace_line' do | |
26 | - before do | |
27 | - backtrace = [{ | |
25 | + context '.in_app_backtrace_line?' do | |
26 | + let(:backtrace) do [{ | |
28 | 27 | 'number' => rand(999), |
29 | 28 | 'file' => '[GEM_ROOT]/gems/actionpack-3.0.4/lib/action_controller/metal/rescue.rb', |
30 | 29 | 'method' => ActiveSupport.methods.shuffle.first |
... | ... | @@ -36,18 +35,19 @@ describe Notice do |
36 | 35 | 'number' => rand(999), |
37 | 36 | 'file' => '[PROJECT_ROOT]/lib/set_headers.rb', |
38 | 37 | 'method' => ActiveSupport.methods.shuffle.first |
39 | - }, { | |
40 | - 'number' => rand(999), | |
41 | - 'file' => '[PROJECT_ROOT]/lib/detect_api.rb', | |
42 | - 'method' => ActiveSupport.methods.shuffle.first | |
43 | 38 | }] |
39 | + end | |
44 | 40 | |
45 | - @notice = Factory(:notice, :backtrace => backtrace) | |
41 | + it "should be false for line not starting with PROJECT_ROOT" do | |
42 | + Notice.in_app_backtrace_line?(backtrace[0]).should == false | |
46 | 43 | end |
47 | - | |
48 | - it 'finds the correct line' do | |
49 | - line = @notice.top_in_app_backtrace_line | |
50 | - line['file'].should == '[PROJECT_ROOT]/lib/set_headers.rb' | |
44 | + | |
45 | + it "should be false for file in vendor dir" do | |
46 | + Notice.in_app_backtrace_line?(backtrace[1]).should == false | |
47 | + end | |
48 | + | |
49 | + it "should be true for application file" do | |
50 | + Notice.in_app_backtrace_line?(backtrace[2]).should == true | |
51 | 51 | end |
52 | 52 | end |
53 | 53 | ... | ... |