Permalink
Browse files

Merge branch 'master' of github.com:airbrake/airbrake

  • Loading branch information...
2 parents c3c0e3c + fa6c1ff commit 9f7ea74f6efb910c6861d9256b7981e821e85f5e @shime shime committed Sep 20, 2012
Showing with 28 additions and 3 deletions.
  1. +2 −2 lib/airbrake/sender.rb
  2. +0 −1 lib/airbrake_tasks.rb
  3. +26 −0 test/sender_test.rb
View
@@ -31,9 +31,9 @@ def initialize(options = {})
# Sends the notice data off to Airbrake for processing.
#
- # @param [Notice] notice The notice to be sent off
+ # @param [Notice or String] notice The notice to be sent off
def send_to_airbrake(notice)
- data = notice.to_xml
+ data = notice.respond_to?(:to_xml) ? notice.to_xml : notice
http = setup_http_connection
response = begin
View
@@ -1,6 +1,5 @@
require 'net/http'
require 'uri'
-require 'active_support'
# Capistrano tasks for notifying Airbrake of deploys
module AirbrakeTasks
View
@@ -31,6 +31,32 @@ def stub_http(options = {})
http
end
+ should "post to Airbrake with XML passed" do
+ xml_notice = Airbrake::Notice.new(:error_class => "FooBar", :error_message => "Foo Bar").to_xml
+
+ http = stub_http
+
+ sender = build_sender
+ sender.send_to_airbrake(xml_notice)
+
+ assert_received(http, :post) do |expect|
+ expect.with(anything, xml_notice, Airbrake::HEADERS)
+ end
+ end
+
+ should "post to Airbrake with a Notice instance passed" do
+ notice = Airbrake::Notice.new(:error_class => "FooBar", :error_message => "Foo Bar")
+
+ http = stub_http
+
+ sender = build_sender
+ sender.send_to_airbrake(notice)
+
+ assert_received(http, :post) do |expect|
+ expect.with(anything, notice.to_xml, Airbrake::HEADERS)
+ end
+ end
+
should "post to Airbrake when using an HTTP proxy" do
response = stub(:body => 'body')
http = stub(:post => response,

0 comments on commit 9f7ea74

Please sign in to comment.