Merge branch 'master' into orchestra

This commit is contained in:
Jeremy Kemper 2009-10-15 17:36:54 -07:00
commit 71f7e75d95
42 changed files with 137 additions and 90 deletions

View File

@ -20,7 +20,7 @@ ActiveSupport::Deprecation.debug = true
ActionView::Template.register_template_handler :haml, lambda { |template| "Look its HAML!".inspect } ActionView::Template.register_template_handler :haml, lambda { |template| "Look its HAML!".inspect }
ActionView::Template.register_template_handler :bak, lambda { |template| "Lame backup".inspect } ActionView::Template.register_template_handler :bak, lambda { |template| "Lame backup".inspect }
ActionView::Base.config = { :assets_dir => '/nowhere' } ActionView::Base::DEFAULT_CONFIG = { :assets_dir => '/nowhere' }
$:.unshift "#{File.dirname(__FILE__)}/fixtures/helpers" $:.unshift "#{File.dirname(__FILE__)}/fixtures/helpers"

View File

@ -2,7 +2,7 @@ rails_root = Pathname.new(File.dirname(__FILE__)).join("..")
Gem.sources.each { |uri| source uri } Gem.sources.each { |uri| source uri }
gem "rack", "~> 1.0.0" gem "rack", "1.0.1", :git => "git://github.com/rack/rack.git", :branch => "rack-1.0"
gem "rack-test", "~> 0.5.0" gem "rack-test", "~> 0.5.0"
gem "activesupport", "3.0.pre", :vendored_at => rails_root.join("activesupport") gem "activesupport", "3.0.pre", :vendored_at => rails_root.join("activesupport")
gem "activemodel", "3.0.pre", :vendored_at => rails_root.join("activemodel") gem "activemodel", "3.0.pre", :vendored_at => rails_root.join("activemodel")

View File

@ -167,7 +167,16 @@ module ActionView #:nodoc:
module Subclasses module Subclasses
end end
include Helpers, Rendering, Partials, ::ERB::Util, ActiveSupport::Configurable include Helpers, Rendering, Partials, ::ERB::Util
def config
self.config = DEFAULT_CONFIG unless @config
@config
end
def config=(config)
@config = ActiveSupport::OrderedOptions.new.merge(config)
end
extend ActiveSupport::Memoizable extend ActiveSupport::Memoizable

View File

@ -176,8 +176,8 @@ class ::ApplicationController < ActionController::Base
end end
module ActionController module ActionController
class << Routing module Routing
def possible_controllers def self.possible_controllers
@@possible_controllers ||= [] @@possible_controllers ||= []
end end
end end

View File

@ -5,7 +5,7 @@ module ContentNegotiation
# This has no layout and it works # This has no layout and it works
class BasicController < ActionController::Base class BasicController < ActionController::Base
self.view_paths = [ActionView::FixtureResolver.new( self.view_paths = [ActionView::FixtureResolver.new(
"content_negotiation/basic/hello.html.erb" => "Hello world <%= request.formats %>!" "content_negotiation/basic/hello.html.erb" => "Hello world <%= request.formats.first.to_s %>!"
)] )]
end end

View File

@ -20,8 +20,8 @@ module MetalTest
class TestMiddleware < ActiveSupport::TestCase class TestMiddleware < ActiveSupport::TestCase
def setup def setup
@app = Rack::Builder.new do @app = Rack::Builder.new do
use MetalMiddleware use MetalTest::MetalMiddleware
run Endpoint.new run MetalTest::Endpoint.new
end.to_app end.to_app
end end

View File

@ -327,7 +327,7 @@ class RescueTest < ActionController::IntegrationTest
test 'rescue routing exceptions' do test 'rescue routing exceptions' do
@app = ActionDispatch::Rescue.new(ActionController::Routing::Routes) do @app = ActionDispatch::Rescue.new(ActionController::Routing::Routes) do
rescue_from ActionController::RoutingError, lambda { |env| [200, {"Content-Type" => "text/html"}, "Gotcha!"] } rescue_from ActionController::RoutingError, lambda { |env| [200, {"Content-Type" => "text/html"}, ["Gotcha!"]] }
end end
get '/b00m' get '/b00m'

