Skip to content

Commit

Permalink
Create a test that shows bug ruby-grape#1403
Browse files Browse the repository at this point in the history
I have created an example that shows that even if it is setted `format :json`, if I send a post request with content_type: application/x-www-form-urlencoded it does return `201`
  • Loading branch information
ciaoben committed May 26, 2016
1 parent dc39328 commit df4c526
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions spec/grape/endpoint_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit df4c526

Please sign in to comment.