Skip to content

Commit

Permalink
added a spec to ensure that you can post a notice with the XML in a d…
Browse files Browse the repository at this point in the history
…ata param
  • Loading branch information
boblail committed Aug 30, 2012
1 parent 141f6ff commit 1cada7b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion spec/controllers/notices_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@notice = App.report_error!(@xml)
end

it "generates a notice from xml [POST]" do
it "generates a notice from raw xml [POST]" do
App.should_receive(:report_error!).with(@xml).and_return(@notice)
request.should_receive(:raw_post).and_return(@xml)
post :create, :format => :xml
Expand All @@ -24,6 +24,16 @@
response.body.should match(%r{<url[^>]*>(.+)#{locate_path(@notice.id)}</url>})
end

it "generates a notice from xml in a data param [POST]" do
App.should_receive(:report_error!).with(@xml).and_return(@notice)
post :create, :data => @xml, :format => :xml
response.should be_success
# Same RegExp from Airbrake::Sender#send_to_airbrake (https://github.com/airbrake/airbrake/blob/master/lib/airbrake/sender.rb#L53)
# Inspired by https://github.com/airbrake/airbrake/blob/master/test/sender_test.rb
response.body.should match(%r{<id[^>]*>#{@notice.id}</id>})
response.body.should match(%r{<url[^>]*>(.+)#{locate_path(@notice.id)}</url>})
end

it "generates a notice from xml [GET]" do
App.should_receive(:report_error!).with(@xml).and_return(@notice)
get :create, :data => @xml, :format => :xml
Expand Down

0 comments on commit 1cada7b

Please sign in to comment.