View File

@ -18,7 +18,7 @@ class TestRequestTest < ActiveSupport::TestCase
assert_equal "0.0.0.0", env.delete("REMOTE_ADDR") assert_equal "0.0.0.0", env.delete("REMOTE_ADDR")
assert_equal "Rails Testing", env.delete("HTTP_USER_AGENT") assert_equal "Rails Testing", env.delete("HTTP_USER_AGENT")
assert_equal [0, 1], env.delete("rack.version") assert_equal [1, 0], env.delete("rack.version")
assert_equal "", env.delete("rack.input").string assert_equal "", env.delete("rack.input").string
assert_kind_of StringIO, env.delete("rack.errors") assert_kind_of StringIO, env.delete("rack.errors")
assert_equal true, env.delete("rack.multithread") assert_equal true, env.delete("rack.multithread")

View File

@ -1,3 +1,4 @@
require "#{RAILS_ROOT}/config/environment" require "#{RAILS_ROOT}/config/application"
Rails.application.new
require 'rails/info' require 'rails/info'
puts Rails::Info puts Rails::Info

View File

@ -1,5 +1,5 @@
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'generators')) require File.expand_path(File.join(File.dirname(__FILE__), '..', 'generators'))
require "#{RAILS_ROOT}/config/environment" require "#{RAILS_ROOT}/config/application"
if ARGV.size == 0 if ARGV.size == 0
Rails::Generators.help Rails::Generators.help

View File

@ -1,5 +1,5 @@
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'generators')) require File.expand_path(File.join(File.dirname(__FILE__), '..', 'generators'))
require "#{RAILS_ROOT}/config/environment" Rails.application.new
if ARGV.size == 0 if ARGV.size == 0
Rails::Generators.help Rails::Generators.help

View File

@ -10,9 +10,9 @@ rescue ArgumentError
N = 1 N = 1
end end
require RAILS_ROOT + '/config/environment'
require 'benchmark' require 'benchmark'
include Benchmark include Benchmark
Rails.application.new
# Don't include compilation in the benchmark # Don't include compilation in the benchmark
ARGV.each { |expression| eval(expression) } ARGV.each { |expression| eval(expression) }

View File

@ -5,7 +5,7 @@ end
# Keep the expensive require out of the profile. # Keep the expensive require out of the profile.
$stderr.puts 'Loading Rails...' $stderr.puts 'Loading Rails...'
require RAILS_ROOT + '/config/environment' Rails.application.new # Initialize the application
# Define a method to profile. # Define a method to profile.
if ARGV[1] and ARGV[1].to_i > 1 if ARGV[1] and ARGV[1].to_i > 1

View File

@ -36,7 +36,7 @@ ARGV.delete(code_or_file)
ENV["RAILS_ENV"] = options[:environment] ENV["RAILS_ENV"] = options[:environment]
RAILS_ENV.replace(options[:environment]) if defined?(RAILS_ENV) RAILS_ENV.replace(options[:environment]) if defined?(RAILS_ENV)
require RAILS_ROOT + '/config/environment' Rails.application.new
begin begin
if code_or_file.nil? if code_or_file.nil?

View File

@ -1,5 +1,4 @@
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'generators')) require File.expand_path(File.join(File.dirname(__FILE__), '..', 'generators'))
require "#{RAILS_ROOT}/config/environment"
if ARGV.size == 0 if ARGV.size == 0
Rails::Generators.help Rails::Generators.help

View File

@ -71,7 +71,7 @@ module Rails
in_root do in_root do
if options[:env].nil? if options[:env].nil?
inject_into_file 'config/environment.rb', "\n #{data}", :after => sentinel, :verbose => false inject_into_file 'config/application.rb', "\n #{data}", :after => sentinel, :verbose => false
else else
Array.wrap(options[:env]).each do|env| Array.wrap(options[:env]).each do|env|
append_file "config/environments/#{env}.rb", "\n#{data}", :verbose => false append_file "config/environments/#{env}.rb", "\n#{data}", :verbose => false

View File

