Skip to content

Commit

Permalink
Merge d3bd06f into 385f608
Browse files Browse the repository at this point in the history
  • Loading branch information
josephmancuso committed Dec 12, 2018
2 parents 385f608 + d3bd06f commit 6d15243
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/http/controllers/subdirectory/SubController.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

class SubController:

def show(self):
return 'test'
4 changes: 3 additions & 1 deletion masonite/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ def _find_controller(self, controller):
if mod[0].startswith('/'):
self.module_location = '.'.join(
mod[0].replace('/', '').split('.')[0:-1])

elif '.' in mod[0]:
# This is a deeper module controller
self.module_location = self.module_location + '.' + '.'.join(mod[0].split('.')[:-1])
else:
if controller is None:
return None
Expand Down
6 changes: 6 additions & 0 deletions tests/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from masonite.helpers.routes import group, flatten_routes
from masonite.testsuite.TestSuite import generate_wsgi
from masonite.exceptions import InvalidRouteCompileException, RouteException
from app.http.controllers.subdirectory.SubController import SubController
import pytest


Expand Down Expand Up @@ -64,6 +65,11 @@ def test_route_gets_controllers(self):
def test_route_doesnt_break_on_incorrect_controller(self):
assert Get().route('test/url', 'BreakController@show')

def test_route_gets_deeper_module_controller(self):
route = Get().route('test/url', 'subdirectory.SubController@show')
assert route.controller
assert isinstance(route.controller, SubController.__class__)

def test_route_can_have_multiple_routes(self):
assert Match(['GET', 'POST']).route('test/url', 'TestController@show').method_type == ['GET', 'POST']

Expand Down

0 comments on commit 6d15243

Please sign in to comment.