From 2865421f5d77170c1ff39013d9d4efbc98526e74 Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Thu, 25 Jun 2009 16:18:02 -0700 Subject: Checkpoint. Added a bunch of TODOs and some changes after further going through the initializer --- railties/lib/initializer.rb | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index cdf2a22c83..697ccfa0dc 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -179,6 +179,10 @@ module Rails begin require 'active_support' require 'active_support/core_ext/kernel/reporting' + require 'active_support/core_ext/logger' + + # TODO: This is here to make Sam Ruby's tests pass. Needs discussion. + require 'active_support/core_ext/numeric/bytes' configuration.frameworks.each { |framework| require(framework.to_s) } rescue LoadError => e # Re-raise as RuntimeError because Mongrel would swallow LoadError. @@ -307,6 +311,7 @@ module Rails end end + # TODO: Why are we silencing warning here? silence_warnings { Object.const_set "RAILS_DEFAULT_LOGGER", logger } end @@ -326,6 +331,7 @@ module Rails # Sets the dependency loading mechanism based on the value of # Configuration#cache_classes. Initializer.default.add :initialize_dependency_mechanism do + # TODO: Remove files from the $" and always use require ActiveSupport::Dependencies.mechanism = configuration.cache_classes ? :require : :load end @@ -409,10 +415,6 @@ module Rails end end - # Add the load paths used by support functions such as the info controller - Initializer.default.add :add_support_load_paths do - end - Initializer.default.add :check_for_unbuilt_gems do unbuilt_gems = config.gems.select {|gem| gem.frozen? && !gem.built? } if unbuilt_gems.size > 0 @@ -462,6 +464,7 @@ Run `rake gems:build` to build the unbuilt gems. # # pick up any gems that plugins depend on Initializer.default.add :add_gem_load_paths do require 'rails/gem_dependency' + # TODO: This seems extraneous Rails::GemDependency.add_frozen_gem_path unless config.gems.empty? require "rubygems" @@ -529,6 +532,7 @@ Run `rake gems:install` to install the missing gems. end end + # TODO: Make a DSL way to limit an initializer to a particular framework # # Prepare dispatcher callbacks and run 'prepare' callbacks Initializer.default.add :prepare_dispatcher do @@ -557,17 +561,6 @@ Run `rake gems:install` to install the missing gems. end end - # # Load view path cache - Initializer.default.add :load_view_paths do - if configuration.frameworks.include?(:action_view) - if configuration.cache_classes - view_path = ActionView::FileSystemResolverWithFallback.new(configuration.view_path) - ActionController::Base.view_paths = view_path if configuration.frameworks.include?(:action_controller) - ActionMailer::Base.template_root = view_path if configuration.frameworks.include?(:action_mailer) - end - end - end - # Eager load application classes Initializer.default.add :load_application_classes do next if $rails_rake_task -- cgit v1.2.3 From 728e3b4047a55ead0f5fbb3bc57095b2b273352b Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Fri, 26 Jun 2009 11:21:17 -0700 Subject: Simple initial Paths impl --- railties/test/paths_test.rb | 68 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 railties/test/paths_test.rb diff --git a/railties/test/paths_test.rb b/railties/test/paths_test.rb new file mode 100644 index 0000000000..0da31b467a --- /dev/null +++ b/railties/test/paths_test.rb @@ -0,0 +1,68 @@ +require 'abstract_unit' + +module Rails + class Application + class Path + attr_accessor :path, :root #, :glob, :load_once, :eager + + def initialize(path, root = nil) + @children = {} + @path = path + @root = root || self + end + + def method_missing(id, *args) + name = id.to_s + + if name =~ /^(.*)=$/ + @children[$1] = Path.new(args.first, @root) + elsif path = @children[name] + path + else + super + end + end + + def path + @path.index('/') == 0 ? @path : File.join(@root.path, @path) + end + + alias to_s path + end + end +end + +class PathsTest < ActiveSupport::TestCase + + def setup + @root = Rails::Application::Path.new("/foo/bar") + end + + test "the paths object is initialized with the root path" do + root = Rails::Application::Path.new("/fiz/baz") + assert_equal "/fiz/baz", root.to_s + end + + test "creating a root level path" do + @root.app = "/foo/bar" + assert_equal "/foo/bar", @root.app.to_s + end + + test "relative paths are relative to the paths root" do + @root.app = "app" + assert_equal "/foo/bar/app", @root.app.to_s + end + + test "creating a child level path" do + @root.app = "/foo/bar" + @root.app.models = "/foo/bar/baz" + assert_equal "/foo/bar/baz", @root.app.models.to_s + end + + test "child level paths are relative from the root" do + @root.app = "/app" + @root.app.models = "baz" + + assert_equal "/foo/bar/baz", @root.app.models.to_s + end +end \ No newline at end of file -- cgit v1.2.3 From b0774281ef4008f2c249b1e85bbdb1f28629d18f Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Fri, 26 Jun 2009 12:12:20 -0700 Subject: Update paths to support an explicit root and multiple paths per category --- railties/test/paths_test.rb | 120 +++++++++++++++++++++++++++++++++----------- 1 file changed, 91 insertions(+), 29 deletions(-) diff --git a/railties/test/paths_test.rb b/railties/test/paths_test.rb index 0da31b467a..1fad324015 100644 --- a/railties/test/paths_test.rb +++ b/railties/test/paths_test.rb @@ -2,18 +2,10 @@ require 'abstract_unit' module Rails class Application - class Path - attr_accessor :path, :root #, :glob, :load_once, :eager - - def initialize(path, root = nil) - @children = {} - @path = path - @root = root || self - end - + module PathParent def method_missing(id, *args) name = id.to_s - + if name =~ /^(.*)=$/ @children[$1] = Path.new(args.first, @root) elsif path = @children[name] @@ -22,47 +14,117 @@ module Rails super end end - - def path - @path.index('/') == 0 ? @path : File.join(@root.path, @path) + end + + class Root + include PathParent + + attr_reader :path + def initialize(path) + raise unless path.is_a?(String) + + @children = {} + + # TODO: Move logic from set_root_path initializer + @path = File.expand_path(path) + @root = self + end + end + + class Path + include PathParent + + attr_reader :path #, :glob, :load_once, :eager + + def initialize(path, root) + @children = {} + @root = root + @paths = [path].flatten + end + + def push(path) + @paths.push path + end + + alias << push + + def unshift(path) + @paths.unshift path + end + + + def paths + @paths.map do |path| + path.index('/') == 0 ? path : File.join(@root.path, path) + end end - - alias to_s path + + alias to_a paths end end end class PathsTest < ActiveSupport::TestCase - + def setup - @root = Rails::Application::Path.new("/foo/bar") + @root = Rails::Application::Root.new("/foo/bar") end - + test "the paths object is initialized with the root path" do - root = Rails::Application::Path.new("/fiz/baz") - assert_equal "/fiz/baz", root.to_s + root = Rails::Application::Root.new("/fiz/baz") + assert_equal "/fiz/baz", root.path end - + test "creating a root level path" do @root.app = "/foo/bar" - assert_equal "/foo/bar", @root.app.to_s + assert_equal ["/foo/bar"], @root.app.to_a end - + test "relative paths are relative to the paths root" do @root.app = "app" - assert_equal "/foo/bar/app", @root.app.to_s + assert_equal ["/foo/bar/app"], @root.app.to_a end - + test "creating a child level path" do @root.app = "/foo/bar" @root.app.models = "/foo/bar/baz" - assert_equal "/foo/bar/baz", @root.app.models.to_s + assert_equal ["/foo/bar/baz"], @root.app.models.to_a end - + test "child level paths are relative from the root" do @root.app = "/app" @root.app.models = "baz" - - assert_equal "/foo/bar/baz", @root.app.models.to_s + + assert_equal ["/foo/bar/baz"], @root.app.models.to_a + end + + test "adding multiple physical paths as an array" do + @root.app = ["/app", "/app2"] + assert_equal ["/app", "/app2"], @root.app.to_a + end + + test "adding multiple physical paths using #push" do + @root.app = "/app" + @root.app.push "/app2" + assert_equal ["/app", "/app2"], @root.app.to_a + end + + test "adding multiple physical paths using <<" do + @root.app = "/app" + @root.app << "/app2" + assert_equal ["/app", "/app2"], @root.app.to_a + end + + test "adding multiple physical paths using #unshift" do + @root.app = "/app" + @root.app.unshift "/app2" + assert_equal ["/app2", "/app"], @root.app.to_a + end + + test "the root can only have one physical path" do + assert_raise(RuntimeError) { Rails::Application::Root.new(["/fiz", "/biz"]) } + assert_raise(NoMethodError) { @root.push "/biz" } + assert_raise(NoMethodError) { @root.unshift "/biz" } + assert_raise(NoMethodError) { @root << "/biz" } end end \ No newline at end of file -- cgit v1.2.3 From 4153c6b720563e1c43bb96e95f0ff5fbd59d6be7 Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Fri, 26 Jun 2009 15:36:38 -0700 Subject: Finished a first stab at the Rails application path object. --- railties/lib/rails/paths.rb | 85 ++++++++++++++++++++++++++++++++++++ railties/test/paths_test.rb | 104 +++++++++++++++++--------------------------- 2 files changed, 125 insertions(+), 64 deletions(-) create mode 100644 railties/lib/rails/paths.rb diff --git a/railties/lib/rails/paths.rb b/railties/lib/rails/paths.rb new file mode 100644 index 0000000000..0b43725e32 --- /dev/null +++ b/railties/lib/rails/paths.rb @@ -0,0 +1,85 @@ +require 'set' + +module Rails + class Application + module PathParent + def method_missing(id, *args) + name = id.to_s + + if name =~ /^(.*)=$/ + @children[$1] = Path.new(args.first, @root) + elsif path = @children[name] + path + else + super + end + end + end + + class Root + include PathParent + + attr_reader :path, :load_once, :eager_load + def initialize(path) + raise unless path.is_a?(String) + + @children = {} + + # TODO: Move logic from set_root_path initializer + @path = File.expand_path(path) + @root = self + @load_once, @eager_load = Set.new, Set.new + end + end + + class Path + include PathParent + + attr_reader :path + attr_accessor :glob + + def initialize(path, root) + @children = {} + @root = root + @paths = [path].flatten + @glob = "**/*.rb" + end + + def push(path) + @paths.push path + end + + alias << push + + def unshift(path) + @paths.unshift path + end + + def load_once! + @load_once = true + @root.load_once << self + end + + def load_once? + @load_once + end + + def eager_load! + @eager_load = true + @root.eager_load << self + end + + def eager_load? + @eager_load + end + + def paths + @paths.map do |path| + path.index('/') == 0 ? path : File.join(@root.path, path) + end + end + + alias to_a paths + end + end +end \ No newline at end of file diff --git a/railties/test/paths_test.rb b/railties/test/paths_test.rb index 1fad324015..e7df58579f 100644 --- a/railties/test/paths_test.rb +++ b/railties/test/paths_test.rb @@ -1,68 +1,5 @@ require 'abstract_unit' - -module Rails - class Application - module PathParent - def method_missing(id, *args) - name = id.to_s - - if name =~ /^(.*)=$/ - @children[$1] = Path.new(args.first, @root) - elsif path = @children[name] - path - else - super - end - end - end - - class Root - include PathParent - - attr_reader :path - def initialize(path) - raise unless path.is_a?(String) - - @children = {} - - # TODO: Move logic from set_root_path initializer - @path = File.expand_path(path) - @root = self - end - end - - class Path - include PathParent - - attr_reader :path #, :glob, :load_once, :eager - - def initialize(path, root) - @children = {} - @root = root - @paths = [path].flatten - end - - def push(path) - @paths.push path - end - - alias << push - - def unshift(path) - @paths.unshift path - end - - - def paths - @paths.map do |path| - path.index('/') == 0 ? path : File.join(@root.path, path) - end - end - - alias to_a paths - end - end -end +require 'rails/paths' class PathsTest < ActiveSupport::TestCase @@ -127,4 +64,43 @@ class PathsTest < ActiveSupport::TestCase assert_raise(NoMethodError) { @root.unshift "/biz" } assert_raise(NoMethodError) { @root << "/biz" } end + + test "it is possible to add a path that should be loaded only once" do + @root.app = "/app" + @root.app.load_once! + assert @root.app.load_once? + assert @root.load_once.include?(@root.app) + end + + test "making a path load_once more than once only includes it once in @root.load_once" do + @root.app = "/app" + @root.app.load_once! + @root.app.load_once! + assert_equal 1, @root.load_once.select {|p| p == @root.app }.size + end + + test "it is possible to mark a path as eager" do + @root.app = "/app" + @root.app.eager_load! + assert @root.app.eager_load? + assert @root.eager_load.include?(@root.app) + end + + test "making a path eager more than once only includes it once in @root.eager_paths" do + @root.app = "/app" + @root.app.eager_load! + @root.app.eager_load! + assert_equal 1, @root.eager_load.select {|p| p == @root.app }.size + end + + test "a path should have a glob that defaults to **/*.rb" do + @root.app = "/app" + assert_equal "**/*.rb", @root.app.glob + end + + test "it should be possible to override a path's default glob" do + @root.app = "/app" + @root.app.glob = "*.rb" + assert_equal "*.rb", @root.app.glob + end end \ No newline at end of file -- cgit v1.2.3 From 188a892c5a097ee6d62249d048a6be7d2dfe9649 Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Fri, 26 Jun 2009 17:32:05 -0700 Subject: Starting to replace scattered path configuration settings with the path object --- railties/lib/initializer.rb | 27 ++----- railties/lib/rails/configuration.rb | 33 ++++++++- railties/lib/rails/paths.rb | 43 ++++++++++- railties/lib/railties_path.rb | 2 +- railties/test/abstract_unit.rb | 1 + railties/test/initializer/path_test.rb | 86 ++++++++++++++++++++++ .../test/initializer/root/app/controllers/.keep | 0 railties/test/initializer/root/app/helpers/.keep | 0 railties/test/initializer/root/app/metal/.keep | 0 railties/test/initializer/root/app/models/.keep | 0 railties/test/initializer/root/app/views/.keep | 0 railties/test/initializer/root/config/database.yml | 4 + .../initializer/root/config/environments/.keep | 0 .../test/initializer/root/config/locales/.keep | 0 railties/test/initializer/root/config/routes.rb | 0 railties/test/initializer/root/lib/.keep | 0 railties/test/initializer/root/tmp/.keep | 0 railties/test/initializer/root/tmp/cache/.keep | 0 railties/test/initializer/root/vendor/.keep | 0 railties/test/paths_test.rb | 21 +++++- 20 files changed, 186 insertions(+), 31 deletions(-) create mode 100644 railties/test/initializer/path_test.rb create mode 100644 railties/test/initializer/root/app/controllers/.keep create mode 100644 railties/test/initializer/root/app/helpers/.keep create mode 100644 railties/test/initializer/root/app/metal/.keep create mode 100644 railties/test/initializer/root/app/models/.keep create mode 100644 railties/test/initializer/root/app/views/.keep create mode 100644 railties/test/initializer/root/config/database.yml create mode 100644 railties/test/initializer/root/config/environments/.keep create mode 100644 railties/test/initializer/root/config/locales/.keep create mode 100644 railties/test/initializer/root/config/routes.rb create mode 100644 railties/test/initializer/root/lib/.keep create mode 100644 railties/test/initializer/root/tmp/.keep create mode 100644 railties/test/initializer/root/tmp/cache/.keep create mode 100644 railties/test/initializer/root/vendor/.keep diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 697ccfa0dc..cd23158e98 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -5,6 +5,7 @@ require 'railties_path' require 'rails/version' require 'rails/gem_dependency' require 'rails/rack' +require 'rails/paths' require 'rails/core' require 'rails/configuration' @@ -112,24 +113,6 @@ module Rails require 'ruby_version_check' end - Initializer.default.add :set_root_path do - raise 'RAILS_ROOT is not set' unless defined?(RAILS_ROOT) - raise 'RAILS_ROOT is not a directory' unless File.directory?(RAILS_ROOT) - - configuration.root_path = - # Pathname is incompatible with Windows, but Windows doesn't have - # real symlinks so File.expand_path is safe. - if RUBY_PLATFORM =~ /(:?mswin|mingw)/ - File.expand_path(RAILS_ROOT) - - # Otherwise use Pathname#realpath which respects symlinks. - else - Pathname.new(RAILS_ROOT).realpath.to_s - end - - RAILS_ROOT.replace configuration.root_path - end - # If Rails is vendored and RubyGems is available, install stub GemSpecs # for Rails, Active Support, Active Record, Action Pack, Action Mailer, and # Active Resource. This allows Gem plugins to depend on Rails even when @@ -158,8 +141,9 @@ module Rails # Set the $LOAD_PATH based on the value of # Configuration#load_paths. Duplicates are removed. Initializer.default.add :set_load_path do - load_paths = configuration.load_paths + configuration.framework_paths - load_paths.reverse_each { |dir| $LOAD_PATH.unshift(dir) if File.directory?(dir) } + # TODO: Think about unifying this with the general Rails paths + configuration.framework_paths.reverse_each { |dir| $LOAD_PATH.unshift(dir) if File.directory?(dir) } + configuration.paths.add_to_load_path $LOAD_PATH.uniq! end @@ -221,6 +205,8 @@ module Rails Initializer.default.add :load_environment do silence_warnings do next if @environment_loaded + next unless File.file?(configuration.environment_path) + @environment_loaded = true config = configuration @@ -564,6 +550,7 @@ Run `rake gems:install` to install the missing gems. # Eager load application classes Initializer.default.add :load_application_classes do next if $rails_rake_task + if configuration.cache_classes configuration.eager_load_paths.each do |load_path| matcher = /\A#{Regexp.escape(load_path)}(.*)\.rb\Z/ diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb index fdb071fc18..59132efe98 100644 --- a/railties/lib/rails/configuration.rb +++ b/railties/lib/rails/configuration.rb @@ -10,7 +10,7 @@ module Rails :log_path, :log_level, :logger, :preload_frameworks, :database_configuration_file, :cache_store, :time_zone, :view_path, :metals, :controller_paths, :routes_configuration_file, - :eager_load_paths, :dependency_loading + :eager_load_paths, :dependency_loading, :paths def initialize set_root_path! @@ -61,7 +61,36 @@ module Rails Pathname.new(RAILS_ROOT).realpath.to_s end - RAILS_ROOT.replace self.root_path + @paths = Rails::Application::Root.new(root_path) + @paths.app = "app" + @paths.app.metals = "app/metal" + @paths.app.models = "app/models" + @paths.app.controllers = "app/controllers" + @paths.app.helpers = "app/helpers" + @paths.app.services = "app/services" + @paths.lib = "lib" + @paths.vendor = "vendor" + @paths.vendor.plugins = "vendor/plugins" + @paths.cache = "tmp/cache" + @paths.config = "config" + @paths.config.locales = "config/locales" + @paths.config.environments = "config/environments" + + @paths.app.controllers.push *builtin_directories + + @paths.app.load_path! + @paths.app.metals.load_path! + @paths.app.models.eager_load! + @paths.app.controllers.eager_load! + @paths.app.helpers.eager_load! + @paths.app.services.load_path! + @paths.app.metals.eager_load! + @paths.lib.load_path! + @paths.vendor.load_path! + + @paths.config.environments.glob = "#{RAILS_ENV}.rb" + + RAILS_ROOT.replace root_path end # Enable threaded mode. Allows concurrent requests to controller actions and diff --git a/railties/lib/rails/paths.rb b/railties/lib/rails/paths.rb index 0b43725e32..aada7d4a56 100644 --- a/railties/lib/rails/paths.rb +++ b/railties/lib/rails/paths.rb @@ -19,7 +19,7 @@ module Rails class Root include PathParent - attr_reader :path, :load_once, :eager_load + attr_reader :path def initialize(path) raise unless path.is_a?(String) @@ -28,7 +28,32 @@ module Rails # TODO: Move logic from set_root_path initializer @path = File.expand_path(path) @root = self - @load_once, @eager_load = Set.new, Set.new + @load_once, @eager_load, @all_paths = [], [], [] + end + + def load_once + @load_once.uniq! + @load_once + end + + def eager_load + @eager_load.uniq! + @eager_load + end + + def all_paths + @all_paths.uniq! + @all_paths + end + + def load_paths + all_paths.map { |path| path.paths }.flatten + end + + def add_to_load_path + load_paths.reverse_each do |path| + $LOAD_PATH.unshift(path) if File.directory?(path) + end end end @@ -57,7 +82,7 @@ module Rails def load_once! @load_once = true - @root.load_once << self + @root.load_once.push *self.paths end def load_once? @@ -66,13 +91,23 @@ module Rails def eager_load! @eager_load = true - @root.eager_load << self + @root.all_paths << self + @root.eager_load.push *self.paths end def eager_load? @eager_load end + def load_path! + @load_path = true + @root.all_paths << self + end + + def load_path? + @load_path + end + def paths @paths.map do |path| path.index('/') == 0 ? path : File.join(@root.path, path) diff --git a/railties/lib/railties_path.rb b/railties/lib/railties_path.rb index a298a4cc27..b729c095c8 100644 --- a/railties/lib/railties_path.rb +++ b/railties/lib/railties_path.rb @@ -1 +1 @@ -RAILTIES_PATH = File.join(File.dirname(__FILE__), '..') +RAILTIES_PATH = File.expand_path(File.join(File.dirname(__FILE__), '..')) diff --git a/railties/test/abstract_unit.rb b/railties/test/abstract_unit.rb index 0addcb8bf3..cef69e90cb 100644 --- a/railties/test/abstract_unit.rb +++ b/railties/test/abstract_unit.rb @@ -2,6 +2,7 @@ $:.unshift File.dirname(__FILE__) + "/../../activesupport/lib" $:.unshift File.dirname(__FILE__) + "/../../activerecord/lib" $:.unshift File.dirname(__FILE__) + "/../../actionpack/lib" $:.unshift File.dirname(__FILE__) + "/../../actionmailer/lib" +$:.unshift File.dirname(__FILE__) + "/../../activeresource/lib" $:.unshift File.dirname(__FILE__) + "/../lib" $:.unshift File.dirname(__FILE__) + "/../builtin/rails_info" diff --git a/railties/test/initializer/path_test.rb b/railties/test/initializer/path_test.rb new file mode 100644 index 0000000000..37e1eebbc7 --- /dev/null +++ b/railties/test/initializer/path_test.rb @@ -0,0 +1,86 @@ +require 'abstract_unit' +require 'active_support/ruby/shim' +require 'initializer' + +RAILS_ROOT.replace File.join(File.dirname(__FILE__), "root") + +module Rails + def self.vendor_rails? ; false ; end +end + +# TODO: Can this be reset? +Rails::Initializer.run do |config| + config.frameworks = [:action_controller, :action_view, :action_mailer, :active_record] +end + +class PathsTest < ActiveSupport::TestCase + def setup + @paths = Rails::Initializer.default.config.paths + end + + def root(*path) + File.expand_path(File.join(File.dirname(__FILE__), "root", *path)) + end + + def assert_path(paths, *dir) + assert_equal [root(*dir)], paths.paths + end + + test "booting up Rails yields a valid paths object" do + assert_path @paths.app, "app" + assert_path @paths.app.metals, "app", "metal" + assert_path @paths.app.models, "app", "models" + assert_path @paths.app.helpers, "app", "helpers" + assert_path @paths.app.services, "app", "services" + assert_path @paths.lib, "lib" + assert_path @paths.vendor, "vendor" + assert_path @paths.vendor.plugins, "vendor", "plugins" + assert_path @paths.cache, "tmp", "cache" + assert_path @paths.config, "config" + assert_path @paths.config.locales, "config", "locales" + assert_path @paths.config.environments, "config", "environments" + + assert_equal Pathname.new(File.dirname(__FILE__)).join("root", "app", "controllers").expand_path, + Pathname.new(@paths.app.controllers.to_a.first).expand_path + assert_equal Pathname.new(File.dirname(__FILE__)).join("..", "..", "builtin", "rails_info").expand_path, + Pathname.new(@paths.app.controllers.to_a[1]).expand_path + end + + test "booting up Rails yields a list of paths that are eager" do + assert @paths.app.models.eager_load? + assert @paths.app.controllers.eager_load? + assert @paths.app.helpers.eager_load? + assert @paths.app.metals.eager_load? + end + + test "environments has a glob equal to the current environment" do + assert_equal "#{RAILS_ENV}.rb", @paths.config.environments.glob + end + + def assert_in_load_path(*path) + assert $:.any? { |p| File.expand_path(p) == root(*path) }, "Load path does not include '#{root(*path)}'. They are:\n-----\n #{$:.join("\n")}\n-----" + end + + def assert_not_in_load_path(*path) + assert !$:.any? { |p| File.expand_path(p) == root(*path) }, "Load path includes '#{root(*path)}'. They are:\n-----\n #{$:.join("\n")}\n-----" + end + + test "load path includes each of the paths in config.paths as long as the directories exist" do + assert_in_load_path "app" + assert_in_load_path "app", "controllers" + assert_in_load_path "app", "metal" + assert_in_load_path "app", "models" + assert_in_load_path "app", "helpers" + assert_in_load_path "lib" + assert_in_load_path "vendor" + + assert_not_in_load_path "app", "views" + assert_not_in_load_path "app", "services" + assert_not_in_load_path "config" + assert_not_in_load_path "config", "locales" + assert_not_in_load_path "config", "environments" + assert_not_in_load_path "tmp" + assert_not_in_load_path "tmp", "cache" + end + +end \ No newline at end of file diff --git a/railties/test/initializer/root/app/controllers/.keep b/railties/test/initializer/root/app/controllers/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/railties/test/initializer/root/app/helpers/.keep b/railties/test/initializer/root/app/helpers/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/railties/test/initializer/root/app/metal/.keep b/railties/test/initializer/root/app/metal/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/railties/test/initializer/root/app/models/.keep b/railties/test/initializer/root/app/models/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/railties/test/initializer/root/app/views/.keep b/railties/test/initializer/root/app/views/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/railties/test/initializer/root/config/database.yml b/railties/test/initializer/root/config/database.yml new file mode 100644 index 0000000000..ce3356be0c --- /dev/null +++ b/railties/test/initializer/root/config/database.yml @@ -0,0 +1,4 @@ +development: + adapter: sqlite3 + database: db/railties.db + timeout: 5000 \ No newline at end of file diff --git a/railties/test/initializer/root/config/environments/.keep b/railties/test/initializer/root/config/environments/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/railties/test/initializer/root/config/locales/.keep b/railties/test/initializer/root/config/locales/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/railties/test/initializer/root/config/routes.rb b/railties/test/initializer/root/config/routes.rb new file mode 100644 index 0000000000..e69de29bb2 diff --git a/railties/test/initializer/root/lib/.keep b/railties/test/initializer/root/lib/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/railties/test/initializer/root/tmp/.keep b/railties/test/initializer/root/tmp/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/railties/test/initializer/root/tmp/cache/.keep b/railties/test/initializer/root/tmp/cache/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/railties/test/initializer/root/vendor/.keep b/railties/test/initializer/root/vendor/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/railties/test/paths_test.rb b/railties/test/paths_test.rb index e7df58579f..a1ed43ad6d 100644 --- a/railties/test/paths_test.rb +++ b/railties/test/paths_test.rb @@ -69,28 +69,28 @@ class PathsTest < ActiveSupport::TestCase @root.app = "/app" @root.app.load_once! assert @root.app.load_once? - assert @root.load_once.include?(@root.app) + assert @root.load_once.include?(@root.app.paths.first) end test "making a path load_once more than once only includes it once in @root.load_once" do @root.app = "/app" @root.app.load_once! @root.app.load_once! - assert_equal 1, @root.load_once.select {|p| p == @root.app }.size + assert_equal 1, @root.load_once.select {|p| p == @root.app.paths.first }.size end test "it is possible to mark a path as eager" do @root.app = "/app" @root.app.eager_load! assert @root.app.eager_load? - assert @root.eager_load.include?(@root.app) + assert @root.eager_load.include?(@root.app.paths.first) end test "making a path eager more than once only includes it once in @root.eager_paths" do @root.app = "/app" @root.app.eager_load! @root.app.eager_load! - assert_equal 1, @root.eager_load.select {|p| p == @root.app }.size + assert_equal 1, @root.eager_load.select {|p| p == @root.app.paths.first }.size end test "a path should have a glob that defaults to **/*.rb" do @@ -103,4 +103,17 @@ class PathsTest < ActiveSupport::TestCase @root.app.glob = "*.rb" assert_equal "*.rb", @root.app.glob end + + test "a path can be added to the load path" do + @root.app = "app" + @root.app.load_path! + @root.app.models = "app/models" + assert_equal ["/foo/bar/app"], @root.load_paths + end + + test "adding a path to the eager paths also adds it to the load path" do + @root.app = "app" + @root.app.eager_load! + assert_equal ["/foo/bar/app"], @root.load_paths + end end \ No newline at end of file -- cgit v1.2.3 From 68b02cb00aae4f4ee1b2b9b1eadb6951b747c181 Mon Sep 17 00:00:00 2001 From: Vicente Mundim Date: Sat, 27 Jun 2009 12:40:55 +1200 Subject: Make filter_parameters work correctly with array parameters. --- actionpack/lib/action_controller/base/filter_parameter_logging.rb | 4 ++++ actionpack/test/controller/filter_params_test.rb | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/actionpack/lib/action_controller/base/filter_parameter_logging.rb b/actionpack/lib/action_controller/base/filter_parameter_logging.rb index 26cd03f277..065e62a37f 100644 --- a/actionpack/lib/action_controller/base/filter_parameter_logging.rb +++ b/actionpack/lib/action_controller/base/filter_parameter_logging.rb @@ -43,6 +43,10 @@ module ActionController filtered_parameters[key] = '[FILTERED]' elsif value.is_a?(Hash) filtered_parameters[key] = filter_parameters(value) + elsif value.is_a?(Array) + filtered_parameters[key] = value.collect do |item| + filter_parameters(item) + end elsif block_given? key = key.dup value = value.dup if value diff --git a/actionpack/test/controller/filter_params_test.rb b/actionpack/test/controller/filter_params_test.rb index 8c9e4f81de..f7864745eb 100644 --- a/actionpack/test/controller/filter_params_test.rb +++ b/actionpack/test/controller/filter_params_test.rb @@ -40,7 +40,8 @@ class FilterParamTest < ActionController::TestCase [{'foo'=>'bar', 'bar'=>'foo'},{'foo'=>'[FILTERED]', 'bar'=>'foo'},%w'foo baz'], [{'foo'=>'bar', 'baz'=>'foo'},{'foo'=>'[FILTERED]', 'baz'=>'[FILTERED]'},%w'foo baz'], [{'bar'=>{'foo'=>'bar','bar'=>'foo'}},{'bar'=>{'foo'=>'[FILTERED]','bar'=>'foo'}},%w'fo'], - [{'foo'=>{'foo'=>'bar','bar'=>'foo'}},{'foo'=>'[FILTERED]'},%w'f banana']] + [{'foo'=>{'foo'=>'bar','bar'=>'foo'}},{'foo'=>'[FILTERED]'},%w'f banana'], + [{'baz'=>[{'foo'=>'baz'}]}, {'baz'=>[{'foo'=>'[FILTERED]'}]}, %w(foo)]] test_hashes.each do |before_filter, after_filter, filter_words| FilterParamController.filter_parameter_logging(*filter_words) -- cgit v1.2.3 From 085db5e128ad4ad8fd042776722c78e194c6d0a4 Mon Sep 17 00:00:00 2001 From: Chris Mear Date: Thu, 19 Feb 2009 14:16:10 +0000 Subject: Make text_area_tag escape contents by default. Signed-off-by: Michael Koziarski [#2015 state:committed] --- actionpack/lib/action_view/helpers/form_tag_helper.rb | 5 +++++ actionpack/test/template/form_tag_helper_test.rb | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index 8ab78e7bc6..ca6ba501e2 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -231,6 +231,8 @@ module ActionView # * :rows - Specify the number of rows in the textarea # * :cols - Specify the number of columns in the textarea # * :disabled - If set to true, the user will not be able to use this input. + # * :escape - By default, the contents of the text input are HTML escaped. + # If you need unescaped contents, set this to false. # * Any other key creates standard HTML attributes for the tag. # # ==== Examples @@ -258,6 +260,9 @@ module ActionView options["cols"], options["rows"] = size.split("x") if size.respond_to?(:split) end + escape = options.key?("escape") ? options.delete("escape") : true + content = html_escape(content) if escape + content_tag :textarea, content, { "name" => name, "id" => sanitize_to_id(name) }.update(options.stringify_keys) end diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb index 09d199b75d..f387123117 100644 --- a/actionpack/test/template/form_tag_helper_test.rb +++ b/actionpack/test/template/form_tag_helper_test.rb @@ -159,6 +159,18 @@ class FormTagHelperTest < ActionView::TestCase assert_match VALID_HTML_ID, input_elem['id'] end + def test_text_area_tag_escape_content + actual = text_area_tag "body", "hello world", :size => "20x40" + expected = %() + assert_dom_equal expected, actual + end + + def test_text_area_tag_unescaped_content + actual = text_area_tag "body", "hello world", :size => "20x40", :escape => false + expected = %() + assert_dom_equal expected, actual + end + def test_text_field_tag actual = text_field_tag "title", "Hello!" expected = %() -- cgit v1.2.3 From 7d548f795d226f57278f8bdd36298c9552421053 Mon Sep 17 00:00:00 2001 From: Justin French Date: Mon, 29 Jun 2009 15:54:09 +0200 Subject: Changed ActiveRecord::Base.human_name to underscore the class name before it humanizes it This gives you 'Post comment' rather than 'Postcomment' by default. Signed-off-by: Michael Koziarski [#2120 state:committed] --- activerecord/lib/active_record/base.rb | 6 +++--- activerecord/test/cases/reflection_test.rb | 8 +++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index f1b7c323dc..ff5a836b52 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1404,14 +1404,14 @@ module ActiveRecord #:nodoc: end # Transform the modelname into a more humane format, using I18n. - # Defaults to the basic humanize method. + # By default, it will underscore then humanize the class name (BlogPost.human_name #=> "Blog post"). # Default scope of the translation is activerecord.models # Specify +options+ with additional translating options. def human_name(options = {}) defaults = self_and_descendants_from_active_record.map do |klass| :"#{klass.name.underscore}" - end - defaults << self.name.humanize + end + defaults << self.name.underscore.humanize I18n.translate(defaults.shift, {:scope => [:activerecord, :models], :count => 1, :default => defaults}.merge(options)) end diff --git a/activerecord/test/cases/reflection_test.rb b/activerecord/test/cases/reflection_test.rb index db64bbb806..d861b5bb24 100644 --- a/activerecord/test/cases/reflection_test.rb +++ b/activerecord/test/cases/reflection_test.rb @@ -5,14 +5,20 @@ require 'models/company' require 'models/company_in_module' require 'models/subscriber' require 'models/pirate' +require 'models/price_estimate' class ReflectionTest < ActiveRecord::TestCase - fixtures :topics, :customers, :companies, :subscribers + fixtures :topics, :customers, :companies, :subscribers, :price_estimates def setup @first = Topic.find(1) end + def test_human_name + assert_equal "Price estimate", PriceEstimate.human_name + assert_equal "Subscriber", Subscriber.human_name + end + def test_column_null_not_null subscriber = Subscriber.find(:first) assert subscriber.column_for_attribute("name").null -- cgit v1.2.3 From 4954379283099231965fbc3fe00c39e0ef91c4b0 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Tue, 30 Jun 2009 08:41:17 -0700 Subject: Remove stray checks for Rspec in the testing setup. --- activesupport/lib/active_support/testing/declarative.rb | 6 ------ activesupport/lib/active_support/testing/setup_and_teardown.rb | 2 -- 2 files changed, 8 deletions(-) diff --git a/activesupport/lib/active_support/testing/declarative.rb b/activesupport/lib/active_support/testing/declarative.rb index a7af7f4224..a7df473644 100644 --- a/activesupport/lib/active_support/testing/declarative.rb +++ b/activesupport/lib/active_support/testing/declarative.rb @@ -15,12 +15,6 @@ module ActiveSupport end end - if defined?(Spec) - class << self - alias_method :test, :it - end - end - end end diff --git a/activesupport/lib/active_support/testing/setup_and_teardown.rb b/activesupport/lib/active_support/testing/setup_and_teardown.rb index 4537c30e9c..b59ac79e7b 100644 --- a/activesupport/lib/active_support/testing/setup_and_teardown.rb +++ b/activesupport/lib/active_support/testing/setup_and_teardown.rb @@ -10,8 +10,6 @@ module ActiveSupport if defined?(MiniTest::Assertions) && TestCase < MiniTest::Assertions include ForMiniTest - elsif defined? Spec - include ForRspec else include ForClassicTestUnit end -- cgit v1.2.3 From f66b5d79c15c92e0712315b5843e611114390a12 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Tue, 30 Jun 2009 09:01:46 -0700 Subject: Stop the initializer from blowing up when builtin_directories is empty --- railties/lib/rails/configuration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb index 59132efe98..7a903211fa 100644 --- a/railties/lib/rails/configuration.rb +++ b/railties/lib/rails/configuration.rb @@ -76,7 +76,7 @@ module Rails @paths.config.locales = "config/locales" @paths.config.environments = "config/environments" - @paths.app.controllers.push *builtin_directories + builtin_directories.each { |dir| @paths.app.controllers << dir } @paths.app.load_path! @paths.app.metals.load_path! -- cgit v1.2.3 From 9101941c1259627df99c5c13b8e893d5d593265c Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Tue, 30 Jun 2009 09:05:53 -0700 Subject: Require core_ext/kernel/requires in test_help to providing #require_library_or_gem --- railties/lib/test_help.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/railties/lib/test_help.rb b/railties/lib/test_help.rb index 94e089a624..ca30bd3187 100644 --- a/railties/lib/test_help.rb +++ b/railties/lib/test_help.rb @@ -3,6 +3,7 @@ silence_warnings { RAILS_ENV = "test" } require 'test/unit' +require 'active_support/core_ext/kernel/requires' require 'action_controller/testing/test_case' require 'action_view/test_case' require 'action_controller/testing/integration' -- cgit v1.2.3 From 575b95ea0bf3d3fff6f47dddad23c754fb294604 Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Tue, 30 Jun 2009 12:00:50 -0700 Subject: Created AS::Testing::Isolation which runs each test case in a separate process. This allows for testing rails bootup (files are required, correct constants are set, etc...). Currently, this is implemented via forking only, but we will add support for jruby and windows shortly. --- activesupport/lib/active_support/test_case.rb | 1 + .../lib/active_support/testing/isolation.rb | 39 ++++++ activesupport/test/isolation_test.rb | 141 +++++++++++++++++++++ 3 files changed, 181 insertions(+) create mode 100644 activesupport/lib/active_support/testing/isolation.rb create mode 100644 activesupport/test/isolation_test.rb diff --git a/activesupport/lib/active_support/test_case.rb b/activesupport/lib/active_support/test_case.rb index bab2a401eb..e99a4854ce 100644 --- a/activesupport/lib/active_support/test_case.rb +++ b/activesupport/lib/active_support/test_case.rb @@ -13,6 +13,7 @@ require 'active_support/testing/assertions' require 'active_support/testing/deprecation' require 'active_support/testing/declarative' require 'active_support/testing/pending' +require 'active_support/testing/isolation' module ActiveSupport class TestCase < ::Test::Unit::TestCase diff --git a/activesupport/lib/active_support/testing/isolation.rb b/activesupport/lib/active_support/testing/isolation.rb new file mode 100644 index 0000000000..8b2957fbe1 --- /dev/null +++ b/activesupport/lib/active_support/testing/isolation.rb @@ -0,0 +1,39 @@ +module ActiveSupport::Testing + class ProxyTestResult + def initialize + @calls = [] + end + + def __replay__(result) + @calls.each do |name, args| + result.send(name, *args) + end + end + + def method_missing(name, *args) + @calls << [name, args] + end + end + + module Isolation + def run(result) + yield(Test::Unit::TestCase::STARTED, name) + + read, write = IO.pipe + + pid = fork do + # child + read.close + proxy = ProxyTestResult.new + super(proxy) { } + write.puts [Marshal.dump(proxy)].pack("m") + exit! + end + + write.close + Marshal.load(read.read.unpack("m")[0]).__replay__(result) + Process.wait2(pid) + yield(Test::Unit::TestCase::FINISHED, name) + end + end +end \ No newline at end of file diff --git a/activesupport/test/isolation_test.rb b/activesupport/test/isolation_test.rb new file mode 100644 index 0000000000..4adf49ff62 --- /dev/null +++ b/activesupport/test/isolation_test.rb @@ -0,0 +1,141 @@ +require 'abstract_unit' + +# Does awesome +if ENV['CHILD'] + class ChildIsolationTest < ActiveSupport::TestCase + include ActiveSupport::Testing::Isolation + + def setup + @instance = "HELLO" + end + + def teardown + raise if @boom + end + + test "runs the test" do + assert true + end + + test "captures errors" do + raise + end + + test "captures failures" do + assert false + end + + test "first runs in isolation" do + assert_nil $x + $x = 1 + end + + test "second runs in isolation" do + assert_nil $x + $x = 2 + end + + test "runs with slow tests" do + sleep 0.3 + assert true + sleep 0.2 + end + + test "runs setup" do + assert "HELLO", @instance + end + + test "runs teardown" do + @boom = true + end + + test "resets requires one" do + assert !defined?(Racc) + require 'racc/parser' + end + + test "resets requires two" do + assert !defined?(Racc) + require 'racc/parser' + end + end +else + class ParentIsolationTest < ActiveSupport::TestCase + + ENV["CHILD"] = "1" + OUTPUT = `#{Gem.ruby} -I#{File.dirname(__FILE__)} #{File.expand_path(__FILE__)} -v` + ENV.delete("CHILD") + + def setup + # Extract the results + @results = {} + OUTPUT[/Started\n\s*(.*)\s*\nFinished/mi, 1].split(/\s*\n\s*/).each do |result| + result =~ %r'^(\w+)\(\w+\):\s*(\.|E|F)$' + @results[$1] = { 'E' => :error, '.' => :success, 'F' => :failure }[$2] + end + + # Extract the backtraces + @backtraces = {} + OUTPUT.scan(/^\s*\d+\).*?\n\n/m).each do |backtrace| + # \n 1) Error:\ntest_captures_errors(ChildIsolationTest): + backtrace =~ %r'\s*\d+\)\s*(Error|Failure):\n(\w+)'i + @backtraces[$2] = { :type => $1, :output => backtrace } + end + end + + def assert_failing(name) + assert_equal :failure, @results[name.to_s], "Test #{name} did not fail" + end + + def assert_passing(name) + assert_equal :success, @results[name.to_s], "Test #{name} did not pass" + end + + def assert_erroring(name) + assert_equal :error, @results[name.to_s], "Test #{name} did not error" + end + + test "has all tests" do + assert_equal 10, @results.length + end + + test "passing tests are still reported" do + assert_passing :test_runs_the_test + assert_passing :test_runs_with_slow_tests + end + + test "resets global variables" do + assert_passing :test_first_runs_in_isolation + assert_passing :test_second_runs_in_isolation + end + + test "resets requires" do + assert_passing :test_resets_requires_one + assert_passing :test_resets_requires_two + end + + test "erroring tests are still reported" do + assert_erroring :test_captures_errors + end + + test "runs setup and teardown methods" do + assert_passing :test_runs_setup + assert_erroring :test_runs_teardown + end + + test "correct tests fail" do + assert_failing :test_captures_failures + end + + test "backtrace is printed for errors" do + assert_equal 'Error', @backtraces["test_captures_errors"][:type] + assert_match %{isolation_test.rb:21:in `test_captures_errors'}, @backtraces["test_captures_errors"][:output] + end + + test "backtrace is printed for failures" do + assert_equal 'Failure', @backtraces["test_captures_failures"][:type] + assert_match %{isolation_test.rb:25:in `test_captures_failures'}, @backtraces["test_captures_failures"][:output] + end + + end +end \ No newline at end of file -- cgit v1.2.3 From f281745056cd67c967c5a695694061f515385be8 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Tue, 30 Jun 2009 13:53:03 -0700 Subject: Test that builtin_directories is only used in development mode --- railties/test/initializer/path_test.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/railties/test/initializer/path_test.rb b/railties/test/initializer/path_test.rb index 37e1eebbc7..8fbad24a73 100644 --- a/railties/test/initializer/path_test.rb +++ b/railties/test/initializer/path_test.rb @@ -14,6 +14,8 @@ Rails::Initializer.run do |config| end class PathsTest < ActiveSupport::TestCase + include ActiveSupport::Testing::Isolation + def setup @paths = Rails::Initializer.default.config.paths end @@ -83,4 +85,19 @@ class PathsTest < ActiveSupport::TestCase assert_not_in_load_path "tmp", "cache" end + test "controller paths include builtin in development mode" do + RAILS_ENV.replace "development" + assert Rails::Configuration.new.paths.app.controllers.paths.any? { |p| p =~ /builtin/ } + end + + test "controller paths does not have builtin_directories in test mode" do + RAILS_ENV.replace "test" + assert !Rails::Configuration.new.paths.app.controllers.paths.any? { |p| p =~ /builtin/ } + end + + test "controller paths does not have builtin_directories in production mode" do + RAILS_ENV.replace "production" + assert !Rails::Configuration.new.paths.app.controllers.paths.any? { |p| p =~ /builtin/ } + end + end \ No newline at end of file -- cgit v1.2.3 From 132e6d00638dc6370fafa0f1377d3bca17eee2d1 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Tue, 30 Jun 2009 13:55:11 -0700 Subject: Add #concat to Rails::Application::Path --- railties/lib/rails/configuration.rb | 2 +- railties/lib/rails/paths.rb | 4 ++++ railties/test/paths_test.rb | 7 +++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb index 7a903211fa..d877915460 100644 --- a/railties/lib/rails/configuration.rb +++ b/railties/lib/rails/configuration.rb @@ -76,7 +76,7 @@ module Rails @paths.config.locales = "config/locales" @paths.config.environments = "config/environments" - builtin_directories.each { |dir| @paths.app.controllers << dir } + @paths.app.controllers.concat builtin_directories @paths.app.load_path! @paths.app.metals.load_path! diff --git a/railties/lib/rails/paths.rb b/railties/lib/rails/paths.rb index aada7d4a56..d2f6d83659 100644 --- a/railties/lib/rails/paths.rb +++ b/railties/lib/rails/paths.rb @@ -80,6 +80,10 @@ module Rails @paths.unshift path end + def concat(paths) + @paths.concat paths + end + def load_once! @load_once = true @root.load_once.push *self.paths diff --git a/railties/test/paths_test.rb b/railties/test/paths_test.rb index a1ed43ad6d..fa2f6ceee2 100644 --- a/railties/test/paths_test.rb +++ b/railties/test/paths_test.rb @@ -52,6 +52,12 @@ class PathsTest < ActiveSupport::TestCase assert_equal ["/app", "/app2"], @root.app.to_a end + test "adding multiple physical paths using concat" do + @root.app = "/app" + @root.app.concat ["/app2", "/app3"] + assert_equal ["/app", "/app2", "/app3"], @root.app.to_a + end + test "adding multiple physical paths using #unshift" do @root.app = "/app" @root.app.unshift "/app2" @@ -62,6 +68,7 @@ class PathsTest < ActiveSupport::TestCase assert_raise(RuntimeError) { Rails::Application::Root.new(["/fiz", "/biz"]) } assert_raise(NoMethodError) { @root.push "/biz" } assert_raise(NoMethodError) { @root.unshift "/biz" } + assert_raise(NoMethodError) { @root.concat ["/biz"]} assert_raise(NoMethodError) { @root << "/biz" } end -- cgit v1.2.3 From db3de78a83379ab2a58e0d29fb10622b813a4d44 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Tue, 30 Jun 2009 14:37:12 -0700 Subject: Bump up the version to 3.0.pre --- actionmailer/Rakefile | 2 +- actionmailer/lib/action_mailer/version.rb | 6 +++--- actionpack/Rakefile | 2 +- actionpack/lib/action_pack/version.rb | 6 +++--- activerecord/Rakefile | 2 +- activerecord/lib/active_record/version.rb | 6 +++--- activeresource/Rakefile | 2 +- activeresource/lib/active_resource/version.rb | 6 +++--- activesupport/lib/active_support/version.rb | 6 +++--- railties/Rakefile | 10 +++++----- railties/lib/rails/version.rb | 6 +++--- 11 files changed, 27 insertions(+), 27 deletions(-) diff --git a/actionmailer/Rakefile b/actionmailer/Rakefile index 5475ffa493..ebcca0d246 100644 --- a/actionmailer/Rakefile +++ b/actionmailer/Rakefile @@ -60,7 +60,7 @@ spec = Gem::Specification.new do |s| s.rubyforge_project = "actionmailer" s.homepage = "http://www.rubyonrails.org" - s.add_dependency('actionpack', '= 2.3.2' + PKG_BUILD) + s.add_dependency('actionpack', '= 3.0.pre' + PKG_BUILD) s.has_rdoc = true s.requirements << 'none' diff --git a/actionmailer/lib/action_mailer/version.rb b/actionmailer/lib/action_mailer/version.rb index 08ff0d2ffb..0f2b58552b 100644 --- a/actionmailer/lib/action_mailer/version.rb +++ b/actionmailer/lib/action_mailer/version.rb @@ -1,8 +1,8 @@ module ActionMailer module VERSION #:nodoc: - MAJOR = 2 - MINOR = 3 - TINY = 2 + MAJOR = 3 + MINOR = 0 + TINY = "pre" STRING = [MAJOR, MINOR, TINY].join('.') end diff --git a/actionpack/Rakefile b/actionpack/Rakefile index 142c72ce6b..1fc5018561 100644 --- a/actionpack/Rakefile +++ b/actionpack/Rakefile @@ -115,7 +115,7 @@ spec = Gem::Specification.new do |s| s.has_rdoc = true s.requirements << 'none' - s.add_dependency('activesupport', '= 2.3.2' + PKG_BUILD) + s.add_dependency('activesupport', '= 3.0.pre' + PKG_BUILD) s.require_path = 'lib' s.autorequire = 'action_controller' diff --git a/actionpack/lib/action_pack/version.rb b/actionpack/lib/action_pack/version.rb index e0aa2a5f2f..ed0cdf38ee 100644 --- a/actionpack/lib/action_pack/version.rb +++ b/actionpack/lib/action_pack/version.rb @@ -1,8 +1,8 @@ module ActionPack #:nodoc: module VERSION #:nodoc: - MAJOR = 2 - MINOR = 3 - TINY = 2 + MAJOR = 3 + MINOR = 0 + TINY = "pre" STRING = [MAJOR, MINOR, TINY].join('.') end diff --git a/activerecord/Rakefile b/activerecord/Rakefile index 0b3f50d17e..0d33b9d516 100644 --- a/activerecord/Rakefile +++ b/activerecord/Rakefile @@ -187,7 +187,7 @@ spec = Gem::Specification.new do |s| s.files = s.files + Dir.glob( "#{dir}/**/*" ).delete_if { |item| item.include?( "\.svn" ) } end - s.add_dependency('activesupport', '= 2.3.2' + PKG_BUILD) + s.add_dependency('activesupport', '= 3.0.pre' + PKG_BUILD) s.files.delete FIXTURES_ROOT + "/fixture_database.sqlite" s.files.delete FIXTURES_ROOT + "/fixture_database_2.sqlite" diff --git a/activerecord/lib/active_record/version.rb b/activerecord/lib/active_record/version.rb index 852807b4c5..10ef9d7594 100644 --- a/activerecord/lib/active_record/version.rb +++ b/activerecord/lib/active_record/version.rb @@ -1,8 +1,8 @@ module ActiveRecord module VERSION #:nodoc: - MAJOR = 2 - MINOR = 3 - TINY = 2 + MAJOR = 3 + MINOR = 0 + TINY = "pre" STRING = [MAJOR, MINOR, TINY].join('.') end diff --git a/activeresource/Rakefile b/activeresource/Rakefile index eb5b1dd1ac..def489fad9 100644 --- a/activeresource/Rakefile +++ b/activeresource/Rakefile @@ -73,7 +73,7 @@ spec = Gem::Specification.new do |s| s.files = s.files + Dir.glob( "#{dir}/**/*" ).delete_if { |item| item.include?( "\.svn" ) } end - s.add_dependency('activesupport', '= 2.3.2' + PKG_BUILD) + s.add_dependency('activesupport', '= 3.0.pre' + PKG_BUILD) s.require_path = 'lib' s.autorequire = 'active_resource' diff --git a/activeresource/lib/active_resource/version.rb b/activeresource/lib/active_resource/version.rb index 3df2555d53..0f312eac39 100644 --- a/activeresource/lib/active_resource/version.rb +++ b/activeresource/lib/active_resource/version.rb @@ -1,8 +1,8 @@ module ActiveResource module VERSION #:nodoc: - MAJOR = 2 - MINOR = 3 - TINY = 2 + MAJOR = 3 + MINOR = 0 + TINY = "pre" STRING = [MAJOR, MINOR, TINY].join('.') end diff --git a/activesupport/lib/active_support/version.rb b/activesupport/lib/active_support/version.rb index 30f598a8de..3ae6150f2d 100644 --- a/activesupport/lib/active_support/version.rb +++ b/activesupport/lib/active_support/version.rb @@ -1,8 +1,8 @@ module ActiveSupport module VERSION #:nodoc: - MAJOR = 2 - MINOR = 3 - TINY = 2 + MAJOR = 3 + MINOR = 0 + TINY = "pre" STRING = [MAJOR, MINOR, TINY].join('.') end diff --git a/railties/Rakefile b/railties/Rakefile index 69c1ca762a..61c094150a 100644 --- a/railties/Rakefile +++ b/railties/Rakefile @@ -316,11 +316,11 @@ spec = Gem::Specification.new do |s| EOF s.add_dependency('rake', '>= 0.8.3') - s.add_dependency('activesupport', '= 2.3.2' + PKG_BUILD) - s.add_dependency('activerecord', '= 2.3.2' + PKG_BUILD) - s.add_dependency('actionpack', '= 2.3.2' + PKG_BUILD) - s.add_dependency('actionmailer', '= 2.3.2' + PKG_BUILD) - s.add_dependency('activeresource', '= 2.3.2' + PKG_BUILD) + s.add_dependency('activesupport', '= 3.0.pre' + PKG_BUILD) + s.add_dependency('activerecord', '= 3.0.pre' + PKG_BUILD) + s.add_dependency('actionpack', '= 3.0.pre' + PKG_BUILD) + s.add_dependency('actionmailer', '= 3.0.pre' + PKG_BUILD) + s.add_dependency('activeresource', '= 3.0.pre' + PKG_BUILD) s.rdoc_options << '--exclude' << '.' s.has_rdoc = false diff --git a/railties/lib/rails/version.rb b/railties/lib/rails/version.rb index 99c7516a65..9a65096061 100644 --- a/railties/lib/rails/version.rb +++ b/railties/lib/rails/version.rb @@ -1,8 +1,8 @@ module Rails module VERSION #:nodoc: - MAJOR = 2 - MINOR = 3 - TINY = 2 + MAJOR = 3 + MINOR = 0 + TINY = "pre" STRING = [MAJOR, MINOR, TINY].join('.') end -- cgit v1.2.3