@ -66,6 +66,7 @@ module Rails::Generators
inside "config" do inside "config" do
copy_file "routes.rb" copy_file "routes.rb"
template "application.rb"
template "environment.rb" template "environment.rb"
directory "environments" directory "environments"

View File

@ -1,7 +1,7 @@
# Add your own tasks in files placed in lib/tasks ending in .rake, # Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require(File.join(File.dirname(__FILE__), 'config', 'boot')) require File.expand_path(File.join(File.dirname(__FILE__), 'config', 'environment'))
require 'rake' require 'rake'
require 'rake/testtask' require 'rake/testtask'

View File

@ -1,5 +1,5 @@
# Require your environment file to bootstrap Rails # Require your environment file to bootstrap Rails
require ::File.dirname(__FILE__) + '/config/environment' require File.expand_path('../config/application', __FILE__)
# Dispatch the request # Dispatch the request
run Rails.application.new run Rails.application.new

View File

@ -0,0 +1,48 @@
# Bootstrap the Rails environment, frameworks, and default configuration
require File.expand_path(File.join(File.dirname(__FILE__), 'boot'))
Rails::Initializer.run do |config|
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Add additional load paths for your own custom dirs
# config.load_paths += %W( #{RAILS_ROOT}/extras )
# Specify gems that this application depends on and have them installed with rake gems:install
# config.gem "bj"
# config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
# config.gem "sqlite3-ruby", :lib => "sqlite3"
# config.gem "aws-s3", :lib => "aws/s3"
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# Skip frameworks you're not going to use. To use Rails without a database,
# you must remove the Active Record framework.
<% if options[:skip_activerecord] -%>
config.frameworks -= [ :active_record ]
<% else -%>
# config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
# Activate observers that should always be running
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
<% end -%>
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names.
config.time_zone = 'UTC'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
# config.i18n.default_locale = :de
# Configure generators values. Many other options are available, be sure to
# check the documentation.
# config.generators do |g|
# g.orm :active_record
# g.template_engine :erb
# g.test_framework :test_unit, :fixture => true
# end
end

View File

@ -3,51 +3,7 @@
# Specifies gem version of Rails to use when vendor/rails is not present # Specifies gem version of Rails to use when vendor/rails is not present
<%= '# ' if options[:freeze] %>RAILS_GEM_VERSION = '<%= Rails::VERSION::STRING %>' unless defined? RAILS_GEM_VERSION <%= '# ' if options[:freeze] %>RAILS_GEM_VERSION = '<%= Rails::VERSION::STRING %>' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration # Load the rails application
require File.join(File.dirname(__FILE__), 'boot') require File.expand_path(File.join(File.dirname(__FILE__), 'application'))
# Initialize the rails application
Rails::Initializer.run do |config| Rails.application.new
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Add additional load paths for your own custom dirs
# config.load_paths += %W( #{RAILS_ROOT}/extras )
# Specify gems that this application depends on and have them installed with rake gems:install
# config.gem "bj"
# config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
# config.gem "sqlite3-ruby", :lib => "sqlite3"
# config.gem "aws-s3", :lib => "aws/s3"
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# Skip frameworks you're not going to use. To use Rails without a database,
# you must remove the Active Record framework.
<% if options[:skip_activerecord] -%>
config.frameworks -= [ :active_record ]
<% else -%>
# config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
# Activate observers that should always be running
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
<% end -%>
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names.
config.time_zone = 'UTC'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
# config.i18n.default_locale = :de
# Configure generators values. Many other options are available, be sure to
# check the documentation.
# config.generators do |g|
# g.orm :active_record
# g.template_engine :erb
# g.test_framework :test_unit, :fixture => true
# end
end

View File

@ -1,4 +1,4 @@
<%= shebang %> <%= shebang %>
require File.expand_path('../../config/boot', __FILE__) require File.expand_path('../../config/application', __FILE__)
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'rails/commands/about' require 'rails/commands/about'

View File

@ -1,3 +1,3 @@
<%= shebang %> <%= shebang %>
require File.expand_path('../../config/boot', __FILE__) require File.expand_path('../../config/application', __FILE__)
require 'rails/commands/console' require 'rails/commands/console'

