aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/application
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2011-11-24 01:45:50 +0100
committerPiotr Sarnacki <drogus@gmail.com>2011-11-24 16:16:00 +0100
commit0cd3bf84068dd2b2d0bbb26062f2cdc7093a1b04 (patch)
tree13e3b3e3461f7a4221909bb966f0c6104676e853 /railties/test/application
parent30cf3e16a079f833cf396ad9dfaa3a2d4652142d (diff)
downloadrails-0cd3bf84068dd2b2d0bbb26062f2cdc7093a1b04.tar.gz
rails-0cd3bf84068dd2b2d0bbb26062f2cdc7093a1b04.tar.bz2
rails-0cd3bf84068dd2b2d0bbb26062f2cdc7093a1b04.zip
Allow to display engine's routes when running `rake routes ENGINES=true`
Diffstat (limited to 'railties/test/application')
-rw-r--r--railties/test/application/route_inspect_test.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/railties/test/application/route_inspect_test.rb b/railties/test/application/route_inspect_test.rb
index 78980705ed..130d4e52f8 100644
--- a/railties/test/application/route_inspect_test.rb
+++ b/railties/test/application/route_inspect_test.rb
@@ -1,6 +1,7 @@
require 'test/unit'
require 'rails/application/route_inspector'
require 'action_controller'
+require 'rails/engine'
module ApplicationTests
class RouteInspectTest < Test::Unit::TestCase
@@ -9,6 +10,35 @@ module ApplicationTests
@inspector = Rails::Application::RouteInspector.new
end
+ def test_displaying_routes_for_engines
+ ENV["ENGINES"] = "true"
+
+ engine = Class.new(Rails::Engine) do
+ def self.to_s
+ "Blog::Engine"
+ end
+ end
+ engine.routes.draw do
+ get '/cart', :to => 'cart#show'
+ end
+
+ @set.draw do
+ get '/custom/assets', :to => 'custom_assets#show'
+ mount engine => "/blog", :as => "blog"
+ end
+
+ output = @inspector.format @set.routes
+ expected = [
+ "custom_assets GET /custom/assets(.:format) custom_assets#show",
+ " blog /blog Blog::Engine",
+ "\nRoutes for Blog::Engine:",
+ "cart GET /cart(.:format) cart#show"
+ ]
+ assert_equal expected, output
+ ensure
+ ENV["ENGINES"] = nil
+ end
+
def test_cart_inspect
@set.draw do
get '/cart', :to => 'cart#show'