diff --git a/spec/grape/endpoint_spec.rb b/spec/grape/endpoint_spec.rb index 9347288228..790fc9cbea 100644 --- a/spec/grape/endpoint_spec.rb +++ b/spec/grape/endpoint_spec.rb @@ -652,6 +652,18 @@ def app expect(last_response.body).to eq('{"error":"The requested content-type \'application/xml\' is not supported."}') end + it 'responds with a 406 for an unsupported content-type for a post request' do + subject.format :json + # subject.content_type :json, "application/json" + subject.post '/request_body' do + params[:user] + end + post '/request_body', 'user=ciao', 'CONTENT_TYPE' => 'application/x-www-form-urlencoded' + expect(last_request.content_type).to eq('application/x-www-form-urlencoded') + expect(last_response.status).to eq(406) + expect(last_response.body).to eq('{"error":"The requested content-type \'application/xml\' is not supported."}') + end + context 'content type with params' do before do subject.format :json