Skip to content

Commit

Permalink
Merge 58dec4d into f9a7ca3
Browse files Browse the repository at this point in the history
  • Loading branch information
josephmancuso authored May 29, 2019
2 parents f9a7ca3 + 58dec4d commit a68f7bb
Show file tree
Hide file tree
Showing 2 changed files with 21 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 @@ -667,7 +667,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
20 changes: 20 additions & 0 deletions tests/test_requests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import unittest
from cgi import MiniFieldStorage
from pydoc import locate
import pytest



from config import application, providers
from pydoc import locate
from app.http.test_controllers.TestController import TestController
Expand Down Expand Up @@ -218,6 +223,21 @@ def test_redirections_reset(self):

assert request.redirect_url is False

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 a68f7bb

Please sign in to comment.