Commit ccdd2c520b96fb4b22abcc010c20ab9f8136dfcc
Exists in
master
and in
1 other branch
Merge pull request #236 from concordia-publishing-house/add-spec-for-post-xml
added a spec to ensure that you can post a notice with the XML in a data param closes #154
Showing
1 changed file
with
11 additions
and
1 deletions
Show diff stats
spec/controllers/notices_controller_spec.rb
@@ -13,7 +13,7 @@ describe NoticesController do | @@ -13,7 +13,7 @@ describe NoticesController do | ||
13 | @notice = App.report_error!(@xml) | 13 | @notice = App.report_error!(@xml) |
14 | end | 14 | end |
15 | 15 | ||
16 | - it "generates a notice from xml [POST]" do | 16 | + it "generates a notice from raw xml [POST]" do |
17 | App.should_receive(:report_error!).with(@xml).and_return(@notice) | 17 | App.should_receive(:report_error!).with(@xml).and_return(@notice) |
18 | request.should_receive(:raw_post).and_return(@xml) | 18 | request.should_receive(:raw_post).and_return(@xml) |
19 | post :create, :format => :xml | 19 | post :create, :format => :xml |
@@ -24,6 +24,16 @@ describe NoticesController do | @@ -24,6 +24,16 @@ describe NoticesController do | ||
24 | response.body.should match(%r{<url[^>]*>(.+)#{locate_path(@notice.id)}</url>}) | 24 | response.body.should match(%r{<url[^>]*>(.+)#{locate_path(@notice.id)}</url>}) |
25 | end | 25 | end |
26 | 26 | ||
27 | + it "generates a notice from xml in a data param [POST]" do | ||
28 | + App.should_receive(:report_error!).with(@xml).and_return(@notice) | ||
29 | + post :create, :data => @xml, :format => :xml | ||
30 | + response.should be_success | ||
31 | + # Same RegExp from Airbrake::Sender#send_to_airbrake (https://github.com/airbrake/airbrake/blob/master/lib/airbrake/sender.rb#L53) | ||
32 | + # Inspired by https://github.com/airbrake/airbrake/blob/master/test/sender_test.rb | ||
33 | + response.body.should match(%r{<id[^>]*>#{@notice.id}</id>}) | ||
34 | + response.body.should match(%r{<url[^>]*>(.+)#{locate_path(@notice.id)}</url>}) | ||
35 | + end | ||
36 | + | ||
27 | it "generates a notice from xml [GET]" do | 37 | it "generates a notice from xml [GET]" do |
28 | App.should_receive(:report_error!).with(@xml).and_return(@notice) | 38 | App.should_receive(:report_error!).with(@xml).and_return(@notice) |
29 | get :create, :data => @xml, :format => :xml | 39 | get :create, :data => @xml, :format => :xml |