View File

@ -1,3 +1,3 @@
<%= shebang %> <%= shebang %>
require File.expand_path('../../config/boot', __FILE__) require File.expand_path('../../config/application', __FILE__)
require 'rails/commands/dbconsole' require 'rails/commands/dbconsole'

View File

@ -1,3 +1,3 @@
<%= shebang %> <%= shebang %>
require File.expand_path('../../config/boot', __FILE__) require File.expand_path('../../config/application', __FILE__)
require 'rails/commands/destroy' require 'rails/commands/destroy'

View File

@ -1,3 +1,3 @@
<%= shebang %> <%= shebang %>
require File.expand_path('../../config/boot', __FILE__) require File.expand_path('../../config/application', __FILE__)
require 'rails/commands/generate' require 'rails/commands/generate'

View File

@ -1,3 +1,3 @@
<%= shebang %> <%= shebang %>
require File.expand_path('../../../config/boot', __FILE__) require File.expand_path('../../../config/application', __FILE__)
require 'rails/commands/performance/benchmarker' require 'rails/commands/performance/benchmarker'

View File

@ -1,3 +1,3 @@
<%= shebang %> <%= shebang %>
require File.expand_path('../../../config/boot', __FILE__) require File.expand_path('../../../config/application', __FILE__)
require 'rails/commands/performance/profiler' require 'rails/commands/performance/profiler'

View File

@ -1,3 +1,3 @@
<%= shebang %> <%= shebang %>
require File.expand_path('../../config/boot', __FILE__) require File.expand_path('../../config/application', __FILE__)
require 'rails/commands/plugin' require 'rails/commands/plugin'

View File

@ -1,3 +1,3 @@
<%= shebang %> <%= shebang %>
require File.expand_path('../../config/boot', __FILE__) require File.expand_path('../../config/application', __FILE__)
require 'rails/commands/runner' require 'rails/commands/runner'

View File

@ -1,3 +1,3 @@
<%= shebang %> <%= shebang %>
require File.expand_path('../../config/boot', __FILE__) require File.expand_path('../../config/application', __FILE__)
require 'rails/commands/server' require 'rails/commands/server'

View File

@ -21,7 +21,6 @@ module Rails
else else
Rails.application = Class.new(Application) Rails.application = Class.new(Application)
yield Rails.application.config if block_given? yield Rails.application.config if block_given?
Rails.application.new
end end
end end
end end

View File

@ -16,6 +16,7 @@ require 'stringio'
require 'test/unit' require 'test/unit'
require 'active_support' require 'active_support'
require 'active_support/core_ext/logger'
require 'active_support/test_case' require 'active_support/test_case'
require 'action_controller' require 'action_controller'

View File

@ -41,6 +41,8 @@ module ApplicationTests
c.generators.orm :datamapper c.generators.orm :datamapper
c.generators.test_framework :rspec c.generators.test_framework :rspec
end end
# Initialize the application
Rails.application.new
assert_equal :rspec, Rails::Generators.options[:rails][:test_framework] assert_equal :rspec, Rails::Generators.options[:rails][:test_framework]
assert_equal "-w", Rails::Generators.aliases[:rails][:test_framework] assert_equal "-w", Rails::Generators.aliases[:rails][:test_framework]
@ -50,6 +52,8 @@ module ApplicationTests
Rails::Initializer.run do |c| Rails::Initializer.run do |c|
c.generators.colorize_logging = false c.generators.colorize_logging = false
end end
# Initialize the application
Rails.application.new
assert_equal Thor::Base.shell, Thor::Shell::Basic assert_equal Thor::Base.shell, Thor::Shell::Basic
end end

View File

