Skip to content

Commit ba2f522

Browse files
author
Robert Ross
committed
Make sure PUT's work as well.
1 parent 3be0f54 commit ba2f522

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

spec/grape/endpoint_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,18 +175,32 @@ def app; subject end
175175
subject.post '/request_body' do
176176
params[:user]
177177
end
178+
179+
subject.put '/request_body' do
180+
params[:user]
181+
end
178182
end
179183

180184
it 'should convert JSON bodies to params' do
181185
post '/request_body', MultiJson.encode(user: 'Bobby T.'), {'CONTENT_TYPE' => 'application/json'}
182186
last_response.body.should == 'Bobby T.'
183187
end
184188

189+
it 'should convert JSON bodies to params' do
190+
put '/request_body', MultiJson.encode(user: 'Bobby T.'), {'CONTENT_TYPE' => 'application/json'}
191+
last_response.body.should == 'Bobby T.'
192+
end
193+
185194
it 'should convert XML bodies to params' do
186195
post '/request_body', '<user>Bobby T.</user>', {'CONTENT_TYPE' => 'application/xml'}
187196
last_response.body.should == 'Bobby T.'
188197
end
189198

199+
it 'should convert XML bodies to params' do
200+
put '/request_body', '<user>Bobby T.</user>', {'CONTENT_TYPE' => 'application/xml'}
201+
last_response.body.should == 'Bobby T.'
202+
end
203+
190204
it 'does not include parameters not defined by the body' do
191205
subject.post '/omitted_params' do
192206
body_params[:version].should == nil

0 commit comments

Comments
 (0)