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

Commit

Permalink
Bugfix: finish() was being called twice when POST to create a resourc…
Browse files Browse the repository at this point in the history
…e returned some content in the body.
  • Loading branch information
gcirne committed Nov 8, 2012
1 parent 6afbb10 commit fdbf0cd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tapioca/rest_api.py
Expand Up @@ -144,7 +144,8 @@ def _callback(content=None, location=None, *args, **kwargs):
self.set_header('Location', location)
if content:
self.respond_with(content)
self.finish()
else:
self.finish()

self.create_model(_callback, *args, **kwargs)

Expand Down
2 changes: 2 additions & 0 deletions tests/acceptance/test_rest_api.py
Expand Up @@ -138,6 +138,8 @@ def test_post_to_create_a_new_resource(self):
}
response = self.post(self.get_url('/api'), dumps(a_new_item))
assert_response_code(response, 201)
self.assertRegexpMatches(response.headers['Location'], r'http://localhost:\d+/api/\d+')
assert loads(response.body)['text'] == 'this is my new item'

def test_put_to_update_an_existing_resource(self):
response = self.get('/api/1')
Expand Down

0 comments on commit fdbf0cd

Please sign in to comment.