@ -52,6 +52,8 @@ module ApplicationTests
config.eager_load_paths = "#{app_path}/lib" config.eager_load_paths = "#{app_path}/lib"
end end
Rails.application.new
assert Zoo assert Zoo
end end
@ -59,6 +61,7 @@ module ApplicationTests
app_file "config/environments/development.rb", "$initialize_test_set_from_env = 'success'" app_file "config/environments/development.rb", "$initialize_test_set_from_env = 'success'"
assert_nil $initialize_test_set_from_env assert_nil $initialize_test_set_from_env
Rails::Initializer.run { } Rails::Initializer.run { }
Rails.application.new
assert_equal "success", $initialize_test_set_from_env assert_equal "success", $initialize_test_set_from_env
end end
@ -67,6 +70,7 @@ module ApplicationTests
Rails::Initializer.run do |config| Rails::Initializer.run do |config|
config.frameworks = [] config.frameworks = []
end end
Rails.application.new
end end
end end
@ -74,6 +78,7 @@ module ApplicationTests
Rails::Initializer.run do |config| Rails::Initializer.run do |config|
config.frameworks = [:action_controller] config.frameworks = [:action_controller]
end end
Rails.application.new
assert $:.include?("#{framework_path}/actionpack/lib") assert $:.include?("#{framework_path}/actionpack/lib")
end end
@ -82,6 +87,7 @@ module ApplicationTests
Rails::Initializer.run do |config| Rails::Initializer.run do |config|
config.frameworks = [:action_view] config.frameworks = [:action_view]
end end
Rails.application.new
assert $:.include?("#{framework_path}/actionpack/lib") assert $:.include?("#{framework_path}/actionpack/lib")
end end
@ -91,6 +97,7 @@ module ApplicationTests
config.after_initialize { $test_after_initialize_block1 = "success" } config.after_initialize { $test_after_initialize_block1 = "success" }
config.after_initialize { $test_after_initialize_block2 = "congratulations" } config.after_initialize { $test_after_initialize_block2 = "congratulations" }
end end
Rails.application.new
assert_equal "success", $test_after_initialize_block1 assert_equal "success", $test_after_initialize_block1
assert_equal "congratulations", $test_after_initialize_block2 assert_equal "congratulations", $test_after_initialize_block2
@ -102,6 +109,7 @@ module ApplicationTests
config.after_initialize # don't pass a block, this is what we're testing! config.after_initialize # don't pass a block, this is what we're testing!
config.after_initialize { $test_after_initialize_block2 = "congratulations" } config.after_initialize { $test_after_initialize_block2 = "congratulations" }
end end
Rails.application.new
assert_equal "success", $test_after_initialize_block1 assert_equal "success", $test_after_initialize_block1
assert_equal "congratulations", $test_after_initialize_block2 assert_equal "congratulations", $test_after_initialize_block2
@ -112,6 +120,8 @@ module ApplicationTests
Rails::Initializer.run do |config| Rails::Initializer.run do |config|
config.i18n.default_locale = :de config.i18n.default_locale = :de
end end
Rails.application.new
assert_equal :de, I18n.default_locale assert_equal :de, I18n.default_locale
end end
@ -143,6 +153,7 @@ module ApplicationTests
Rails::Initializer.run do |config| Rails::Initializer.run do |config|
config.action_controller.session_store = :cookie_store config.action_controller.session_store = :cookie_store
end end
Rails.application.new
assert !Rails.application.config.middleware.include?(ActiveRecord::SessionStore) assert !Rails.application.config.middleware.include?(ActiveRecord::SessionStore)
end end
@ -158,6 +169,7 @@ module ApplicationTests
Rails::Initializer.run do |c| Rails::Initializer.run do |c|
c.action_controller.session_store = :active_record_store c.action_controller.session_store = :active_record_store
end end
Rails.application.new
expects = [ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActiveRecord::SessionStore] expects = [ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActiveRecord::SessionStore]
middleware = Rails.application.config.middleware.map { |m| m.klass } middleware = Rails.application.config.middleware.map { |m| m.klass }
@ -169,6 +181,7 @@ module ApplicationTests
c.frameworks -= [:action_controller] c.frameworks -= [:action_controller]
c.action_controller.session_store = :active_record_store c.action_controller.session_store = :active_record_store
end end
Rails.application.new
assert !Rails.application.config.middleware.include?(ActiveRecord::SessionStore) assert !Rails.application.config.middleware.include?(ActiveRecord::SessionStore)
end end
@ -178,6 +191,8 @@ module ApplicationTests
Rails::Initializer.run do |c| Rails::Initializer.run do |c|
c.frameworks -= [:action_view] c.frameworks -= [:action_view]
end end
Rails.application.new
assert_equal nil, ActionMailer::Base.template_root assert_equal nil, ActionMailer::Base.template_root
assert_equal [], ActionController::Base.view_paths assert_equal [], ActionController::Base.view_paths
end end

