diff --git a/tapioca/rest_api.py b/tapioca/rest_api.py index 05b8ab8..aa03ed0 100644 --- a/tapioca/rest_api.py +++ b/tapioca/rest_api.py @@ -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) diff --git a/tests/acceptance/test_rest_api.py b/tests/acceptance/test_rest_api.py index 2fc84dc..73adbf5 100644 --- a/tests/acceptance/test_rest_api.py +++ b/tests/acceptance/test_rest_api.py @@ -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')