Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #124 from zanker/send-xml

Add the ability to pass XML directly to send_to_airbrake
  • Loading branch information...
commit fa6c1ff5489e0acd12550200afb1840a83dd2ec2 2 parents 8cb15da + e4a2336
@shime shime authored
Showing with 28 additions and 2 deletions.
  1. +2 −2 lib/airbrake/sender.rb
  2. +26 −0 test/sender_test.rb
View
4 lib/airbrake/sender.rb
@@ -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
26 test/sender_test.rb
@@ -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,
Please sign in to comment.
Something went wrong with that request. Please try again.