diff options
author | José Valim <jose.valim@gmail.com> | 2009-11-24 09:24:40 -0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2009-11-24 09:24:40 -0200 |
commit | 41e607dee20b15d8dc71dc16a08d4bbe9e36ac70 (patch) | |
tree | a99108c3e60bb9f44f5f1870d885971de383b9e4 | |
parent | 16cf25e717c9b13e402fda33fe859684e1d8a154 (diff) | |
parent | e62e6d409986cd5c99234689aa49e3162d7b3a59 (diff) | |
download | rails-41e607dee20b15d8dc71dc16a08d4bbe9e36ac70.tar.gz rails-41e607dee20b15d8dc71dc16a08d4bbe9e36ac70.tar.bz2 rails-41e607dee20b15d8dc71dc16a08d4bbe9e36ac70.zip |
Merge branch 'master' of git://github.com/rails/rails
-rw-r--r-- | actionpack/lib/action_dispatch/routing.rb | 117 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/deprecated_mapper.rb | 3 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 4 | ||||
-rw-r--r-- | actionpack/test/abstract_unit.rb | 12 | ||||
-rw-r--r-- | actionpack/test/controller/routing_test.rb | 31 | ||||
-rw-r--r-- | actionpack/test/template/url_helper_test.rb | 45 | ||||
-rw-r--r-- | railties/lib/rails/commands/console.rb | 85 | ||||
-rw-r--r-- | railties/lib/rails/commands/server.rb | 120 | ||||
-rw-r--r-- | railties/lib/rails/configuration.rb | 2 | ||||
-rwxr-xr-x | railties/lib/rails/generators/rails/app/templates/script/console | 1 | ||||
-rwxr-xr-x | railties/lib/rails/generators/rails/app/templates/script/server | 1 | ||||
-rw-r--r-- | railties/test/application/notifications_test.rb | 4 | ||||
-rw-r--r-- | railties/test/rails_info_controller_test.rb | 5 |
14 files changed, 177 insertions, 255 deletions
diff --git a/actionpack/lib/action_dispatch/routing.rb b/actionpack/lib/action_dispatch/routing.rb index 68ed1e3340..9b977800b4 100644 --- a/actionpack/lib/action_dispatch/routing.rb +++ b/actionpack/lib/action_dispatch/routing.rb @@ -264,11 +264,8 @@ module ActionDispatch autoload :RouteSet, 'action_dispatch/routing/route_set' SEPARATORS = %w( / . ? ) - HTTP_METHODS = [:get, :head, :post, :put, :delete, :options] - ALLOWED_REQUIREMENTS_FOR_OPTIMISATION = [:controller, :action].to_set - # The root paths which may contain controller files mattr_accessor :controller_paths self.controller_paths = [] @@ -279,46 +276,28 @@ module ActionDispatch end class << self - # Expects an array of controller names as the first argument. - # Executes the passed block with only the named controllers named available. - # This method is used in internal Rails testing. - def with_controllers(names) - prior_controllers = @possible_controllers - use_controllers! names - yield - ensure - use_controllers! prior_controllers + def controller_constraints + @controller_constraints ||= Regexp.union(*possible_controllers.collect { |n| Regexp.escape(n) }) end - # Returns an array of paths, cleaned of double-slashes and relative path references. - # * "\\\" and "//" become "\\" or "/". - # * "/foo/bar/../config" becomes "/foo/config". - # The returned array is sorted by length, descending. - def normalize_paths(paths) - # do the hokey-pokey of path normalization... - paths = paths.collect do |path| - path = path. - gsub("//", "/"). # replace double / chars with a single - gsub("\\\\", "\\"). # replace double \ chars with a single - gsub(%r{(.)[\\/]$}, '\1') # drop final / or \ if path ends with it - - # eliminate .. paths where possible - re = %r{[^/\\]+[/\\]\.\.[/\\]} - path.gsub!(re, "") while path.match(re) - path - end - - # start with longest path, first - paths = paths.uniq.sort_by { |path| - path.length } + def clear_controller_cache! + @controller_constraints = nil end - # Returns the array of controller names currently available to ActionController::Routing. - def possible_controllers - unless @possible_controllers - @possible_controllers = [] + private + # Returns the array of controller names currently available to ActionController::Routing. + def possible_controllers + possible_controllers = [] - paths = controller_paths.select { |path| File.directory?(path) && path != "." } + # Find any controller classes already in memory + ActionController::Base.subclasses.each do |klass| + controller_name = klass.underscore + controller_name.gsub!(/_controller\Z/, '') + possible_controllers << controller_name + end + # Find controllers in controllers/ directory + paths = controller_paths.select { |path| File.directory?(path) && path != "." } seen_paths = Hash.new {|h, k| h[k] = true; false} normalize_paths(paths).each do |load_path| Dir["#{load_path}/**/*_controller.rb"].collect do |path| @@ -327,55 +306,37 @@ module ActionDispatch controller_name = path[(load_path.length + 1)..-1] controller_name.gsub!(/_controller\.rb\Z/, '') - @possible_controllers << controller_name + possible_controllers << controller_name end end # remove duplicates - @possible_controllers.uniq! - end - @possible_controllers - end - - # Replaces the internal list of controllers available to ActionController::Routing with the passed argument. - # ActionController::Routing.use_controllers!([ "posts", "comments", "admin/comments" ]) - def use_controllers!(controller_names) - @possible_controllers = controller_names - end + possible_controllers.uniq! - # Returns a controller path for a new +controller+ based on a +previous+ controller path. - # Handles 4 scenarios: - # - # * stay in the previous controller: - # controller_relative_to( nil, "groups/discussion" ) # => "groups/discussion" - # - # * stay in the previous namespace: - # controller_relative_to( "posts", "groups/discussion" ) # => "groups/posts" - # - # * forced move to the root namespace: - # controller_relative_to( "/posts", "groups/discussion" ) # => "posts" - # - # * previous namespace is root: - # controller_relative_to( "posts", "anything_with_no_slashes" ) # =>"posts" - # - def controller_relative_to(controller, previous) - if controller.nil? then previous - elsif controller[0] == ?/ then controller[1..-1] - elsif %r{^(.*)/} =~ previous then "#{$1}/#{controller}" - else controller + possible_controllers end - end - end - ActiveSupport::Inflector.module_eval do - # Ensures that routes are reloaded when Rails inflections are updated. - def inflections_with_route_reloading(&block) - returning(inflections_without_route_reloading(&block)) { - ActionDispatch::Routing::Routes.reload! if block_given? - } - end + # Returns an array of paths, cleaned of double-slashes and relative path references. + # * "\\\" and "//" become "\\" or "/". + # * "/foo/bar/../config" becomes "/foo/config". + # The returned array is sorted by length, descending. + def normalize_paths(paths) + # do the hokey-pokey of path normalization... + paths = paths.collect do |path| + path = path. + gsub("//", "/"). # replace double / chars with a single + gsub("\\\\", "\\"). # replace double \ chars with a single + gsub(%r{(.)[\\/]$}, '\1') # drop final / or \ if path ends with it + + # eliminate .. paths where possible + re = %r{[^/\\]+[/\\]\.\.[/\\]} + path.gsub!(re, "") while path.match(re) + path + end - alias_method_chain :inflections, :route_reloading + # start with longest path, first + paths = paths.uniq.sort_by { |path| - path.length } + end end end end diff --git a/actionpack/lib/action_dispatch/routing/deprecated_mapper.rb b/actionpack/lib/action_dispatch/routing/deprecated_mapper.rb index 0564ba9797..dd76391870 100644 --- a/actionpack/lib/action_dispatch/routing/deprecated_mapper.rb +++ b/actionpack/lib/action_dispatch/routing/deprecated_mapper.rb @@ -113,8 +113,7 @@ module ActionDispatch end end - possible_names = Routing.possible_controllers.collect { |n| Regexp.escape(n) } - requirements[:controller] ||= Regexp.union(*possible_names) + requirements[:controller] ||= Routing.controller_constraints if defaults[:controller] defaults[:action] ||= 'index' diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 6e112c9b54..cfe7425a61 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -282,6 +282,8 @@ module ActionDispatch constraints.reject! { |k, v| segment_keys.include?(k.to_s) } conditions.merge!(constraints) + requirements[:controller] ||= Routing.controller_constraints + if via = options[:via] via = Array(via).map { |m| m.to_s.upcase } conditions[:request_method] = Regexp.union(*via) diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index c15aaceb5b..79e15edeaa 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -246,7 +246,9 @@ module ActionDispatch end def load! - Routing.use_controllers!(nil) # Clear the controller cache so we may discover new ones + # Clear the controller cache so we may discover new ones + Routing.clear_controller_cache! + load_routes! end diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb index 775cfc82bf..9d055da4b9 100644 --- a/actionpack/test/abstract_unit.rb +++ b/actionpack/test/abstract_unit.rb @@ -191,20 +191,8 @@ class ::ApplicationController < ActionController::Base end module ActionController - module Routing - def self.possible_controllers - @@possible_controllers ||= [] - end - end - class Base include ActionController::Testing - - def self.inherited(klass) - name = klass.name.underscore.sub(/_controller$/, '') - ActionController::Routing.possible_controllers << name unless name.blank? - super - end end Base.view_paths = FIXTURE_LOAD_PATH diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index 4eaf309c41..b5effeda40 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -51,30 +51,6 @@ class UriReservedCharactersRoutingTest < Test::Unit::TestCase end end -class RoutingTest < Test::Unit::TestCase - def test_normalize_unix_paths - load_paths = %w(. config/../app/controllers config/../app//helpers script/../config/../vendor/rails/actionpack/lib vendor/rails/railties/builtin/rails_info app/models lib script/../config/../foo/bar/../../app/models .foo/../.bar foo.bar/../config) - paths = ActionController::Routing.normalize_paths(load_paths) - assert_equal %w(vendor/rails/railties/builtin/rails_info vendor/rails/actionpack/lib app/controllers app/helpers app/models config .bar lib .), paths - end - - def test_normalize_windows_paths - load_paths = %w(. config\\..\\app\\controllers config\\..\\app\\\\helpers script\\..\\config\\..\\vendor\\rails\\actionpack\\lib vendor\\rails\\railties\\builtin\\rails_info app\\models lib script\\..\\config\\..\\foo\\bar\\..\\..\\app\\models .foo\\..\\.bar foo.bar\\..\\config) - paths = ActionController::Routing.normalize_paths(load_paths) - assert_equal %w(vendor\\rails\\railties\\builtin\\rails_info vendor\\rails\\actionpack\\lib app\\controllers app\\helpers app\\models config .bar lib .), paths - end - - def test_routing_helper_module - assert_kind_of Module, ActionController::Routing::Helpers - - h = ActionController::Routing::Helpers - c = Class.new - assert ! c.ancestors.include?(h) - ActionController::Routing::Routes.install_helpers c - assert c.ancestors.include?(h) - end -end - class MockController attr_accessor :routes @@ -1762,13 +1738,6 @@ class RouteLoadingTest < Test::Unit::TestCase 2.times { routes.reload! } end - def test_adding_inflections_forces_reload - ActiveSupport::Inflector::Inflections.instance.expects(:uncountable).with('equipment') - routes.expects(:reload!) - - ActiveSupport::Inflector.inflections { |inflect| inflect.uncountable('equipment') } - end - def test_load_with_configuration routes.configuration_files.clear routes.add_configuration_file("foobarbaz") diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index bf0b4ad3a7..5c463a4f60 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -391,54 +391,47 @@ class UrlHelperTest < ActionView::TestCase end end -class UrlHelperController < ActionController::Base - def self.controller_path; 'url_helper_with_controller' end +class UrlHelperControllerTest < ActionController::TestCase + class UrlHelperController < ActionController::Base + def show_url_for + render :inline => "<%= url_for :controller => 'url_helper_controller_test/url_helper', :action => 'show_url_for' %>" + end - def show_url_for - render :inline => "<%= url_for :controller => 'url_helper_with_controller', :action => 'show_url_for' %>" - end + def show_named_route + render :inline => "<%= show_named_route_#{params[:kind]} %>" + end - def show_named_route - render :inline => "<%= show_named_route_#{params[:kind]} %>" - end + def nil_url_for + render :inline => '<%= url_for(nil) %>' + end - def nil_url_for - render :inline => '<%= url_for(nil) %>' + def rescue_action(e) raise e end end - def rescue_action(e) raise e end -end - -class UrlHelperWithControllerTest < ActionController::TestCase - def setup - super - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - @controller = UrlHelperController.new - end + tests UrlHelperController def test_url_for_shows_only_path get :show_url_for - assert_equal '/url_helper_with_controller/show_url_for', @response.body + assert_equal '/url_helper_controller_test/url_helper/show_url_for', @response.body end def test_named_route_url_shows_host_and_path with_url_helper_routing do get :show_named_route, :kind => 'url' - assert_equal 'http://test.host/url_helper_with_controller/show_named_route', @response.body + assert_equal 'http://test.host/url_helper_controller_test/url_helper/show_named_route', @response.body end end def test_named_route_path_shows_only_path with_url_helper_routing do get :show_named_route, :kind => 'path' - assert_equal '/url_helper_with_controller/show_named_route', @response.body + assert_equal '/url_helper_controller_test/url_helper/show_named_route', @response.body end end def test_url_for_nil_returns_current_path get :nil_url_for - assert_equal '/url_helper/nil_url_for', @response.body + assert_equal '/url_helper_controller_test/url_helper/nil_url_for', @response.body end def test_named_route_should_show_host_and_path_using_controller_default_url_options @@ -450,7 +443,7 @@ class UrlHelperWithControllerTest < ActionController::TestCase with_url_helper_routing do get :show_named_route, :kind => 'url' - assert_equal 'http://testtwo.host/url_helper_with_controller/show_named_route', @response.body + assert_equal 'http://testtwo.host/url_helper_controller_test/url_helper/show_named_route', @response.body end end @@ -458,7 +451,7 @@ class UrlHelperWithControllerTest < ActionController::TestCase def with_url_helper_routing with_routing do |set| set.draw do |map| - map.show_named_route 'url_helper_with_controller/show_named_route', :controller => 'url_helper', :action => 'show_named_route' + map.show_named_route 'url_helper_controller_test/url_helper/show_named_route', :controller => 'url_helper_controller_test/url_helper', :action => 'show_named_route' end yield end diff --git a/railties/lib/rails/commands/console.rb b/railties/lib/rails/commands/console.rb index b977b7162f..fc22ad64a9 100644 --- a/railties/lib/rails/commands/console.rb +++ b/railties/lib/rails/commands/console.rb @@ -1,45 +1,52 @@ -irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb' - require 'optparse' +require 'irb' +require "irb/completion" -options = { :sandbox => false, :irb => irb } -OptionParser.new do |opt| - opt.banner = "Usage: console [environment] [options]" - opt.on('-s', '--sandbox', 'Rollback database modifications on exit.') { |v| options[:sandbox] = v } - opt.on("--irb=[#{irb}]", 'Invoke a different irb.') { |v| options[:irb] = v } - opt.on("--debugger", 'Enable ruby-debugging for the console.') { |v| options[:debugger] = v } - opt.parse!(ARGV) -end +module Rails + class Console + ENVIRONMENTS = %w(production development test) -libs = " -r irb/completion" -libs << %( -r "#{Rails.root}/config/environment") -libs << " -r rails/console_app" -libs << " -r rails/console_sandbox" if options[:sandbox] -libs << " -r rails/console_with_helpers" - -if options[:debugger] - begin - require 'ruby-debug' - libs << " -r ruby-debug" - puts "=> Debugger enabled" - rescue Exception - puts "You need to install ruby-debug to run the console in debugging mode. With gems, use 'gem install ruby-debug'" - exit - end -end + def self.start + new.start + end -ENV['RAILS_ENV'] = case ARGV.first - when "p"; "production" - when "d"; "development" - when "t"; "test" - else - ARGV.first || ENV['RAILS_ENV'] || 'development' -end + def start + options = {} -if options[:sandbox] - puts "Loading #{ENV['RAILS_ENV']} environment in sandbox (Rails #{Rails.version})" - puts "Any modifications you make will be rolled back on exit" -else - puts "Loading #{ENV['RAILS_ENV']} environment (Rails #{Rails.version})" + OptionParser.new do |opt| + opt.banner = "Usage: console [environment] [options]" + opt.on('-s', '--sandbox', 'Rollback database modifications on exit.') { |v| options[:sandbox] = v } + opt.on("--debugger", 'Enable ruby-debugging for the console.') { |v| options[:debugger] = v } + opt.on('--irb') { |v| abort '--irb option is no longer supported. Invoke `/your/choice/of/ruby script/console` instead' } + opt.parse!(ARGV) + end + + if env = ARGV.first + ENV['RAILS_ENV'] = ENVIRONMENTS.find { |e| e.index(env) } || env + end + + require "#{Rails.root}/config/environment" + require "rails/console_app" + require "rails/console_sandbox" if options[:sandbox] + require "rails/console_with_helpers" + + if options[:debugger] + begin + require 'ruby-debug' + puts "=> Debugger enabled" + rescue Exception + puts "You need to install ruby-debug to run the console in debugging mode. With gems, use 'gem install ruby-debug'" + exit + end + end + + if options[:sandbox] + puts "Loading #{ENV['RAILS_ENV']} environment in sandbox (Rails #{Rails.version})" + puts "Any modifications you make will be rolled back on exit" + else + puts "Loading #{ENV['RAILS_ENV']} environment (Rails #{Rails.version})" + end + IRB.start + end + end end -exec "#{options[:irb]} #{libs} --simple-prompt" diff --git a/railties/lib/rails/commands/server.rb b/railties/lib/rails/commands/server.rb index 2c90851fb2..ff2282a534 100644 --- a/railties/lib/rails/commands/server.rb +++ b/railties/lib/rails/commands/server.rb @@ -1,73 +1,75 @@ -require 'action_dispatch' - require 'fileutils' require 'optparse' +require 'action_dispatch' -options = { - :Port => 3000, - :Host => "0.0.0.0", - :environment => (ENV['RAILS_ENV'] || "development").dup, - :config => "#{Rails.root}/config.ru", - :detach => false, - :debugger => false -} +module Rails + class Server < ::Rack::Server + class Options + def parse!(args) + options = {} + args = args.dup + opt_parser = OptionParser.new do |opts| + opts.on("-p", "--port=port", Integer, + "Runs Rails on the specified port.", "Default: #{options[:Port]}") { |v| options[:Port] = v } + opts.on("-b", "--binding=ip", String, + "Binds Rails to the specified ip.", "Default: #{options[:Host]}") { |v| options[:Host] = v } + opts.on("-c", "--config=file", String, + "Use custom rackup configuration file") { |v| options[:config] = v } + opts.on("-d", "--daemon", "Make server run as a Daemon.") { options[:daemonize] = true } + opts.on("-u", "--debugger", "Enable ruby-debugging for the server.") { options[:debugger] = true } + opts.on("-e", "--environment=name", String, + "Specifies the environment to run this server under (test/development/production).", + "Default: #{options[:environment]}") { |v| options[:environment] = v } -ARGV.clone.options do |opts| - opts.on("-p", "--port=port", Integer, - "Runs Rails on the specified port.", "Default: #{options[:Port]}") { |v| options[:Port] = v } - opts.on("-b", "--binding=ip", String, - "Binds Rails to the specified ip.", "Default: #{options[:Host]}") { |v| options[:Host] = v } - opts.on("-c", "--config=file", String, - "Use custom rackup configuration file") { |v| options[:config] = v } - opts.on("-d", "--daemon", "Make server run as a Daemon.") { options[:detach] = true } - opts.on("-u", "--debugger", "Enable ruby-debugging for the server.") { options[:debugger] = true } - opts.on("-e", "--environment=name", String, - "Specifies the environment to run this server under (test/development/production).", - "Default: #{options[:environment]}") { |v| options[:environment] = v } + opts.separator "" - opts.separator "" + opts.on("-h", "--help", "Show this help message.") { puts opts; exit } + end - opts.on("-h", "--help", "Show this help message.") { puts opts; exit } + opt_parser.parse! args - opts.parse! -end + options[:server] = args.shift + options + end + end -server = Rack::Handler.get(ARGV.first) rescue nil -unless server - begin - server = Rack::Handler::Mongrel - rescue LoadError => e - server = Rack::Handler::WEBrick - end -end + def opt_parser + Options.new + end -puts "=> Booting #{ActiveSupport::Inflector.demodulize(server)}" -puts "=> Rails #{Rails.version} application starting on http://#{options[:Host]}:#{options[:Port]}" + def start + puts "=> Booting #{ActiveSupport::Inflector.demodulize(server)}" + puts "=> Rails #{Rails.version} application starting on http://#{options[:Host]}:#{options[:Port]}" + puts "=> Call with -d to detach" unless options[:daemonize] + trap(:INT) { exit } + puts "=> Ctrl-C to shutdown server" unless options[:daemonize] -if options[:detach] - Process.daemon - pid = "#{Rails.root}/tmp/pids/server.pid" - File.open(pid, 'w'){ |f| f.write(Process.pid) } - at_exit { File.delete(pid) if File.exist?(pid) } -end - -ENV["RAILS_ENV"] = options[:environment] -RAILS_ENV.replace(options[:environment]) if defined?(RAILS_ENV) - -app = Rack::Builder.new { - use Rails::Rack::LogTailer unless options[:detach] - use Rails::Rack::Debugger if options[:debugger] - run ActionDispatch::Utils.parse_config(options[:config]) -}.to_app + ENV["RAILS_ENV"] = options[:environment] + RAILS_ENV.replace(options[:environment]) if defined?(RAILS_ENV) -puts "=> Call with -d to detach" + super + ensure + puts 'Exiting' unless options[:daemonize] + end -trap(:INT) { exit } + def middleware + middlewares = [] + middlewares << [Rails::Rack::LogTailer] unless options[:daemonize] + middlewares << [Rails::Rack::Debugger] if options[:debugger] + Hash.new(middlewares) + end -puts "=> Ctrl-C to shutdown server" - -begin - server.run(app, options.merge(:AccessLog => [])) -ensure - puts 'Exiting' + def default_options + { + :Port => 3000, + :Host => "0.0.0.0", + :environment => (ENV['RAILS_ENV'] || "development").dup, + :rack_file => "#{Rails.root}/config.ru", + :daemonize => false, + :debugger => false, + :pid => "#{Rails.root}/tmp/pids/server.pid", + :AccessLog => [] + } + end + end end diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb index 102a0836dc..3f43a48e2e 100644 --- a/railties/lib/rails/configuration.rb +++ b/railties/lib/rails/configuration.rb @@ -31,7 +31,7 @@ module Rails def root @root ||= begin call_stack = caller.map { |p| p.split(':').first } - root_path = call_stack.detect { |p| p !~ %r[railties/lib/rails] } + root_path = call_stack.detect { |p| p !~ %r[railties/lib/rails|rack/lib/rack] } root_path = File.dirname(root_path) while root_path && File.directory?(root_path) && !File.exist?("#{root_path}/config.ru") diff --git a/railties/lib/rails/generators/rails/app/templates/script/console b/railties/lib/rails/generators/rails/app/templates/script/console index 20aa799d2f..6043f3792b 100755 --- a/railties/lib/rails/generators/rails/app/templates/script/console +++ b/railties/lib/rails/generators/rails/app/templates/script/console @@ -1,2 +1,3 @@ require File.expand_path('../../config/application', __FILE__) require 'rails/commands/console' +Rails::Console.start diff --git a/railties/lib/rails/generators/rails/app/templates/script/server b/railties/lib/rails/generators/rails/app/templates/script/server index a7aaee2953..709ca002df 100755 --- a/railties/lib/rails/generators/rails/app/templates/script/server +++ b/railties/lib/rails/generators/rails/app/templates/script/server @@ -1,2 +1,3 @@ require File.expand_path('../../config/application', __FILE__) require 'rails/commands/server' +Rails::Server.start diff --git a/railties/test/application/notifications_test.rb b/railties/test/application/notifications_test.rb index 62ed4f4ad4..28dfdfcd83 100644 --- a/railties/test/application/notifications_test.rb +++ b/railties/test/application/notifications_test.rb @@ -10,13 +10,15 @@ module ApplicationTests def initialize @events = [] @subscribers = [] + @listeners = [] end def publish(name, *args) @events << name end - def subscribe(pattern=nil, &block) + def subscribe(listener, pattern=nil, &block) + @listeners << listener @subscribers << pattern end end diff --git a/railties/test/rails_info_controller_test.rb b/railties/test/rails_info_controller_test.rb index a0484c0868..39f23fa0be 100644 --- a/railties/test/rails_info_controller_test.rb +++ b/railties/test/rails_info_controller_test.rb @@ -14,17 +14,12 @@ class InfoControllerTest < ActionController::TestCase tests Rails::InfoController def setup - ActionController::Routing.use_controllers!(['rails/info']) ActionController::Routing::Routes.draw do |map| map.connect ':controller/:action/:id' end @controller.stubs(:consider_all_requests_local => false, :local_request? => true) end - def teardown - ActionController::Routing.use_controllers! nil - end - test "info controller does not allow remote requests" do @controller.stubs(:consider_all_requests_local => false, :local_request? => false) get :properties |