From 19ea9e8b6da0c1d90015eb6a0252565d68e8834d Mon Sep 17 00:00:00 2001 From: John Edmonds Date: Sat, 1 Oct 2011 11:48:41 -0400 Subject: [PATCH] Add tests for Content-Type returned from #create. --- spec/controllers/photos_controller_spec.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index 210daa25c..9a438a269 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -24,6 +24,16 @@ describe PhotosController do post :create, @params }.should change(Photo, :count).by(1) end + + it 'returns application/json when possible' do + request.env['HTTP_ACCEPT'] = 'application/json' + post(:create, @params).headers['Content-Type'].should match 'application/json.*' + end + + it 'returns text/html by default' do + request.env['HTTP_ACCEPT'] = 'text/html,*/*' + post(:create, @params).headers['Content-Type'].should match 'text/html.*' + end end describe '#create' do