View File

@ -18,6 +18,7 @@ module ApplicationTests
test "all plugins are loaded when registered plugin list is untouched" do test "all plugins are loaded when registered plugin list is untouched" do
Rails::Initializer.run { } Rails::Initializer.run { }
Rails.application.new
assert_plugins [ assert_plugins [
:a, :acts_as_chunky_bacon, :engine, :gemlike, :plugin_with_no_lib_dir, :stubby :a, :acts_as_chunky_bacon, :engine, :gemlike, :plugin_with_no_lib_dir, :stubby
], Rails.application.config.loaded_plugins, @failure_tip ], Rails.application.config.loaded_plugins, @failure_tip
@ -31,6 +32,7 @@ module ApplicationTests
test "only the specified plugins are located in the order listed" do test "only the specified plugins are located in the order listed" do
plugin_names = [:plugin_with_no_lib_dir, :acts_as_chunky_bacon] plugin_names = [:plugin_with_no_lib_dir, :acts_as_chunky_bacon]
Rails::Initializer.run { |c| c.plugins = plugin_names } Rails::Initializer.run { |c| c.plugins = plugin_names }
Rails.application.new
assert_plugins plugin_names, Rails.application.config.loaded_plugins assert_plugins plugin_names, Rails.application.config.loaded_plugins
end end
@ -38,6 +40,7 @@ module ApplicationTests
Rails::Initializer.run do |config| Rails::Initializer.run do |config|
config.plugins = [:stubby, :all, :acts_as_chunky_bacon] config.plugins = [:stubby, :all, :acts_as_chunky_bacon]
end end
Rails.application.new
assert_plugins [:stubby, :a, :engine, :gemlike, :plugin_with_no_lib_dir, :acts_as_chunky_bacon], Rails.application.config.loaded_plugins, @failure_tip assert_plugins [:stubby, :a, :engine, :gemlike, :plugin_with_no_lib_dir, :acts_as_chunky_bacon], Rails.application.config.loaded_plugins, @failure_tip
end end
@ -46,6 +49,7 @@ module ApplicationTests
Rails::Initializer.run do |config| Rails::Initializer.run do |config|
config.plugins = ['stubby', 'acts_as_chunky_bacon', :a, :plugin_with_no_lib_dir] config.plugins = ['stubby', 'acts_as_chunky_bacon', :a, :plugin_with_no_lib_dir]
end end
Rails.application.new
assert_plugins plugin_names, Rails.application.config.loaded_plugins, @failure_tip assert_plugins plugin_names, Rails.application.config.loaded_plugins, @failure_tip
end end
@ -54,6 +58,7 @@ module ApplicationTests
Rails::Initializer.run do |config| Rails::Initializer.run do |config|
config.plugins = [:stubby, :acts_as_chunky_bacon, :all] config.plugins = [:stubby, :acts_as_chunky_bacon, :all]
end end
Rails.application.new
assert_plugins [:stubby, :acts_as_chunky_bacon, :a, :engine, :gemlike, :plugin_with_no_lib_dir], Rails.application.config.loaded_plugins, @failure_tip assert_plugins [:stubby, :acts_as_chunky_bacon, :a, :engine, :gemlike, :plugin_with_no_lib_dir], Rails.application.config.loaded_plugins, @failure_tip
end end
@ -62,16 +67,19 @@ module ApplicationTests
Rails::Initializer.run do |config| Rails::Initializer.run do |config|
config.plugins = [:stubby, :acts_as_chunky_bacon] config.plugins = [:stubby, :acts_as_chunky_bacon]
end end
Rails.application.new
assert $LOAD_PATH.include?("#{app_path}/vendor/plugins/default/stubby/lib") assert $LOAD_PATH.include?("#{app_path}/vendor/plugins/default/stubby/lib")
assert $LOAD_PATH.include?("#{app_path}/vendor/plugins/default/acts/acts_as_chunky_bacon/lib") assert $LOAD_PATH.include?("#{app_path}/vendor/plugins/default/acts/acts_as_chunky_bacon/lib")
end end
test "registering a plugin name that does not exist raises a load error" do test "registering a plugin name that does not exist raises a load error" do
Rails::Initializer.run do |config|
config.plugins = [:stubby, :acts_as_a_non_existant_plugin]
end
assert_raise(LoadError) do assert_raise(LoadError) do
Rails::Initializer.run do |config| Rails.application.new
config.plugins = [:stubby, :acts_as_a_non_existant_plugin]
end
end end
end end
@ -83,6 +91,7 @@ module ApplicationTests
Rails::Initializer.run do |config| Rails::Initializer.run do |config|
config.plugins = [:stubby, :acts_as_chunky_bacon, :non_existant_plugin1, :non_existant_plugin2] config.plugins = [:stubby, :acts_as_chunky_bacon, :non_existant_plugin1, :non_existant_plugin2]
end end
Rails.application.new
flunk "Expected a LoadError but did not get one" flunk "Expected a LoadError but did not get one"
rescue LoadError => e rescue LoadError => e
assert_plugins valid_plugins, Rails.application.config.loaded_plugins, @failure_tip assert_plugins valid_plugins, Rails.application.config.loaded_plugins, @failure_tip

