Skip to content

Commit

Permalink
Merge pull request #505 from MasoniteFramework/fix-view-integer
Browse files Browse the repository at this point in the history
fixed integer returned from view throwing error
  • Loading branch information
josephmancuso committed Dec 12, 2018
2 parents fe58ba1 + 6b2273d commit 385f608
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions masonite/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ def view(self, view, status=200):

if isinstance(view, dict) or isinstance(view, list):
return self.json(view)
elif isinstance(view, int):
view = str(view)
elif isinstance(view, View):
view = view.rendered_template
elif isinstance(view, self.request.__class__):
Expand Down
6 changes: 6 additions & 0 deletions tests/test_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,9 @@ def test_view(self):
self.response.view('foobar')

assert self.app.make('Response') == 'foobar'

def test_view_can_return_integer_as_string(self):
self.response.view(1)

assert self.app.make('Response') == '1'
assert self.request.is_status(200)

0 comments on commit 385f608

Please sign in to comment.