diff options
author | Hongli Lai (Phusion) <hongli@phusion.nl> | 2008-09-04 23:01:40 +0200 |
---|---|---|
committer | Hongli Lai (Phusion) <hongli@phusion.nl> | 2008-09-04 23:01:40 +0200 |
commit | c480c1db1f302ab28a255c5423326e51d27ec5ed (patch) | |
tree | ac2afe4deb5ea436d53e421c14650bc627480f45 /railties/test | |
parent | 08704c442d15b16511214731dd94108b737ef407 (diff) | |
parent | d7bd01f543d18e37f9c353d847bda3456bc337c3 (diff) | |
download | rails-c480c1db1f302ab28a255c5423326e51d27ec5ed.tar.gz rails-c480c1db1f302ab28a255c5423326e51d27ec5ed.tar.bz2 rails-c480c1db1f302ab28a255c5423326e51d27ec5ed.zip |
Merge branch 'master' of git@github.com:lifo/docrails
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/error_page_test.rb | 43 | ||||
-rw-r--r-- | railties/test/fixtures/eager/zoo.rb | 3 | ||||
-rw-r--r-- | railties/test/fixtures/eager/zoo/reptile_house.rb | 2 | ||||
-rw-r--r-- | railties/test/generators/rails_model_generator_test.rb | 16 | ||||
-rw-r--r-- | railties/test/initializer_test.rb | 18 | ||||
-rw-r--r-- | railties/test/secret_key_generation_test.rb | 10 |
6 files changed, 84 insertions, 8 deletions
diff --git a/railties/test/error_page_test.rb b/railties/test/error_page_test.rb new file mode 100644 index 0000000000..844f889aad --- /dev/null +++ b/railties/test/error_page_test.rb @@ -0,0 +1,43 @@ +require 'abstract_unit' +require 'action_controller' +require 'action_controller/test_process' + +RAILS_ENV = "test" +CURRENT_DIR = File.expand_path(File.dirname(__FILE__)) +HTML_DIR = File.expand_path(File.join(CURRENT_DIR, "..", "html")) + +module Rails + def self.public_path + CURRENT_DIR + end +end + +class ErrorPageController < ActionController::Base + def crash + raise StandardError, "crash!" + end +end + +ActionController::Routing::Routes.draw do |map| + map.connect ':controller/:action/:id' +end + +class ErrorPageControllerTest < Test::Unit::TestCase + def setup + @controller = ErrorPageController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + + ActionController::Base.consider_all_requests_local = false + end + + def test_500_error_page_instructs_system_administrator_to_check_log_file + template = ERB.new(File.read(File.join(HTML_DIR, "500.html"))) + File.open(File.join(CURRENT_DIR, "500.html"), "w") do |f| + f.write(template.result) + end + get :crash + expected_log_file = "#{RAILS_ENV}.log" + assert_not_nil @response.body.index(expected_log_file) + end +end diff --git a/railties/test/fixtures/eager/zoo.rb b/railties/test/fixtures/eager/zoo.rb new file mode 100644 index 0000000000..8b10ef984b --- /dev/null +++ b/railties/test/fixtures/eager/zoo.rb @@ -0,0 +1,3 @@ +class Zoo + include ReptileHouse +end
\ No newline at end of file diff --git a/railties/test/fixtures/eager/zoo/reptile_house.rb b/railties/test/fixtures/eager/zoo/reptile_house.rb new file mode 100644 index 0000000000..82bbafce79 --- /dev/null +++ b/railties/test/fixtures/eager/zoo/reptile_house.rb @@ -0,0 +1,2 @@ +module Zoo::ReptileHouse +end
\ No newline at end of file diff --git a/railties/test/generators/rails_model_generator_test.rb b/railties/test/generators/rails_model_generator_test.rb index 0bfc338566..aea2abafba 100644 --- a/railties/test/generators/rails_model_generator_test.rb +++ b/railties/test/generators/rails_model_generator_test.rb @@ -29,4 +29,20 @@ class RailsModelGeneratorTest < GeneratorTestCase assert_generated_column t, :created_at, :timestamp end end + + def test_model_with_reference_attributes_generates_belongs_to_associations + run_generator('model', %w(Product name:string supplier:references)) + + assert_generated_model_for :product do |body| + assert body =~ /^\s+belongs_to :supplier/, "#{body.inspect} should contain 'belongs_to :supplier'" + end + end + + def test_model_with_belongs_to_attributes_generates_belongs_to_associations + run_generator('model', %w(Product name:string supplier:belongs_to)) + + assert_generated_model_for :product do |body| + assert body =~ /^\s+belongs_to :supplier/, "#{body.inspect} should contain 'belongs_to :supplier'" + end + end end diff --git a/railties/test/initializer_test.rb b/railties/test/initializer_test.rb index 07303a510e..5147eeb482 100644 --- a/railties/test/initializer_test.rb +++ b/railties/test/initializer_test.rb @@ -30,6 +30,24 @@ class Initializer_load_environment_Test < Test::Unit::TestCase end +class Initializer_eager_loading_Test < Test::Unit::TestCase + def setup + @config = ConfigurationMock.new("") + @config.cache_classes = true + @config.load_paths = [File.expand_path(File.dirname(__FILE__) + "/fixtures/eager")] + @config.eager_load_paths = [File.expand_path(File.dirname(__FILE__) + "/fixtures/eager")] + @initializer = Rails::Initializer.new(@config) + @initializer.set_load_path + @initializer.set_autoload_paths + end + + def test_eager_loading_loads_parent_classes_before_children + assert_nothing_raised do + @initializer.load_application_classes + end + end +end + uses_mocha 'Initializer after_initialize' do class Initializer_after_initialize_with_blocks_environment_Test < Test::Unit::TestCase def setup diff --git a/railties/test/secret_key_generation_test.rb b/railties/test/secret_key_generation_test.rb index ea1b0dae31..7269f98ce5 100644 --- a/railties/test/secret_key_generation_test.rb +++ b/railties/test/secret_key_generation_test.rb @@ -31,14 +31,8 @@ class SecretKeyGenerationTest < Test::Unit::TestCase end def test_secret_key_generation - assert @generator.generate_secret.length >= SECRET_KEY_MIN_LENGTH - end - - Rails::SecretKeyGenerator::GENERATORS.each do |generator| - if Rails::SecretKeyGenerator.send("supports_#{generator}?") - define_method("test_secret_key_generation_with_#{generator}") do - assert @generator.send("generate_secret_with_#{generator}").length >= SECRET_KEY_MIN_LENGTH - end + assert_deprecated /ActiveSupport::SecureRandom\.hex\(64\)/ do + assert @generator.generate_secret.length >= SECRET_KEY_MIN_LENGTH end end end |