mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Add mailers to paths in case someone wants to access it directly and ensures deep nesting works in controllers.
This commit is contained in:
@@ -82,7 +82,7 @@ module Rails
|
||||
initializer :add_routing_namespaces do |app|
|
||||
paths.app.controllers.to_a.each do |load_path|
|
||||
load_path = File.expand_path(load_path)
|
||||
Dir["#{load_path}/*/*_controller.rb"].collect do |path|
|
||||
Dir["#{load_path}/*/**/*_controller.rb"].collect do |path|
|
||||
namespace = File.dirname(path).sub(/#{load_path}\/?/, '')
|
||||
app.routes.controller_namespaces << namespace unless namespace.empty?
|
||||
end
|
||||
|
||||
@@ -18,8 +18,9 @@ module Rails
|
||||
paths.app.controllers "app/controllers", :eager_load => true
|
||||
paths.app.helpers "app/helpers", :eager_load => true
|
||||
paths.app.models "app/models", :eager_load => true
|
||||
paths.app.metals "app/metal"
|
||||
paths.app.views "app/views"
|
||||
paths.app.mailers "app/mailers", :eager_load => true
|
||||
paths.app.metals "app/metal", :eager_load => true
|
||||
paths.app.views "app/views", :eager_load => true
|
||||
paths.lib "lib", :load_path => true
|
||||
paths.lib.tasks "lib/tasks", :glob => "**/*.rake"
|
||||
paths.lib.templates "lib/templates"
|
||||
|
||||
@@ -56,9 +56,10 @@ module ApplicationTests
|
||||
end
|
||||
|
||||
test "booting up Rails yields a list of paths that are eager" do
|
||||
assert @paths.app.eager_load?
|
||||
assert @paths.app.controllers.eager_load?
|
||||
assert @paths.app.helpers.eager_load?
|
||||
eager_load = @paths.eager_load
|
||||
assert eager_load.include?(root("app/controllers"))
|
||||
assert eager_load.include?(root("app/helpers"))
|
||||
assert eager_load.include?(root("app/models"))
|
||||
end
|
||||
|
||||
test "environments has a glob equal to the current environment" do
|
||||
|
||||
@@ -263,13 +263,15 @@ YAML
|
||||
@plugin.write "config/routes.rb", <<-RUBY
|
||||
Rails.application.routes.draw do
|
||||
namespace :admin do
|
||||
match "index", :to => "admin/foo#index"
|
||||
namespace :foo do
|
||||
match "bar", :to => "admin/foo/bar#index"
|
||||
end
|
||||
end
|
||||
end
|
||||
RUBY
|
||||
|
||||
@plugin.write "app/controllers/admin/foo_controller.rb", <<-RUBY
|
||||
class Admin::FooController < ApplicationController
|
||||
@plugin.write "app/controllers/admin/foo/bar_controller.rb", <<-RUBY
|
||||
class Admin::Foo::BarController < ApplicationController
|
||||
def index
|
||||
render :text => "Rendered from namespace"
|
||||
end
|
||||
@@ -280,7 +282,7 @@ YAML
|
||||
require 'rack/test'
|
||||
extend Rack::Test::Methods
|
||||
|
||||
get "/admin/index"
|
||||
get "/admin/foo/bar"
|
||||
assert_equal 200, last_response.status
|
||||
assert_equal "Rendered from namespace", last_response.body
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user