View File

@ -57,7 +57,7 @@ class ActionsTest < GeneratorsTestCase
def test_gem_should_put_gem_dependency_in_enviroment def test_gem_should_put_gem_dependency_in_enviroment
run_generator run_generator
action :gem, 'will-paginate' action :gem, 'will-paginate'
assert_file 'config/environment.rb', /config\.gem 'will\-paginate'/ assert_file 'config/application.rb', /config\.gem 'will\-paginate'/
end end
def test_gem_with_options_should_include_options_in_gem_dependency_in_environment def test_gem_with_options_should_include_options_in_gem_dependency_in_environment
@ -65,7 +65,7 @@ class ActionsTest < GeneratorsTestCase
action :gem, 'mislav-will-paginate', :lib => 'will-paginate', :source => 'http://gems.github.com' action :gem, 'mislav-will-paginate', :lib => 'will-paginate', :source => 'http://gems.github.com'
regexp = /#{Regexp.escape("config.gem 'mislav-will-paginate', :lib => 'will-paginate', :source => 'http://gems.github.com'")}/ regexp = /#{Regexp.escape("config.gem 'mislav-will-paginate', :lib => 'will-paginate', :source => 'http://gems.github.com'")}/
assert_file 'config/environment.rb', regexp assert_file 'config/application.rb', regexp
end end
def test_gem_with_env_string_should_put_gem_dependency_in_specified_environment def test_gem_with_env_string_should_put_gem_dependency_in_specified_environment
@ -84,14 +84,14 @@ class ActionsTest < GeneratorsTestCase
def test_gem_with_lib_option_set_to_false_should_put_gem_dependency_in_enviroment_correctly def test_gem_with_lib_option_set_to_false_should_put_gem_dependency_in_enviroment_correctly
run_generator run_generator
action :gem, 'mislav-will-paginate', :lib => false action :gem, 'mislav-will-paginate', :lib => false
assert_file 'config/environment.rb', /config\.gem 'mislav\-will\-paginate'\, :lib => false/ assert_file 'config/application.rb', /config\.gem 'mislav\-will\-paginate'\, :lib => false/
end end
def test_environment_should_include_data_in_environment_initializer_block def test_environment_should_include_data_in_environment_initializer_block
run_generator run_generator
load_paths = 'config.load_paths += %w["#{RAILS_ROOT}/app/extras"]' load_paths = 'config.load_paths += %w["#{RAILS_ROOT}/app/extras"]'
action :environment, load_paths action :environment, load_paths
assert_file 'config/environment.rb', /#{Regexp.escape(load_paths)}/ assert_file 'config/application.rb', /#{Regexp.escape(load_paths)}/
end end
def test_environment_with_block_should_include_block_contents_in_environment_initializer_block def test_environment_with_block_should_include_block_contents_in_environment_initializer_block
@ -102,7 +102,7 @@ class ActionsTest < GeneratorsTestCase
'# This will be added' '# This will be added'
end end
assert_file 'config/environment.rb' do |content| assert_file 'config/application.rb' do |content|
assert_match /# This will be added/, content assert_match /# This will be added/, content
assert_no_match /# This wont be added/, content assert_no_match /# This wont be added/, content
end end

