Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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