aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2012-06-29 17:39:50 +0200
committerJosé Valim <jose.valim@gmail.com>2012-06-29 17:44:10 +0200
commit5e7d6bba79393de0279917f93b82f3b7b176f4b5 (patch)
tree1e9c6c8c183ba326efa33087d9b590c9196acec3 /railties
parent50b6110106a6e467f5e5f6303700522cebc60a9c (diff)
downloadrails-5e7d6bba79393de0279917f93b82f3b7b176f4b5.tar.gz
rails-5e7d6bba79393de0279917f93b82f3b7b176f4b5.tar.bz2
rails-5e7d6bba79393de0279917f93b82f3b7b176f4b5.zip
Revert "Allow loading external route files from the router"
This reverts commit 6acebb38bc0637bc05c19d87f8767f16ce79189b. Usage of this feature did not reveal any improvement in existing apps. Conflicts: actionpack/lib/action_dispatch/routing/mapper.rb guides/source/routing.textile railties/lib/rails/engine.rb railties/lib/rails/paths.rb railties/test/paths_test.rb
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails/application/routes_reloader.rb13
-rw-r--r--railties/lib/rails/engine.rb7
-rw-r--r--railties/lib/rails/engine/configuration.rb1
-rw-r--r--railties/lib/rails/paths.rb10
-rw-r--r--railties/test/application/paths_test.rb2
-rw-r--r--railties/test/application/routing_test.rb83
-rw-r--r--railties/test/paths_test.rb2
7 files changed, 6 insertions, 112 deletions
diff --git a/railties/lib/rails/application/routes_reloader.rb b/railties/lib/rails/application/routes_reloader.rb
index 19f616ec50..6f9a200aa9 100644
--- a/railties/lib/rails/application/routes_reloader.rb
+++ b/railties/lib/rails/application/routes_reloader.rb
@@ -3,13 +3,12 @@ require "active_support/core_ext/module/delegation"
module Rails
class Application
class RoutesReloader
- attr_reader :route_sets, :paths, :external_routes
+ attr_reader :route_sets, :paths
delegate :execute_if_updated, :execute, :updated?, :to => :updater
def initialize
- @paths = []
- @route_sets = []
- @external_routes = []
+ @paths = []
+ @route_sets = []
end
def reload!
@@ -24,11 +23,7 @@ module Rails
def updater
@updater ||= begin
- dirs = @external_routes.each_with_object({}) do |dir, hash|
- hash[dir.to_s] = %w(rb)
- end
-
- updater = ActiveSupport::FileUpdateChecker.new(paths, dirs) { reload! }
+ updater = ActiveSupport::FileUpdateChecker.new(paths) { reload! }
updater.execute
updater
end
diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb
index 309d265477..383c159d3d 100644
--- a/railties/lib/rails/engine.rb
+++ b/railties/lib/rails/engine.rb
@@ -508,10 +508,7 @@ module Rails
# Defines the routes for this engine. If a block is given to
# routes, it is appended to the engine.
def routes
- @routes ||= ActionDispatch::Routing::RouteSet.new.tap do |routes|
- routes.draw_paths.concat paths["config/routes"].paths
- end
-
+ @routes ||= ActionDispatch::Routing::RouteSet.new
@routes.append(&Proc.new) if block_given?
@routes
end
@@ -555,12 +552,10 @@ module Rails
initializer :add_routing_paths do |app|
paths = self.paths["config/routes.rb"].existent
- external_paths = self.paths["config/routes"].paths
if routes? || paths.any?
app.routes_reloader.paths.unshift(*paths)
app.routes_reloader.route_sets << routes
- app.routes_reloader.external_routes.unshift(*external_paths)
end
end
diff --git a/railties/lib/rails/engine/configuration.rb b/railties/lib/rails/engine/configuration.rb
index e31df807a6..6b18b1e249 100644
--- a/railties/lib/rails/engine/configuration.rb
+++ b/railties/lib/rails/engine/configuration.rb
@@ -53,7 +53,6 @@ module Rails
paths.add "config/initializers", :glob => "**/*.rb"
paths.add "config/locales", :glob => "*.{rb,yml}"
paths.add "config/routes.rb"
- paths.add "config/routes", :glob => "**/*.rb"
paths.add "db"
paths.add "db/migrate"
paths.add "db/seeds.rb"
diff --git a/railties/lib/rails/paths.rb b/railties/lib/rails/paths.rb
index 6cd9c7bc95..9b4a69f19f 100644
--- a/railties/lib/rails/paths.rb
+++ b/railties/lib/rails/paths.rb
@@ -114,7 +114,7 @@ module Rails
class Path
include Enumerable
- attr_reader :path, :root
+ attr_reader :path
attr_accessor :glob
def initialize(root, current, paths, options = {})
@@ -180,14 +180,6 @@ module Rails
@paths
end
- def paths
- raise "You need to set a path root" unless @root.path
-
- map do |p|
- File.join @root.path, p
- end
- end
-
# Expands all paths against the root and return all unique values.
def expanded
raise "You need to set a path root" unless @root.path
diff --git a/railties/test/application/paths_test.rb b/railties/test/application/paths_test.rb
index e0893f53be..4029984ce9 100644
--- a/railties/test/application/paths_test.rb
+++ b/railties/test/application/paths_test.rb
@@ -50,8 +50,6 @@ module ApplicationTests
assert_path @paths["config/locales"], "config/locales/en.yml"
assert_path @paths["config/environment"], "config/environment.rb"
assert_path @paths["config/environments"], "config/environments/development.rb"
- assert_path @paths["config/routes.rb"], "config/routes.rb"
- assert_path @paths["config/routes"], "config/routes"
assert_equal root("app", "controllers"), @paths["app/controllers"].expanded.first
end
diff --git a/railties/test/application/routing_test.rb b/railties/test/application/routing_test.rb
index d1373ba202..396b1849d8 100644
--- a/railties/test/application/routing_test.rb
+++ b/railties/test/application/routing_test.rb
@@ -178,90 +178,7 @@ module ApplicationTests
assert_equal 'WIN', last_response.body
end
- test "routes drawing from config/routes" do
- app_file 'config/routes.rb', <<-RUBY
- AppTemplate::Application.routes.draw do
- draw :external
- end
- RUBY
-
- app_file 'config/routes/external.rb', <<-RUBY
- get ':controller/:action'
- RUBY
-
- controller :success, <<-RUBY
- class SuccessController < ActionController::Base
- def index
- render :text => "success!"
- end
- end
- RUBY
-
- app 'development'
- get '/success/index'
- assert_equal 'success!', last_response.body
- end
-
{"development" => "baz", "production" => "bar"}.each do |mode, expected|
- test "reloads routes when external configuration is changed in #{mode}" do
- controller :foo, <<-RUBY
- class FooController < ApplicationController
- def bar
- render :text => "bar"
- end
-
- def baz
- render :text => "baz"
- end
- end
- RUBY
-
- app_file 'config/routes.rb', <<-RUBY
- AppTemplate::Application.routes.draw do
- draw :external
- end
- RUBY
-
- app_file 'config/routes/external.rb', <<-RUBY
- get 'foo', :to => 'foo#bar'
- RUBY
-
- app(mode)
-
- get '/foo'
- assert_equal 'bar', last_response.body
-
- app_file 'config/routes/external.rb', <<-RUBY
- get 'foo', :to => 'foo#baz'
- RUBY
-
- sleep 0.1
-
- get '/foo'
- assert_equal expected, last_response.body
-
- app_file 'config/routes.rb', <<-RUBY
- AppTemplate::Application.routes.draw do
- draw :external
- draw :other_external
- end
- RUBY
-
- app_file 'config/routes/other_external.rb', <<-RUBY
- get 'win', :to => 'foo#baz'
- RUBY
-
- sleep 0.1
-
- get '/win'
-
- if mode == "development"
- assert_equal expected, last_response.body
- else
- assert_equal 404, last_response.status
- end
- end
-
test "reloads routes when configuration is changed in #{mode}" do
controller :foo, <<-RUBY
class FooController < ApplicationController
diff --git a/railties/test/paths_test.rb b/railties/test/paths_test.rb
index 5d6b6f9f72..d334034e7d 100644
--- a/railties/test/paths_test.rb
+++ b/railties/test/paths_test.rb
@@ -29,7 +29,6 @@ class PathsTest < ActiveSupport::TestCase
test "creating a root level path" do
@root.add "app"
assert_equal ["/foo/bar/app"], @root["app"].to_a
- assert_equal ["/foo/bar/app"], @root["app"].paths
end
test "creating a root level path with options" do
@@ -192,7 +191,6 @@ class PathsTest < ActiveSupport::TestCase
@root["app"] = "/app"
@root["app"].glob = "*.rb"
assert_equal "*.rb", @root["app"].glob
- assert_equal ["/foo/bar/app"], @root["app"].paths
end
test "it should be possible to override a path's default glob without assignment" do