View File

@ -65,7 +65,7 @@ class AppGeneratorTest < GeneratorsTestCase
def test_activerecord_is_removed_from_frameworks_if_skip_activerecord_is_given def test_activerecord_is_removed_from_frameworks_if_skip_activerecord_is_given
run_generator ["--skip-activerecord"] run_generator ["--skip-activerecord"]
assert_file "config/environment.rb", /config\.frameworks \-= \[ :active_record \]/ assert_file "config/application.rb", /config\.frameworks \-= \[ :active_record \]/
end end
def test_prototype_and_test_unit_are_added_by_default def test_prototype_and_test_unit_are_added_by_default

View File

@ -42,6 +42,7 @@ module InitializerTests
set_ruby_version(version) set_ruby_version(version)
assert_nothing_raised "It appears that rails does not boot" do assert_nothing_raised "It appears that rails does not boot" do
Rails::Initializer.run { |c| c.frameworks = [] } Rails::Initializer.run { |c| c.frameworks = [] }
Rails.application.new
end end
end end
@ -50,6 +51,7 @@ module InitializerTests
$stderr = File.open("/dev/null", "w") $stderr = File.open("/dev/null", "w")
assert_raises(SystemExit) do assert_raises(SystemExit) do
Rails::Initializer.run { |c| c.frameworks = [] } Rails::Initializer.run { |c| c.frameworks = [] }
Rails.application.new
end end
end end
end end

View File

@ -14,6 +14,7 @@ module InitializerTests
Rails::Initializer.run do |c| Rails::Initializer.run do |c|
c.i18n.load_path << "my/other/locale.yml" c.i18n.load_path << "my/other/locale.yml"
end end
Rails.application.new
#{RAILS_FRAMEWORK_ROOT}/railties/test/fixtures/plugins/engines/engine/config/locales/en.yml #{RAILS_FRAMEWORK_ROOT}/railties/test/fixtures/plugins/engines/engine/config/locales/en.yml
assert_equal %W( assert_equal %W(
@ -35,6 +36,7 @@ module InitializerTests
Rails::Initializer.run do |c| Rails::Initializer.run do |c|
c.i18n.load_path << "my/other/locale.yml" c.i18n.load_path << "my/other/locale.yml"
end end
Rails.application.new
#{RAILS_FRAMEWORK_ROOT}/railties/test/fixtures/plugins/engines/engine/config/locales/en.yml #{RAILS_FRAMEWORK_ROOT}/railties/test/fixtures/plugins/engines/engine/config/locales/en.yml
assert_equal %W( assert_equal %W(

View File

@ -12,6 +12,7 @@ class PathsTest < Test::Unit::TestCase
ActionController::Base.session_store = nil ActionController::Base.session_store = nil
end end
end end
Rails.application.new
@paths = Rails.application.config.paths @paths = Rails.application.config.paths
end end

View File

@ -94,9 +94,9 @@ module TestHelpers
end end
def add_to_config(str) def add_to_config(str)
environment = File.read("#{app_path}/config/environment.rb") environment = File.read("#{app_path}/config/application.rb")
if environment =~ /(\n\s*end\s*)\Z/ if environment =~ /(\n\s*end\s*)\Z/
File.open("#{app_path}/config/environment.rb", 'w') do |f| File.open("#{app_path}/config/application.rb", 'w') do |f|
f.puts $` + "\n#{str}\n" + $1 f.puts $` + "\n#{str}\n" + $1
end end
end end