Skip to content

Commit

Permalink
route not found throws exception
Browse files Browse the repository at this point in the history
  • Loading branch information
josephmancuso committed May 29, 2019
1 parent da03457 commit 7fd445f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion masonite/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ def _get_named_route(self, name, params):
if route.named_route == name:
return self.compile_route_to_url(route.route_url, params)

return None
raise RouteException("Could not find the route with the name of '{}'".format(name))

def _get_route_from_controller(self, controller):
"""Get the route using the controller.
Expand Down
16 changes: 16 additions & 0 deletions tests/core/test_requests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import unittest
from cgi import MiniFieldStorage
from pydoc import locate
import pytest



Expand Down Expand Up @@ -218,6 +219,21 @@ def test_redirections_reset(self):

self.assertFalse(request.redirect_url)

def test_redirect_to_throws_exception_when_no_routes_found(self):
app = App()
app.bind('Request', self.request)
app.bind('WebRoutes', WEB_ROUTES)
request = app.make('Request').load_app(app)

request.redirect_to('test')
request.redirect(name='test')

with pytest.raises(RouteException):
request.redirect_to('notavailable')

with pytest.raises(RouteException):
request.redirect(name='notavailable')

def test_request_has_subdomain_returns_bool(self):
app = App()
app.bind('Request', self.request)
Expand Down

0 comments on commit 7fd445f

Please sign in to comment.