-
-
Notifications
You must be signed in to change notification settings - Fork 540
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #273 from AlfonsoUceda/fix-container-routes-bug
Fix container router bugs
- Loading branch information
Showing
2 changed files
with
104 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,55 @@ | ||
require 'test_helper' | ||
require 'rack/test' | ||
|
||
describe Lotus::Container do | ||
describe 'apps mounted with container' do | ||
it 'should generate correct paths with route helper' do | ||
Lotus::Container.configure do | ||
mount Admin::Application, at: '/admin' | ||
mount CallCenter::Application, at: '/callcenter' | ||
end | ||
include Rack::Test::Methods | ||
|
||
Lotus::Container.new | ||
before do | ||
Lotus::Container.configure do | ||
mount Front::Application, at: '/front' | ||
mount Back::Application, at: '/back' | ||
end | ||
|
||
@container = Lotus::Container.new | ||
Front::Application.load! | ||
Back::Application.load! | ||
end | ||
|
||
def app | ||
@container | ||
end | ||
|
||
def response | ||
last_response | ||
end | ||
|
||
CallCenter::Routes.path(:home).must_equal '/callcenter/home' | ||
Admin::Routes.path(:home).must_equal '/admin/home' | ||
it 'reach to endpoints' do | ||
get '/back/home' | ||
response.status.must_equal 200 | ||
response.body.must_equal 'hello Back' | ||
|
||
get '/front/home' | ||
response.status.must_equal 200 | ||
response.body.must_equal 'hello Front' | ||
|
||
get '/back/users' | ||
response.status.must_equal 200 | ||
response.body.must_equal 'hello from Back users endpoint' | ||
end | ||
|
||
it 'print correct routes' do | ||
matches = [ | ||
'GET, HEAD /front/home Front::Controllers::Home::Show', | ||
'GET, HEAD /back/home Back::Controllers::Home::Show', | ||
'GET, HEAD /back/users Back::Controllers::Users::Index' | ||
] | ||
matches.each do |match| | ||
@container.routes.inspector.to_s.must_match match | ||
end | ||
end | ||
|
||
it 'generate correct urls with route helpers' do | ||
Front::Routes.path(:home).must_equal '/front/home' | ||
Back::Routes.path(:home).must_equal '/back/home' | ||
end | ||
end |