From 0432d151647f2178ddee79979827d552447c251f Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Wed, 16 Jul 2008 13:00:36 +0100 Subject: Merge with docrails. --- railties/test/generators/generator_test_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/test') diff --git a/railties/test/generators/generator_test_helper.rb b/railties/test/generators/generator_test_helper.rb index 05dca3400e..80d5b145be 100644 --- a/railties/test/generators/generator_test_helper.rb +++ b/railties/test/generators/generator_test_helper.rb @@ -226,7 +226,7 @@ class GeneratorTestCase < Test::Unit::TestCase end end - # Asserts that the given fixtures yaml file was generated. + # Asserts that the given fixtures YAML file was generated. # It takes a fixture name without the .yml part. # The parsed YAML tree is passed to a block. def assert_generated_fixtures_for(name) -- cgit v1.2.3 From 576cae004342899b0506a7834edc524a02a7d9ef Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sat, 19 Jul 2008 11:34:32 -0500 Subject: Stub out timestamped_migrations in generator tests --- railties/test/generators/generator_test_helper.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'railties/test') diff --git a/railties/test/generators/generator_test_helper.rb b/railties/test/generators/generator_test_helper.rb index 80d5b145be..0901b215e4 100644 --- a/railties/test/generators/generator_test_helper.rb +++ b/railties/test/generators/generator_test_helper.rb @@ -5,9 +5,10 @@ require 'fileutils' module ActiveRecord class Base class << self - attr_accessor :pluralize_table_names + attr_accessor :pluralize_table_names, :timestamped_migrations end self.pluralize_table_names = true + self.timestamped_migrations = true end module ConnectionAdapters -- cgit v1.2.3 From 11fdcf88c2aea72ec84c5d4ab05986f5d35a9a81 Mon Sep 17 00:00:00 2001 From: Sam Granieri Date: Thu, 24 Jul 2008 13:51:54 -0500 Subject: Check for ActionMailer and ActionController before attempting to eager load their view paths Signed-off-by: Joshua Peek --- railties/test/initializer_test.rb | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'railties/test') diff --git a/railties/test/initializer_test.rb b/railties/test/initializer_test.rb index dee7abe05f..07303a510e 100644 --- a/railties/test/initializer_test.rb +++ b/railties/test/initializer_test.rb @@ -136,8 +136,27 @@ uses_mocha 'framework paths' do end end - protected + def test_action_mailer_load_paths_set_only_if_action_mailer_in_use + @config.frameworks = [:action_controller] + initializer = Rails::Initializer.new @config + initializer.send :require_frameworks + + assert_nothing_raised NameError do + initializer.send :load_view_paths + end + end + def test_action_controller_load_paths_set_only_if_action_controller_in_use + @config.frameworks = [] + initializer = Rails::Initializer.new @config + initializer.send :require_frameworks + + assert_nothing_raised NameError do + initializer.send :load_view_paths + end + end + + protected def assert_framework_path(path) assert @config.framework_paths.include?(path), "<#{path.inspect}> not found among <#{@config.framework_paths.inspect}>" -- cgit v1.2.3 From 61842d97c5269af8a36a33115f50543a155f1608 Mon Sep 17 00:00:00 2001 From: Ben Sandofsky Date: Fri, 1 Aug 2008 17:01:10 -0700 Subject: Make requiring gems optional. Signed-off-by: Michael Koziarski [#743 state:resolved] --- railties/test/gem_dependency_test.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'railties/test') diff --git a/railties/test/gem_dependency_test.rb b/railties/test/gem_dependency_test.rb index b5946aa7b8..964ca50992 100644 --- a/railties/test/gem_dependency_test.rb +++ b/railties/test/gem_dependency_test.rb @@ -11,6 +11,7 @@ uses_mocha "Plugin Tests" do @gem_with_source = Rails::GemDependency.new "hpricot", :source => "http://code.whytheluckystiff.net" @gem_with_version = Rails::GemDependency.new "hpricot", :version => "= 0.6" @gem_with_lib = Rails::GemDependency.new "aws-s3", :lib => "aws/s3" + @gem_without_load = Rails::GemDependency.new "hpricot", :lib => false end def test_configuration_adds_gem_dependency @@ -62,5 +63,13 @@ uses_mocha "Plugin Tests" do @gem_with_lib.add_load_paths @gem_with_lib.load end + + def test_gem_without_lib_loading + @gem_without_load.expects(:gem).with(@gem_without_load.name) + @gem_without_load.expects(:require).with(@gem_without_load.lib).never + @gem_without_load.add_load_paths + @gem_without_load.load + end + end end -- cgit v1.2.3 From 89d1c77dd012f087c091e0f23874c582ea4e3703 Mon Sep 17 00:00:00 2001 From: Tom Ward Date: Tue, 19 Aug 2008 13:19:41 +0100 Subject: Initializer to sort files before eager loading. [#859 state:resolved] Changed Rails::Initializer to sort files before eager loading them. This ensures that any files in a parent directory will be loaded before files in a subdirectory of the 'same' name. i.e. zoo.rb will be loaded before zoo/reptile_house.rb Signed-off-by: Pratik Naik --- railties/test/fixtures/eager/zoo.rb | 3 +++ railties/test/fixtures/eager/zoo/reptile_house.rb | 2 ++ railties/test/initializer_test.rb | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 railties/test/fixtures/eager/zoo.rb create mode 100644 railties/test/fixtures/eager/zoo/reptile_house.rb (limited to 'railties/test') 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/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 -- cgit v1.2.3 From 9223a919111867e6b47b2627c30d8eb21e8ac7d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20T=C3=A4nav?= Date: Sat, 23 Aug 2008 20:58:44 +0300 Subject: Generate belongs_to associations automatically for 'references' types [#640 state:resolved] --- railties/test/generators/rails_model_generator_test.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'railties/test') diff --git a/railties/test/generators/rails_model_generator_test.rb b/railties/test/generators/rails_model_generator_test.rb index 0bfc338566..67cd3aa26f 100644 --- a/railties/test/generators/rails_model_generator_test.rb +++ b/railties/test/generators/rails_model_generator_test.rb @@ -29,4 +29,12 @@ 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 end -- cgit v1.2.3 From b1f3c6e6ec08a40fc7153ee3ba78d51b466a58e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20T=C3=A4nav?= Date: Sat, 23 Aug 2008 21:54:43 +0300 Subject: Generate belongs_to association when generating a model --- railties/test/generators/rails_model_generator_test.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'railties/test') diff --git a/railties/test/generators/rails_model_generator_test.rb b/railties/test/generators/rails_model_generator_test.rb index 67cd3aa26f..aea2abafba 100644 --- a/railties/test/generators/rails_model_generator_test.rb +++ b/railties/test/generators/rails_model_generator_test.rb @@ -37,4 +37,12 @@ class RailsModelGeneratorTest < GeneratorTestCase 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 -- cgit v1.2.3 From f9f1ab4e3ddeacadf2a7bce021d742f08f67905f Mon Sep 17 00:00:00 2001 From: "Hongli Lai (Phusion" Date: Thu, 10 Jul 2008 13:21:08 +0200 Subject: When an unexpected exception is caught, tell the administrator to read the log file for more information about the error. This should make things less confusing for developers who are new to Rails. Signed-off-by: Michael Koziarski --- railties/test/error_page_test.rb | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 railties/test/error_page_test.rb (limited to 'railties/test') diff --git a/railties/test/error_page_test.rb b/railties/test/error_page_test.rb new file mode 100644 index 0000000000..0e43700eb6 --- /dev/null +++ b/railties/test/error_page_test.rb @@ -0,0 +1,37 @@ +require 'abstract_unit' +require 'action_controller' +require 'action_controller/test_process' + +RAILS_ENV = "test" + +module Rails + def self.public_path + File.expand_path(File.join(File.dirname(__FILE__), "..", "html")) + 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 + get :crash + expected_log_file = "#{RAILS_ENV}.log" + assert_not_nil @response.body.index(expected_log_file) + end +end -- cgit v1.2.3 From c111522d5b8cd108756240a0348d515d6acee46c Mon Sep 17 00:00:00 2001 From: "Hongli Lai (Phusion" Date: Tue, 26 Aug 2008 15:59:03 +0200 Subject: The 'rails' command was broken by the last commit. Fix that. Signed-off-by: Michael Koziarski --- railties/test/error_page_test.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'railties/test') diff --git a/railties/test/error_page_test.rb b/railties/test/error_page_test.rb index 0e43700eb6..844f889aad 100644 --- a/railties/test/error_page_test.rb +++ b/railties/test/error_page_test.rb @@ -3,10 +3,12 @@ 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 - File.expand_path(File.join(File.dirname(__FILE__), "..", "html")) + CURRENT_DIR end end @@ -30,6 +32,10 @@ class ErrorPageControllerTest < Test::Unit::TestCase 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) -- cgit v1.2.3