diff options
author | José Valim <jose.valim@gmail.com> | 2010-01-27 21:20:32 +0100 |
---|---|---|
committer | Carl Lerche <carllerche@mac.com> | 2010-01-28 10:28:41 -0800 |
commit | e7418ab63cc4aa024367851f2f692032840cfe76 (patch) | |
tree | e6e104d8622b7237272e1b9ac75a70223f3c867f /railties/test/application | |
parent | 64ea3dfd9f14b09b65905a10379050ba2f42d8b8 (diff) | |
download | rails-e7418ab63cc4aa024367851f2f692032840cfe76.tar.gz rails-e7418ab63cc4aa024367851f2f692032840cfe76.tar.bz2 rails-e7418ab63cc4aa024367851f2f692032840cfe76.zip |
Add more tests to some key points in Railties.
Signed-off-by: Carl Lerche <carllerche@mac.com>
Diffstat (limited to 'railties/test/application')
-rw-r--r-- | railties/test/application/configuration_test.rb | 11 | ||||
-rw-r--r-- | railties/test/application/initializers/frameworks_test.rb | 6 | ||||
-rw-r--r-- | railties/test/application/initializers/load_path_test.rb | 16 |
3 files changed, 30 insertions, 3 deletions
diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 50d6ba2855..57bd797ef0 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -17,12 +17,15 @@ module ApplicationTests end def setup - FileUtils.rm_rf(new_app) if File.directory?(new_app) build_app boot_rails FileUtils.rm_rf("#{app_path}/config/environments") end + def teardown + FileUtils.rm_rf(new_app) if File.directory?(new_app) + end + test "Rails::Application.instance is nil until app is initialized" do require 'rails' assert_nil Rails::Application.instance @@ -30,6 +33,12 @@ module ApplicationTests assert_equal AppTemplate::Application.instance, Rails::Application.instance end + test "Rails::Application responds to all instance methods" do + require "#{app_path}/config/environment" + assert_respond_to Rails::Application, :routes_reloader + assert_equal Rails::Application.routes_reloader, Rails.application.routes_reloader + end + test "the application root is set correctly" do require "#{app_path}/config/environment" assert_equal Pathname.new(app_path), Rails.application.root diff --git a/railties/test/application/initializers/frameworks_test.rb b/railties/test/application/initializers/frameworks_test.rb index ea052320ef..1e7b9c9997 100644 --- a/railties/test/application/initializers/frameworks_test.rb +++ b/railties/test/application/initializers/frameworks_test.rb @@ -71,6 +71,12 @@ module ApplicationTests assert_equal expects, middleware & expects end + test "active_record extensions are applied to ActiveRecord" do + add_to_config "config.active_record.table_name_prefix = 'tbl_'" + require "#{app_path}/config/environment" + assert_equal 'tbl_', ActiveRecord::Base.table_name_prefix + end + test "database middleware doesn't initialize when activerecord is not in frameworks" do use_frameworks [] require "#{app_path}/config/environment" diff --git a/railties/test/application/initializers/load_path_test.rb b/railties/test/application/initializers/load_path_test.rb index 714b6114a2..b39b9ecaae 100644 --- a/railties/test/application/initializers/load_path_test.rb +++ b/railties/test/application/initializers/load_path_test.rb @@ -10,7 +10,6 @@ module ApplicationTests FileUtils.rm_rf "#{app_path}/config/environments" end - # General test "initializing an application adds the application paths to the load path" do add_to_config <<-RUBY config.root = "#{app_path}" @@ -20,10 +19,24 @@ module ApplicationTests assert $:.include?("#{app_path}/app/models") end + test "initializing an application eager load any path under app" do + app_file "app/anything/foo.rb", <<-RUBY + module Foo; end + RUBY + + add_to_config <<-RUBY + config.root = "#{app_path}" + RUBY + + require "#{app_path}/config/environment" + assert Foo + end + test "eager loading loads parent classes before children" do app_file "lib/zoo.rb", <<-ZOO class Zoo ; include ReptileHouse ; end ZOO + app_file "lib/zoo/reptile_house.rb", <<-ZOO module Zoo::ReptileHouse ; end ZOO @@ -34,7 +47,6 @@ module ApplicationTests RUBY require "#{app_path}/config/environment" - assert Zoo end |