Skip to content
This repository has been archived by the owner on Dec 3, 2020. It is now read-only.

Commit

Permalink
fix ruby-grape#726 - add failing spec
Browse files Browse the repository at this point in the history
  • Loading branch information
Morred authored and inclooder committed Mar 9, 2017
1 parent 92c173b commit 13d8e97
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions spec/grape/endpoint_spec.rb
Expand Up @@ -843,6 +843,19 @@ def app
expect(last_response.body).to eq('{"error":"The requested content-type \'application/xml\' is not supported."}')
end

it 'does not accept text/plain in JSON format if application/json is specified as content type' do
subject.format :json
# this test will fail unless the line below is commented out
subject.default_format :json
#
subject.put '/request_body' do
params[:user]
end
put '/request_body', MultiJson.dump(user: 'Bob'), 'CONTENT_TYPE' => 'text/plain'
expect(last_response.status).to eq(406)
expect(last_response.body).to eq('{"error":"The requested content-type \'text/plain\' is not supported."}')
end

context 'content type with params' do
before do
subject.format :json
Expand Down

0 comments on commit 13d8e97

Please sign in to comment.