diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-12-21 20:41:25 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-12-21 20:41:25 -0600 |
commit | 1de95077dc3bfc7589ca85dc31d46a1ea6db7650 (patch) | |
tree | 1d59980c564e7f917bddc4d5768c1544e971c596 /railties/test/application | |
parent | 426348b48403f664cc10e8ec545b640e56c1c090 (diff) | |
parent | 2e571e8f99e5e2712c0bc2558df8d62996204b03 (diff) | |
download | rails-1de95077dc3bfc7589ca85dc31d46a1ea6db7650.tar.gz rails-1de95077dc3bfc7589ca85dc31d46a1ea6db7650.tar.bz2 rails-1de95077dc3bfc7589ca85dc31d46a1ea6db7650.zip |
Merge branch 'master' of github.com:rails/rails
Conflicts:
railties/test/initializer/initialize_i18n_test.rb
railties/test/initializer/path_test.rb
Diffstat (limited to 'railties/test/application')
-rw-r--r-- | railties/test/application/configuration_test.rb | 2 | ||||
-rw-r--r-- | railties/test/application/initializer_test.rb | 160 | ||||
-rw-r--r-- | railties/test/application/routing_test.rb | 14 |
3 files changed, 87 insertions, 89 deletions
diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 89337b7f66..83e1401993 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -60,7 +60,7 @@ module ApplicationTests RUBY require "#{app_path}/config/application" - assert AppTemplate.configuration.action_controller.allow_concurrency + assert AppTemplate::Application.configuration.action_controller.allow_concurrency end test "the application can be marked as threadsafe when there are no frameworks" do diff --git a/railties/test/application/initializer_test.rb b/railties/test/application/initializer_test.rb index 031fdc2e9f..b3eff1deb9 100644 --- a/railties/test/application/initializer_test.rb +++ b/railties/test/application/initializer_test.rb @@ -6,31 +6,29 @@ module ApplicationTests def setup build_app - FileUtils.rm_rf("#{app_path}/config/environments") boot_rails require "rails" end test "initializing an application adds the application paths to the load path" do - Rails::Initializer.run do |config| - config.root = app_path - end - Object.const_set(:AppTemplate, Rails.application) + add_to_config <<-RUBY + config.root = "#{app_path}" + RUBY - Rails.initialize! + require "#{app_path}/config/environment" assert $:.include?("#{app_path}/app/models") end test "adding an unknown framework raises an error" do - Rails::Initializer.run do |config| - config.root = app_path + add_to_config <<-RUBY + config.root = "#{app_path}" config.frameworks << :action_foo - end + RUBY require "active_support/core_ext/load_error" assert_raises MissingSourceFile do - Rails.initialize! + require "#{app_path}/config/environment" end end @@ -42,13 +40,12 @@ module ApplicationTests module Zoo::ReptileHouse ; end ZOO - Rails::Initializer.run do |config| - config.root = app_path + add_to_config <<-RUBY + config.root = "#{app_path}" config.eager_load_paths = "#{app_path}/lib" - end - Object.const_set(:AppTemplate, Rails.application) + RUBY - Rails.initialize! + require "#{app_path}/config/environment" assert Zoo end @@ -56,44 +53,43 @@ module ApplicationTests test "load environment with global" do app_file "config/environments/development.rb", "$initialize_test_set_from_env = 'success'" assert_nil $initialize_test_set_from_env - Rails::Initializer.run { |config| config.root = app_path } - Object.const_set(:AppTemplate, Rails.application) - Rails.initialize! + add_to_config <<-RUBY + config.root = "#{app_path}" + RUBY + require "#{app_path}/config/environment" assert_equal "success", $initialize_test_set_from_env end test "action_controller load paths set only if action controller in use" do assert_nothing_raised NameError do - Rails::Initializer.run do |config| - config.root = app_path + add_to_config <<-RUBY + config.root = "#{app_path}" config.frameworks = [] - end - Rails.initialize! + RUBY + require "#{app_path}/config/environment" end end test "after_initialize block works correctly" do - Rails::Initializer.run do |config| - config.root = app_path + add_to_config <<-RUBY + config.root = "#{app_path}" config.after_initialize { $test_after_initialize_block1 = "success" } config.after_initialize { $test_after_initialize_block2 = "congratulations" } - end - Object.const_set(:AppTemplate, Rails.application) - Rails.initialize! + RUBY + require "#{app_path}/config/environment" assert_equal "success", $test_after_initialize_block1 assert_equal "congratulations", $test_after_initialize_block2 end test "after_initialize block works correctly when no block is passed" do - Rails::Initializer.run do |config| - config.root = app_path + add_to_config <<-RUBY + config.root = "#{app_path}" config.after_initialize { $test_after_initialize_block1 = "success" } config.after_initialize # don't pass a block, this is what we're testing! config.after_initialize { $test_after_initialize_block2 = "congratulations" } - end - Object.const_set(:AppTemplate, Rails.application) - Rails.initialize! + RUBY + require "#{app_path}/config/environment" assert_equal "success", $test_after_initialize_block1 assert_equal "congratulations", $test_after_initialize_block2 @@ -101,36 +97,40 @@ module ApplicationTests # i18n test "setting another default locale" do - Rails::Initializer.run do |config| - config.root = app_path + add_to_config <<-RUBY + config.root = "#{app_path}" config.i18n.default_locale = :de - end - Object.const_set(:AppTemplate, Rails.application) - Rails.initialize! + RUBY + require "#{app_path}/config/environment" assert_equal :de, I18n.default_locale end test "no config locales dir present should return empty load path" do FileUtils.rm_rf "#{app_path}/config/locales" - Rails::Initializer.run do |c| - c.root = app_path - assert_equal [], c.i18n.load_path - end + add_to_config <<-RUBY + config.root = "#{app_path}" + RUBY + require "#{app_path}/config/environment" + + assert_equal [], Rails.application.config.i18n.load_path end test "config locales dir present should be added to load path" do - Rails::Initializer.run do |c| - c.root = app_path - assert_equal ["#{app_path}/config/locales/en.yml"], c.i18n.load_path - end + add_to_config <<-RUBY + config.root = "#{app_path}" + RUBY + + require "#{app_path}/config/environment" + assert_equal ["#{app_path}/config/locales/en.yml"], Rails.application.config.i18n.load_path end test "config defaults should be added with config settings" do - Rails::Initializer.run do |c| - c.root = app_path - c.i18n.load_path << "my/other/locale.yml" - end + add_to_config <<-RUBY + config.root = "#{app_path}" + config.i18n.load_path << "my/other/locale.yml" + RUBY + require "#{app_path}/config/environment" assert_equal [ "#{app_path}/config/locales/en.yml", "my/other/locale.yml" @@ -139,31 +139,31 @@ module ApplicationTests # DB middleware test "database middleware doesn't initialize when session store is not active_record" do - Rails::Initializer.run do |config| - config.root = app_path + add_to_config <<-RUBY + config.root = "#{app_path}" config.action_controller.session_store = :cookie_store - end - Object.const_set(:AppTemplate, Rails.application) - Rails.initialize! + RUBY + require "#{app_path}/config/environment" assert !Rails.application.config.middleware.include?(ActiveRecord::SessionStore) end test "database middleware doesn't initialize when activerecord is not in frameworks" do - Rails::Initializer.run do |c| - c.root = app_path - c.frameworks = [] - end + add_to_config <<-RUBY + config.root = "#{app_path}" + config.frameworks = [] + RUBY + require "#{app_path}/config/environment" + assert_equal [], Rails.application.config.middleware end test "database middleware initializes when session store is active record" do - Rails::Initializer.run do |c| - c.root = app_path - c.action_controller.session_store = :active_record_store - end - Object.const_set(:AppTemplate, Rails.application) - Rails.initialize! + add_to_config <<-RUBY + config.root = "#{app_path}" + config.action_controller.session_store = :active_record_store + RUBY + require "#{app_path}/config/environment" expects = [ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActiveRecord::SessionStore] middleware = Rails.application.config.middleware.map { |m| m.klass } @@ -171,35 +171,33 @@ module ApplicationTests end test "ensure database middleware doesn't use action_controller on initializing" do - Rails::Initializer.run do |c| - c.root = app_path - c.frameworks -= [:action_controller] - c.action_controller.session_store = :active_record_store - end - Rails.initialize! + add_to_config <<-RUBY + config.root = "#{app_path}" + config.frameworks -= [:action_controller] + config.action_controller.session_store = :active_record_store + RUBY + require "#{app_path}/config/environment" assert !Rails.application.config.middleware.include?(ActiveRecord::SessionStore) end # Pathview test test "load view paths doesn't perform anything when action_view not in frameworks" do - Rails::Initializer.run do |c| - c.root = app_path - c.frameworks -= [:action_view] - end - Object.const_set(:AppTemplate, Rails.application) - Rails.initialize! + add_to_config <<-RUBY + config.root = "#{app_path}" + config.frameworks -= [:action_view] + RUBY + require "#{app_path}/config/environment" assert_equal nil, ActionMailer::Base.template_root assert_equal [], ActionController::Base.view_paths end test "Rails.root should be a Pathname" do - Rails::Initializer.run do |c| - c.root = app_path - end - Object.const_set(:AppTemplate, Rails.application) - Rails.initialize! + add_to_config <<-RUBY + config.root = "#{app_path}" + RUBY + require "#{app_path}/config/environment" assert_instance_of Pathname, Rails.root end end diff --git a/railties/test/application/routing_test.rb b/railties/test/application/routing_test.rb index 7803794307..7b1df7f45d 100644 --- a/railties/test/application/routing_test.rb +++ b/railties/test/application/routing_test.rb @@ -29,7 +29,7 @@ module ApplicationTests RUBY app_file 'config/routes.rb', <<-RUBY - AppTemplate.routes.draw do |map| + AppTemplate::Application.routes.draw do |map| match ':controller(/:action)' end RUBY @@ -56,7 +56,7 @@ module ApplicationTests RUBY app_file 'config/routes.rb', <<-RUBY - AppTemplate.routes.draw do |map| + AppTemplate::Application.routes.draw do |map| match ':controller(/:action)' end RUBY @@ -88,7 +88,7 @@ module ApplicationTests RUBY app_file 'config/routes.rb', <<-RUBY - AppTemplate.routes.draw do |map| + AppTemplate::Application.routes.draw do |map| match ':controller(/:action)' end RUBY @@ -110,7 +110,7 @@ module ApplicationTests RUBY app_file 'config/routes.rb', <<-RUBY - AppTemplate.routes.draw do |map| + AppTemplate::Application.routes.draw do |map| match 'foo', :to => 'foo#index' end RUBY @@ -125,7 +125,7 @@ module ApplicationTests RUBY plugin.write 'config/routes.rb', <<-RUBY - AppTemplate.routes.draw do |map| + AppTemplate::Application.routes.draw do |map| match 'bar', :to => 'bar#index' end RUBY @@ -152,7 +152,7 @@ module ApplicationTests RUBY app_file 'config/routes.rb', <<-RUBY - AppTemplate.routes.draw do |map| + AppTemplate::Application.routes.draw do |map| match 'foo', :to => 'foo#bar' end RUBY @@ -161,7 +161,7 @@ module ApplicationTests assert_equal 'bar', last_response.body app_file 'config/routes.rb', <<-RUBY - AppTemplate.routes.draw do |map| + AppTemplate::Application.routes.draw do |map| match 'foo', :to => 'foo#baz' end RUBY |