toadhopper 0.9.7 → 0.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +0 -1
- data/lib/toadhopper.rb +10 -12
- data/test/helper.rb +4 -0
- data/test/test_filters.rb +0 -22
- data/test/test_notice_document_data.rb +14 -0
- data/test/test_posting.rb +0 -4
- metadata +3 -1
data/Gemfile
CHANGED
data/lib/toadhopper.rb
CHANGED
@@ -4,7 +4,7 @@ require 'ostruct'
|
|
4
4
|
|
5
5
|
# Posts errors to the Hoptoad API
|
6
6
|
class ToadHopper
|
7
|
-
VERSION = "0.9.
|
7
|
+
VERSION = "0.9.8"
|
8
8
|
|
9
9
|
# Hoptoad API response
|
10
10
|
class Response < Struct.new(:status, :body, :errors); end
|
@@ -77,13 +77,13 @@ class ToadHopper
|
|
77
77
|
|
78
78
|
# @private
|
79
79
|
def document_for(exception, options={})
|
80
|
-
data =
|
80
|
+
data = document_data(exception, options)
|
81
81
|
scope = OpenStruct.new(data).extend(ERB::Util)
|
82
82
|
ERB.new(notice_template, nil, '-').result(scope.send(:binding))
|
83
83
|
end
|
84
84
|
|
85
|
-
def
|
86
|
-
|
85
|
+
def document_defaults(error)
|
86
|
+
{
|
87
87
|
:error => error,
|
88
88
|
:api_key => api_key,
|
89
89
|
:environment => ENV.to_hash,
|
@@ -98,15 +98,13 @@ class ToadHopper
|
|
98
98
|
:session => {},
|
99
99
|
:framework_env => ENV['RACK_ENV'] || 'development',
|
100
100
|
:project_root => Dir.pwd
|
101
|
-
}
|
102
|
-
|
103
|
-
# Backwards compatibility
|
104
|
-
defaults[:params] ||= defaults[:request].params if defaults[:request]
|
105
|
-
|
106
|
-
# Filter params, session and environment
|
107
|
-
[:params, :session, :environment].each{|n| defaults[n] = clean(defaults[n]) if defaults[n] }
|
101
|
+
}
|
102
|
+
end
|
108
103
|
|
109
|
-
|
104
|
+
def document_data(error, options)
|
105
|
+
data = document_defaults(error).merge(options)
|
106
|
+
[:params, :session, :environment].each{|n| data[n] = clean(data[n]) if data[n] }
|
107
|
+
data
|
110
108
|
end
|
111
109
|
|
112
110
|
# @private
|
data/test/helper.rb
CHANGED
data/test/test_filters.rb
CHANGED
@@ -24,25 +24,3 @@ class ToadHopper::TestFilters < Test::Unit::TestCase
|
|
24
24
|
toadhopper.clean(:id => "myid", :email => "myemail", :password => "mypassword"))
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
28
|
-
class ToadHopper::TestCleanedOptions < Test::Unit::TestCase
|
29
|
-
def setup
|
30
|
-
@request = Struct.new(:params).new
|
31
|
-
@request.params = {:password => "foo"}
|
32
|
-
def @request.params=(*); raise NoMethodError, "requests don't have #params=, you fool"; end
|
33
|
-
@error = begin; raise "Kaboom!"; rescue => e; e end
|
34
|
-
toadhopper.filters = "password"
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_filtering_params_with_backwards_compatibility
|
38
|
-
filtered_data = toadhopper.filtered_data(@error, :request => @request)[:params]
|
39
|
-
|
40
|
-
assert_equal({:password => "[FILTERED]"}, filtered_data)
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_filtering_params
|
44
|
-
filtered_data = toadhopper.filtered_data(@error, :params => @request.params)[:params]
|
45
|
-
|
46
|
-
assert_equal({:password => "[FILTERED]"}, filtered_data)
|
47
|
-
end
|
48
|
-
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
2
|
+
|
3
|
+
class ToadHopper::TestNoticeDocument < Test::Unit::TestCase
|
4
|
+
def test_filtering
|
5
|
+
toadhopper.filters = "password"
|
6
|
+
sensitive_options = {
|
7
|
+
:params => {"password" => "sensitive"},
|
8
|
+
:session => {"password" => "sensitive"},
|
9
|
+
:environment => {"password" => "sensitive"}
|
10
|
+
}
|
11
|
+
notice_document = toadhopper.document_for(error, sensitive_options)
|
12
|
+
assert_false notice_document.include?("sensitive")
|
13
|
+
end
|
14
|
+
end
|
data/test/test_posting.rb
CHANGED
@@ -2,8 +2,6 @@ require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
|
2
2
|
|
3
3
|
class ToadHopper::TestPosting < Test::Unit::TestCase
|
4
4
|
def test_posting
|
5
|
-
error = begin; raise "Kaboom!"; rescue => e; e end
|
6
|
-
|
7
5
|
response = ToadHopper('bogus key').post!(error)
|
8
6
|
assert_equal 422, response.status
|
9
7
|
assert_equal ['No project exists with the given API key.'], response.errors
|
@@ -12,8 +10,6 @@ class ToadHopper::TestPosting < Test::Unit::TestCase
|
|
12
10
|
if ENV['HOPTOAD_API_KEY']
|
13
11
|
def test_posting_integration
|
14
12
|
toadhopper.filters = "HOPTOAD_API_KEY", "ROOT_PASSWORD"
|
15
|
-
error = begin; raise "Kaboom!"; rescue => e; e end
|
16
|
-
|
17
13
|
response = toadhopper.post!(error)
|
18
14
|
assert_equal 200, response.status
|
19
15
|
assert_equal [], response.errors
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toadhopper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Lucas
|
@@ -36,6 +36,7 @@ files:
|
|
36
36
|
- lib/toadhopper.rb
|
37
37
|
- test/helper.rb
|
38
38
|
- test/test_filters.rb
|
39
|
+
- test/test_notice_document_data.rb
|
39
40
|
- test/test_posting.rb
|
40
41
|
has_rdoc: true
|
41
42
|
homepage: http://github.com/toolmantim/toadhopper
|
@@ -68,4 +69,5 @@ summary: Post error notifications to Hoptoad
|
|
68
69
|
test_files:
|
69
70
|
- test/helper.rb
|
70
71
|
- test/test_filters.rb
|
72
|
+
- test/test_notice_document_data.rb
|
71
73
|
- test/test_posting.rb
|