diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2009-10-15 17:36:54 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-10-15 17:36:54 -0700 |
commit | 71f7e75d95c47e4283a7cac0a2f776abf0a11d0e (patch) | |
tree | 75a9b6825f9f81a9bec372af8db097b6ea022fc6 /railties/test | |
parent | 2d7abe245e7a2b1717e48ef550e4083318fd7ec2 (diff) | |
parent | ef70ad5538c4ce02c4d31ef01a8db6b55c837571 (diff) | |
download | rails-71f7e75d95c47e4283a7cac0a2f776abf0a11d0e.tar.gz rails-71f7e75d95c47e4283a7cac0a2f776abf0a11d0e.tar.bz2 rails-71f7e75d95c47e4283a7cac0a2f776abf0a11d0e.zip |
Merge branch 'master' into orchestra
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/abstract_unit.rb | 1 | ||||
-rw-r--r-- | railties/test/application/generators_test.rb | 4 | ||||
-rw-r--r-- | railties/test/application/initializer_test.rb | 15 | ||||
-rw-r--r-- | railties/test/application/plugins_test.rb | 15 | ||||
-rw-r--r-- | railties/test/generators/actions_test.rb | 10 | ||||
-rw-r--r-- | railties/test/generators/app_generator_test.rb | 2 | ||||
-rw-r--r-- | railties/test/initializer/check_ruby_version_test.rb | 2 | ||||
-rw-r--r-- | railties/test/initializer/initialize_i18n_test.rb | 2 | ||||
-rw-r--r-- | railties/test/initializer/path_test.rb | 1 | ||||
-rw-r--r-- | railties/test/isolation/abstract_unit.rb | 4 |
10 files changed, 45 insertions, 11 deletions
diff --git a/railties/test/abstract_unit.rb b/railties/test/abstract_unit.rb index 6c6af0b2bf..551468b3e8 100644 --- a/railties/test/abstract_unit.rb +++ b/railties/test/abstract_unit.rb @@ -16,6 +16,7 @@ require 'stringio' require 'test/unit' require 'active_support' +require 'active_support/core_ext/logger' require 'active_support/test_case' require 'action_controller' diff --git a/railties/test/application/generators_test.rb b/railties/test/application/generators_test.rb index 0edb29483d..c664b61137 100644 --- a/railties/test/application/generators_test.rb +++ b/railties/test/application/generators_test.rb @@ -41,6 +41,8 @@ module ApplicationTests c.generators.orm :datamapper c.generators.test_framework :rspec end + # Initialize the application + Rails.application.new assert_equal :rspec, Rails::Generators.options[:rails][:test_framework] assert_equal "-w", Rails::Generators.aliases[:rails][:test_framework] @@ -50,6 +52,8 @@ module ApplicationTests Rails::Initializer.run do |c| c.generators.colorize_logging = false end + # Initialize the application + Rails.application.new assert_equal Thor::Base.shell, Thor::Shell::Basic end diff --git a/railties/test/application/initializer_test.rb b/railties/test/application/initializer_test.rb index f46bf2b656..76486d8f2c 100644 --- a/railties/test/application/initializer_test.rb +++ b/railties/test/application/initializer_test.rb @@ -52,6 +52,8 @@ module ApplicationTests config.eager_load_paths = "#{app_path}/lib" end + Rails.application.new + assert Zoo end @@ -59,6 +61,7 @@ module ApplicationTests app_file "config/environments/development.rb", "$initialize_test_set_from_env = 'success'" assert_nil $initialize_test_set_from_env Rails::Initializer.run { } + Rails.application.new assert_equal "success", $initialize_test_set_from_env end @@ -67,6 +70,7 @@ module ApplicationTests Rails::Initializer.run do |config| config.frameworks = [] end + Rails.application.new end end @@ -74,6 +78,7 @@ module ApplicationTests Rails::Initializer.run do |config| config.frameworks = [:action_controller] end + Rails.application.new assert $:.include?("#{framework_path}/actionpack/lib") end @@ -82,6 +87,7 @@ module ApplicationTests Rails::Initializer.run do |config| config.frameworks = [:action_view] end + Rails.application.new assert $:.include?("#{framework_path}/actionpack/lib") end @@ -91,6 +97,7 @@ module ApplicationTests config.after_initialize { $test_after_initialize_block1 = "success" } config.after_initialize { $test_after_initialize_block2 = "congratulations" } end + Rails.application.new assert_equal "success", $test_after_initialize_block1 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 { $test_after_initialize_block2 = "congratulations" } end + Rails.application.new assert_equal "success", $test_after_initialize_block1 assert_equal "congratulations", $test_after_initialize_block2 @@ -112,6 +120,8 @@ module ApplicationTests Rails::Initializer.run do |config| config.i18n.default_locale = :de end + Rails.application.new + assert_equal :de, I18n.default_locale end @@ -143,6 +153,7 @@ module ApplicationTests Rails::Initializer.run do |config| config.action_controller.session_store = :cookie_store end + Rails.application.new assert !Rails.application.config.middleware.include?(ActiveRecord::SessionStore) end @@ -158,6 +169,7 @@ module ApplicationTests Rails::Initializer.run do |c| c.action_controller.session_store = :active_record_store end + Rails.application.new expects = [ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActiveRecord::SessionStore] middleware = Rails.application.config.middleware.map { |m| m.klass } @@ -169,6 +181,7 @@ module ApplicationTests c.frameworks -= [:action_controller] c.action_controller.session_store = :active_record_store end + Rails.application.new assert !Rails.application.config.middleware.include?(ActiveRecord::SessionStore) end @@ -178,6 +191,8 @@ module ApplicationTests Rails::Initializer.run do |c| c.frameworks -= [:action_view] end + Rails.application.new + assert_equal nil, ActionMailer::Base.template_root assert_equal [], ActionController::Base.view_paths end diff --git a/railties/test/application/plugins_test.rb b/railties/test/application/plugins_test.rb index 81e7f4d88c..a4cf322139 100644 --- a/railties/test/application/plugins_test.rb +++ b/railties/test/application/plugins_test.rb @@ -18,6 +18,7 @@ module ApplicationTests test "all plugins are loaded when registered plugin list is untouched" do Rails::Initializer.run { } + Rails.application.new assert_plugins [ :a, :acts_as_chunky_bacon, :engine, :gemlike, :plugin_with_no_lib_dir, :stubby ], 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 plugin_names = [:plugin_with_no_lib_dir, :acts_as_chunky_bacon] Rails::Initializer.run { |c| c.plugins = plugin_names } + Rails.application.new assert_plugins plugin_names, Rails.application.config.loaded_plugins end @@ -38,6 +40,7 @@ module ApplicationTests Rails::Initializer.run do |config| config.plugins = [:stubby, :all, :acts_as_chunky_bacon] 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 end @@ -46,6 +49,7 @@ module ApplicationTests Rails::Initializer.run do |config| config.plugins = ['stubby', 'acts_as_chunky_bacon', :a, :plugin_with_no_lib_dir] end + Rails.application.new assert_plugins plugin_names, Rails.application.config.loaded_plugins, @failure_tip end @@ -54,6 +58,7 @@ module ApplicationTests Rails::Initializer.run do |config| config.plugins = [:stubby, :acts_as_chunky_bacon, :all] 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 end @@ -62,16 +67,19 @@ module ApplicationTests Rails::Initializer.run do |config| config.plugins = [:stubby, :acts_as_chunky_bacon] end + Rails.application.new 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") end 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 - Rails::Initializer.run do |config| - config.plugins = [:stubby, :acts_as_a_non_existant_plugin] - end + Rails.application.new end end @@ -83,6 +91,7 @@ module ApplicationTests Rails::Initializer.run do |config| config.plugins = [:stubby, :acts_as_chunky_bacon, :non_existant_plugin1, :non_existant_plugin2] end + Rails.application.new flunk "Expected a LoadError but did not get one" rescue LoadError => e assert_plugins valid_plugins, Rails.application.config.loaded_plugins, @failure_tip diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb index f226e184d1..adc61f6d8a 100644 --- a/railties/test/generators/actions_test.rb +++ b/railties/test/generators/actions_test.rb @@ -57,7 +57,7 @@ class ActionsTest < GeneratorsTestCase def test_gem_should_put_gem_dependency_in_enviroment run_generator action :gem, 'will-paginate' - assert_file 'config/environment.rb', /config\.gem 'will\-paginate'/ + assert_file 'config/application.rb', /config\.gem 'will\-paginate'/ end 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' 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 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 run_generator 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 def test_environment_should_include_data_in_environment_initializer_block run_generator load_paths = 'config.load_paths += %w["#{RAILS_ROOT}/app/extras"]' action :environment, load_paths - assert_file 'config/environment.rb', /#{Regexp.escape(load_paths)}/ + assert_file 'config/application.rb', /#{Regexp.escape(load_paths)}/ end def test_environment_with_block_should_include_block_contents_in_environment_initializer_block @@ -102,7 +102,7 @@ class ActionsTest < GeneratorsTestCase '# This will be added' end - assert_file 'config/environment.rb' do |content| + assert_file 'config/application.rb' do |content| assert_match /# This will be added/, content assert_no_match /# This wont be added/, content end diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 6e46c4ddc0..5d6a9f6de9 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -65,7 +65,7 @@ class AppGeneratorTest < GeneratorsTestCase def test_activerecord_is_removed_from_frameworks_if_skip_activerecord_is_given run_generator ["--skip-activerecord"] - assert_file "config/environment.rb", /config\.frameworks \-= \[ :active_record \]/ + assert_file "config/application.rb", /config\.frameworks \-= \[ :active_record \]/ end def test_prototype_and_test_unit_are_added_by_default diff --git a/railties/test/initializer/check_ruby_version_test.rb b/railties/test/initializer/check_ruby_version_test.rb index 1852fea4df..6c32f5635b 100644 --- a/railties/test/initializer/check_ruby_version_test.rb +++ b/railties/test/initializer/check_ruby_version_test.rb @@ -42,6 +42,7 @@ module InitializerTests set_ruby_version(version) assert_nothing_raised "It appears that rails does not boot" do Rails::Initializer.run { |c| c.frameworks = [] } + Rails.application.new end end @@ -50,6 +51,7 @@ module InitializerTests $stderr = File.open("/dev/null", "w") assert_raises(SystemExit) do Rails::Initializer.run { |c| c.frameworks = [] } + Rails.application.new end end end diff --git a/railties/test/initializer/initialize_i18n_test.rb b/railties/test/initializer/initialize_i18n_test.rb index e909688817..f952d06f94 100644 --- a/railties/test/initializer/initialize_i18n_test.rb +++ b/railties/test/initializer/initialize_i18n_test.rb @@ -14,6 +14,7 @@ module InitializerTests Rails::Initializer.run do |c| c.i18n.load_path << "my/other/locale.yml" end + Rails.application.new #{RAILS_FRAMEWORK_ROOT}/railties/test/fixtures/plugins/engines/engine/config/locales/en.yml assert_equal %W( @@ -35,6 +36,7 @@ module InitializerTests Rails::Initializer.run do |c| c.i18n.load_path << "my/other/locale.yml" end + Rails.application.new #{RAILS_FRAMEWORK_ROOT}/railties/test/fixtures/plugins/engines/engine/config/locales/en.yml assert_equal %W( diff --git a/railties/test/initializer/path_test.rb b/railties/test/initializer/path_test.rb index 72ff8d88e0..ce8fc4b8b0 100644 --- a/railties/test/initializer/path_test.rb +++ b/railties/test/initializer/path_test.rb @@ -12,6 +12,7 @@ class PathsTest < Test::Unit::TestCase ActionController::Base.session_store = nil end end + Rails.application.new @paths = Rails.application.config.paths end diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb index 245577e8c0..5bc878b3be 100644 --- a/railties/test/isolation/abstract_unit.rb +++ b/railties/test/isolation/abstract_unit.rb @@ -94,9 +94,9 @@ module TestHelpers end 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/ - 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 end end |