File tree 2 files changed +12
-1
lines changed
2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -34,12 +34,17 @@ def initialize(options = {})
34
34
#
35
35
# Returns error id from successful response
36
36
def send_to_honeybadger ( notice )
37
+ if api_key . nil?
38
+ log ( :error , "API key not found." )
39
+ return nil
40
+ end
41
+
37
42
data = notice . is_a? ( String ) ? notice : notice . to_json
38
43
39
44
http = setup_http_connection
40
45
headers = HEADERS
41
46
42
- headers . merge! ( { 'X-API-Key' => api_key } ) unless api_key . nil?
47
+ headers . merge! ( { 'X-API-Key' => api_key } )
43
48
44
49
response = begin
45
50
http . post ( url . path , data , headers )
Original file line number Diff line number Diff line change @@ -71,6 +71,12 @@ def stub_http(options = {})
71
71
assert_equal nil , send_exception ( :secure => false )
72
72
end
73
73
74
+ should "log missing API key and return nil" do
75
+ sender = build_sender ( { :api_key => nil } )
76
+ sender . expects ( :log ) . with ( :error , includes ( 'API key' ) )
77
+ assert_equal nil , send_exception ( :sender => sender , :secure => false )
78
+ end
79
+
74
80
should "should log success" do
75
81
http = stub_http
76
82
sender = build_sender
You can’t perform that action at this time.
0 commit comments