aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/rails-2.1.0/railties/test
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/rails-2.1.0/railties/test')
-rw-r--r--vendor/rails-2.1.0/railties/test/abstract_unit.rb24
-rw-r--r--vendor/rails-2.1.0/railties/test/boot_test.rb181
-rw-r--r--vendor/rails-2.1.0/railties/test/console_app_test.rb32
-rw-r--r--vendor/rails-2.1.0/railties/test/fcgi_dispatcher_test.rb299
-rw-r--r--vendor/rails-2.1.0/railties/test/fixtures/about_yml_plugins/bad_about_yml/about.yml1
-rw-r--r--vendor/rails-2.1.0/railties/test/fixtures/about_yml_plugins/bad_about_yml/init.rb1
-rw-r--r--vendor/rails-2.1.0/railties/test/fixtures/about_yml_plugins/plugin_without_about_yml/init.rb1
-rw-r--r--vendor/rails-2.1.0/railties/test/fixtures/environment_with_constant.rb1
-rw-r--r--vendor/rails-2.1.0/railties/test/fixtures/lib/generators/missing_class/missing_class_generator.rb0
-rw-r--r--vendor/rails-2.1.0/railties/test/fixtures/lib/generators/missing_class/templates/.gitignore0
-rw-r--r--vendor/rails-2.1.0/railties/test/fixtures/lib/generators/missing_generator/templates/.gitignore0
-rw-r--r--vendor/rails-2.1.0/railties/test/fixtures/lib/generators/missing_templates/.gitignore0
-rw-r--r--vendor/rails-2.1.0/railties/test/fixtures/lib/generators/working/working_generator.rb2
-rw-r--r--vendor/rails-2.1.0/railties/test/fixtures/plugins/alternate/a/generators/a_generator/a_generator.rb4
-rw-r--r--vendor/rails-2.1.0/railties/test/fixtures/plugins/alternate/a/lib/.gitignore0
-rw-r--r--vendor/rails-2.1.0/railties/test/fixtures/plugins/default/acts/acts_as_chunky_bacon/lib/.gitignore0
-rw-r--r--vendor/rails-2.1.0/railties/test/fixtures/plugins/default/empty/.gitignore0
-rw-r--r--vendor/rails-2.1.0/railties/test/fixtures/plugins/default/plugin_with_no_lib_dir/init.rb0
-rw-r--r--vendor/rails-2.1.0/railties/test/fixtures/plugins/default/stubby/about.yml2
-rw-r--r--vendor/rails-2.1.0/railties/test/fixtures/plugins/default/stubby/generators/stubby_generator/stubby_generator.rb4
-rw-r--r--vendor/rails-2.1.0/railties/test/fixtures/plugins/default/stubby/init.rb7
-rw-r--r--vendor/rails-2.1.0/railties/test/fixtures/plugins/default/stubby/lib/stubby_mixin.rb2
-rw-r--r--vendor/rails-2.1.0/railties/test/gem_dependency_test.rb66
-rw-r--r--vendor/rails-2.1.0/railties/test/generator_lookup_test.rb40
-rw-r--r--vendor/rails-2.1.0/railties/test/generators/generator_test_helper.rb287
-rw-r--r--vendor/rails-2.1.0/railties/test/generators/rails_controller_generator_test.rb20
-rw-r--r--vendor/rails-2.1.0/railties/test/generators/rails_mailer_generator_test.rb29
-rw-r--r--vendor/rails-2.1.0/railties/test/generators/rails_model_generator_test.rb32
-rw-r--r--vendor/rails-2.1.0/railties/test/generators/rails_resource_generator_test.rb29
-rw-r--r--vendor/rails-2.1.0/railties/test/generators/rails_scaffold_generator_test.rb107
-rw-r--r--vendor/rails-2.1.0/railties/test/initializer_test.rb225
-rw-r--r--vendor/rails-2.1.0/railties/test/mocks/routes.rb6
-rw-r--r--vendor/rails-2.1.0/railties/test/plugin_loader_test.rb142
-rw-r--r--vendor/rails-2.1.0/railties/test/plugin_locator_test.rb69
-rw-r--r--vendor/rails-2.1.0/railties/test/plugin_test.rb159
-rw-r--r--vendor/rails-2.1.0/railties/test/plugin_test_helper.rb29
-rw-r--r--vendor/rails-2.1.0/railties/test/rails_generator_test.rb145
-rw-r--r--vendor/rails-2.1.0/railties/test/rails_info_controller_test.rb48
-rw-r--r--vendor/rails-2.1.0/railties/test/rails_info_test.rb99
-rw-r--r--vendor/rails-2.1.0/railties/test/secret_key_generation_test.rb44
40 files changed, 2137 insertions, 0 deletions
diff --git a/vendor/rails-2.1.0/railties/test/abstract_unit.rb b/vendor/rails-2.1.0/railties/test/abstract_unit.rb
new file mode 100644
index 000000000..e1ce32da6
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/abstract_unit.rb
@@ -0,0 +1,24 @@
+$:.unshift File.dirname(__FILE__) + "/../../activesupport/lib"
+$:.unshift File.dirname(__FILE__) + "/../../actionpack/lib"
+$:.unshift File.dirname(__FILE__) + "/../lib"
+$:.unshift File.dirname(__FILE__) + "/../builtin/rails_info"
+
+require 'test/unit'
+require 'stringio'
+require 'active_support'
+
+# Wrap tests that use Mocha and skip if unavailable.
+def uses_mocha(test_name)
+ require 'rubygems'
+ gem 'mocha', '>= 0.5.5'
+ require 'mocha'
+ yield
+rescue LoadError
+ $stderr.puts "Skipping #{test_name} tests. `gem install mocha` and try again."
+end
+
+if defined?(RAILS_ROOT)
+ RAILS_ROOT.replace File.dirname(__FILE__)
+else
+ RAILS_ROOT = File.dirname(__FILE__)
+end
diff --git a/vendor/rails-2.1.0/railties/test/boot_test.rb b/vendor/rails-2.1.0/railties/test/boot_test.rb
new file mode 100644
index 000000000..7736a8f4c
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/boot_test.rb
@@ -0,0 +1,181 @@
+require 'abstract_unit'
+require 'initializer'
+require "#{File.dirname(__FILE__)}/../environments/boot"
+
+uses_mocha 'boot tests' do
+
+class BootTest < Test::Unit::TestCase
+ def test_boot_returns_if_booted
+ Rails.expects(:booted?).returns(true)
+ Rails.expects(:pick_boot).never
+ assert_nil Rails.boot!
+ end
+
+ def test_boot_preinitializes_then_picks_and_runs_if_not_booted
+ Rails.expects(:booted?).returns(false)
+ Rails.expects(:preinitialize)
+ Rails.expects(:pick_boot).returns(mock(:run => 'result'))
+ assert_equal 'result', Rails.boot!
+ end
+
+ def test_preinitialize_does_not_raise_exception_if_preinitializer_file_does_not_exist
+ Rails.stubs(:preinitializer_path).returns('/there/is/no/such/file')
+
+ assert_nothing_raised { Rails.preinitialize }
+ end
+
+ def test_load_preinitializer_loads_preinitializer_file
+ Rails.stubs(:preinitializer_path).returns("#{File.dirname(__FILE__)}/fixtures/environment_with_constant.rb")
+
+ assert_nil $initialize_test_set_from_env
+ Rails.preinitialize
+ assert_equal "success", $initialize_test_set_from_env
+ ensure
+ $initialize_test_set_from_env = nil
+ end
+
+ def test_boot_vendor_rails_by_default
+ Rails.expects(:booted?).returns(false)
+ Rails.expects(:preinitialize)
+ File.expects(:exist?).with("#{RAILS_ROOT}/vendor/rails").returns(true)
+ Rails::VendorBoot.any_instance.expects(:run).returns('result')
+ assert_equal 'result', Rails.boot!
+ end
+
+ def test_boot_gem_rails_otherwise
+ Rails.expects(:booted?).returns(false)
+ Rails.expects(:preinitialize)
+ File.expects(:exist?).with("#{RAILS_ROOT}/vendor/rails").returns(false)
+ Rails::GemBoot.any_instance.expects(:run).returns('result')
+ assert_equal 'result', Rails.boot!
+ end
+
+ def test_run_loads_initializer_and_sets_load_path
+ boot = Rails::Boot.new
+ boot.expects(:load_initializer)
+ Rails::Initializer.expects(:run).with(:set_load_path)
+ boot.run
+ end
+end
+
+class VendorBootTest < Test::Unit::TestCase
+ include Rails
+
+ def test_load_initializer_requires_from_vendor_rails
+ boot = VendorBoot.new
+ boot.expects(:require).with("#{RAILS_ROOT}/vendor/rails/railties/lib/initializer")
+ boot.load_initializer
+ end
+end
+
+class GemBootTest < Test::Unit::TestCase
+ include Rails
+
+ def test_load_initializer_loads_rubygems_and_the_rails_gem
+ boot = GemBoot.new
+ GemBoot.expects(:load_rubygems)
+ boot.expects(:load_rails_gem)
+ boot.expects(:require).with('initializer')
+ boot.load_initializer
+ end
+
+ def test_load_rubygems_exits_with_error_if_missing
+ GemBoot.expects(:require).with('rubygems').raises(LoadError, 'missing rubygems')
+ STDERR.expects(:puts)
+ GemBoot.expects(:exit).with(1)
+ GemBoot.load_rubygems
+ end
+
+ def test_load_rubygems_exits_with_error_if_too_old
+ GemBoot.stubs(:rubygems_version).returns('0.0.1')
+ GemBoot.expects(:require).with('rubygems').returns(true)
+ STDERR.expects(:puts)
+ GemBoot.expects(:exit).with(1)
+ GemBoot.load_rubygems
+ end
+
+ def test_load_rails_gem_activates_specific_gem_if_version_given
+ GemBoot.stubs(:gem_version).returns('0.0.1')
+
+ boot = GemBoot.new
+ boot.expects(:gem).with('rails', '0.0.1')
+ boot.load_rails_gem
+ end
+
+ def test_load_rails_gem_activates_latest_gem_if_no_version_given
+ GemBoot.stubs(:gem_version).returns(nil)
+
+ boot = GemBoot.new
+ boot.expects(:gem).with('rails')
+ boot.load_rails_gem
+ end
+
+ def test_load_rails_gem_exits_with_error_if_missing
+ GemBoot.stubs(:gem_version).returns('0.0.1')
+
+ boot = GemBoot.new
+ boot.expects(:gem).with('rails', '0.0.1').raises(Gem::LoadError, 'missing rails 0.0.1 gem')
+ STDERR.expects(:puts)
+ boot.expects(:exit).with(1)
+ boot.load_rails_gem
+ end
+end
+
+end # uses_mocha
+
+
+class ParseGemVersionTest < Test::Unit::TestCase
+ def test_should_return_nil_if_no_lines_are_passed
+ assert_equal nil, parse('')
+ assert_equal nil, parse(nil)
+ end
+
+ def test_should_accept_either_single_or_double_quotes
+ assert_equal "1.2.3", parse("RAILS_GEM_VERSION = '1.2.3'")
+ assert_equal "1.2.3", parse('RAILS_GEM_VERSION = "1.2.3"')
+ end
+
+ def test_should_return_nil_if_no_lines_match
+ assert_equal nil, parse('nothing matches on this line\nor on this line')
+ end
+
+ def test_should_parse_with_no_leading_space
+ assert_equal "1.2.3", parse("RAILS_GEM_VERSION = '1.2.3' unless defined? RAILS_GEM_VERSION")
+ assert_equal "1.2.3", parse("RAILS_GEM_VERSION = '1.2.3'")
+ end
+
+ def test_should_parse_with_any_number_of_leading_spaces
+ assert_equal nil, parse([])
+ assert_equal "1.2.3", parse(" RAILS_GEM_VERSION = '1.2.3' unless defined? RAILS_GEM_VERSION")
+ assert_equal "1.2.3", parse(" RAILS_GEM_VERSION = '1.2.3' unless defined? RAILS_GEM_VERSION")
+ assert_equal "1.2.3", parse(" RAILS_GEM_VERSION = '1.2.3'")
+ assert_equal "1.2.3", parse(" RAILS_GEM_VERSION = '1.2.3'")
+ end
+
+ def test_should_ignore_unrelated_comments
+ assert_equal "1.2.3", parse("# comment\nRAILS_GEM_VERSION = '1.2.3'\n# comment")
+ end
+
+ def test_should_ignore_commented_version_lines
+ assert_equal "1.2.3", parse("#RAILS_GEM_VERSION = '9.8.7'\nRAILS_GEM_VERSION = '1.2.3'")
+ assert_equal "1.2.3", parse("# RAILS_GEM_VERSION = '9.8.7'\nRAILS_GEM_VERSION = '1.2.3'")
+ assert_equal "1.2.3", parse("RAILS_GEM_VERSION = '1.2.3'\n# RAILS_GEM_VERSION = '9.8.7'")
+ end
+
+ def test_should_allow_advanced_rubygems_version_specifications
+ # See http://rubygems.org/read/chapter/16
+ assert_equal "=1.2.3", parse("RAILS_GEM_VERSION = '=1.2.3'") # equal sign
+ assert_equal "= 1.2.3", parse("RAILS_GEM_VERSION = '= 1.2.3'") # with space
+ assert_equal "!=1.2.3", parse("RAILS_GEM_VERSION = '!=1.2.3'") # not equal
+ assert_equal ">1.2.3", parse("RAILS_GEM_VERSION = '>1.2.3'") # greater than
+ assert_equal "<1.2.3", parse("RAILS_GEM_VERSION = '<1.2.3'") # less than
+ assert_equal ">=1.2.3", parse("RAILS_GEM_VERSION = '>=1.2.3'") # greater than or equal
+ assert_equal "<=1.2.3", parse("RAILS_GEM_VERSION = '<=1.2.3'") # less than or equal
+ assert_equal "~>1.2.3.0", parse("RAILS_GEM_VERSION = '~>1.2.3.0'") # approximately greater than
+ end
+
+ private
+ def parse(text)
+ Rails::GemBoot.parse_gem_version(text)
+ end
+end
diff --git a/vendor/rails-2.1.0/railties/test/console_app_test.rb b/vendor/rails-2.1.0/railties/test/console_app_test.rb
new file mode 100644
index 000000000..6cfc907b8
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/console_app_test.rb
@@ -0,0 +1,32 @@
+require 'abstract_unit'
+
+require 'action_controller' # console_app uses 'action_controller/integration'
+
+unless defined? ApplicationController
+ class ApplicationController < ActionController::Base; end
+end
+
+require 'dispatcher'
+require 'console_app'
+
+# console_app sets Test::Unit.run to work around the at_exit hook in test/unit, which kills IRB
+Test::Unit.run = false
+
+class ConsoleAppTest < Test::Unit::TestCase
+ uses_mocha 'console reload test' do
+ def test_reload_should_fire_preparation_callbacks
+ a = b = c = nil
+
+ Dispatcher.to_prepare { a = b = c = 1 }
+ Dispatcher.to_prepare { b = c = 2 }
+ Dispatcher.to_prepare { c = 3 }
+ ActionController::Routing::Routes.expects(:reload)
+
+ reload!
+
+ assert_equal 1, a
+ assert_equal 2, b
+ assert_equal 3, c
+ end
+ end
+end
diff --git a/vendor/rails-2.1.0/railties/test/fcgi_dispatcher_test.rb b/vendor/rails-2.1.0/railties/test/fcgi_dispatcher_test.rb
new file mode 100644
index 000000000..64d054d45
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/fcgi_dispatcher_test.rb
@@ -0,0 +1,299 @@
+require 'abstract_unit'
+
+uses_mocha 'fcgi dispatcher tests' do
+
+require 'fcgi_handler'
+
+module ActionController; module Routing; module Routes; end end end
+
+class RailsFCGIHandlerTest < Test::Unit::TestCase
+ def setup
+ @log = StringIO.new
+ @handler = RailsFCGIHandler.new(@log)
+ end
+
+ def test_process_restart
+ cgi = mock
+ FCGI.stubs(:each_cgi).yields(cgi)
+
+ @handler.expects(:process_request).once
+ @handler.expects(:dispatcher_error).never
+
+ @handler.expects(:when_ready).returns(:restart)
+ @handler.expects(:close_connection).with(cgi)
+ @handler.expects(:reload!).never
+ @handler.expects(:restart!)
+
+ @handler.process!
+ end
+
+ def test_process_exit
+ cgi = mock
+ FCGI.stubs(:each_cgi).yields(cgi)
+
+ @handler.expects(:process_request).once
+ @handler.expects(:dispatcher_error).never
+
+ @handler.expects(:when_ready).returns(:exit)
+ @handler.expects(:close_connection).with(cgi)
+ @handler.expects(:reload!).never
+ @handler.expects(:restart!).never
+
+ @handler.process!
+ end
+
+ def test_process_with_system_exit_exception
+ cgi = mock
+ FCGI.stubs(:each_cgi).yields(cgi)
+
+ @handler.expects(:process_request).once.raises(SystemExit)
+ @handler.stubs(:dispatcher_log)
+ @handler.expects(:dispatcher_log).with(:info, regexp_matches(/^stopping/))
+ @handler.expects(:dispatcher_error).never
+
+ @handler.expects(:when_ready).never
+ @handler.expects(:close_connection).never
+ @handler.expects(:reload!).never
+ @handler.expects(:restart!).never
+
+ @handler.process!
+ end
+
+ def test_restart_handler_outside_request
+ @handler.expects(:dispatcher_log).with(:info, "asked to restart ASAP")
+ @handler.expects(:restart!).once
+
+ @handler.send(:restart_handler, nil)
+ assert_equal nil, @handler.when_ready
+ end
+
+ def test_install_signal_handler_should_log_on_bad_signal
+ @handler.stubs(:trap).raises(ArgumentError)
+
+ @handler.expects(:dispatcher_log).with(:warn, "Ignoring unsupported signal CHEESECAKE.")
+ @handler.send(:install_signal_handler, "CHEESECAKE", nil)
+ end
+
+ def test_reload
+ @handler.expects(:restore!)
+ @handler.expects(:dispatcher_log).with(:info, "reloaded")
+
+ @handler.send(:reload!)
+ assert_nil @handler.when_ready
+ end
+
+
+ def test_reload_runs_gc_when_gc_request_period_set
+ @handler.expects(:run_gc!)
+ @handler.expects(:restore!)
+ @handler.expects(:dispatcher_log).with(:info, "reloaded")
+ @handler.gc_request_period = 10
+ @handler.send(:reload!)
+ end
+
+ def test_reload_doesnt_run_gc_if_gc_request_period_isnt_set
+ @handler.expects(:run_gc!).never
+ @handler.expects(:restore!)
+ @handler.expects(:dispatcher_log).with(:info, "reloaded")
+ @handler.send(:reload!)
+ end
+
+ def test_restart!
+ @handler.expects(:dispatcher_log).with(:info, "restarted")
+ @handler.expects(:exec).returns('restarted')
+ assert_equal 'restarted', @handler.send(:restart!)
+ end
+
+ def test_restore!
+ $".expects(:replace)
+ Dispatcher.expects(:reset_application!)
+ ActionController::Routing::Routes.expects(:reload)
+ @handler.send(:restore!)
+ end
+
+ def test_uninterrupted_processing
+ cgi = mock
+ FCGI.expects(:each_cgi).yields(cgi)
+ @handler.expects(:process_request).with(cgi)
+
+ @handler.process!
+
+ assert_nil @handler.when_ready
+ end
+end
+
+
+class RailsFCGIHandlerSignalsTest < Test::Unit::TestCase
+ class ::RailsFCGIHandler
+ attr_accessor :signal
+ alias_method :old_gc_countdown, :gc_countdown
+ def gc_countdown
+ signal ? Process.kill(signal, $$) : old_gc_countdown
+ end
+ end
+
+ class ::Dispatcher
+ class << self
+ attr_accessor :signal
+ alias_method :old_dispatch, :dispatch
+ def dispatch(cgi)
+ signal ? Process.kill(signal, $$) : old_dispatch
+ end
+ end
+ end
+
+ def setup
+ @log = StringIO.new
+ @handler = RailsFCGIHandler.new(@log)
+ end
+
+ def test_interrupted_via_HUP_when_not_in_request
+ cgi = mock
+ FCGI.expects(:each_cgi).once.yields(cgi)
+ @handler.expects(:signal).times(2).returns('HUP')
+
+ @handler.expects(:reload!).once
+ @handler.expects(:close_connection).never
+ @handler.expects(:exit).never
+
+ @handler.process!
+ assert_equal :reload, @handler.when_ready
+ end
+
+ def test_interrupted_via_HUP_when_in_request
+ cgi = mock
+ FCGI.expects(:each_cgi).once.yields(cgi)
+ Dispatcher.expects(:signal).times(2).returns('HUP')
+
+ @handler.expects(:reload!).once
+ @handler.expects(:close_connection).never
+ @handler.expects(:exit).never
+
+ @handler.process!
+ assert_equal :reload, @handler.when_ready
+ end
+
+ def test_interrupted_via_USR1_when_not_in_request
+ cgi = mock
+ FCGI.expects(:each_cgi).once.yields(cgi)
+ @handler.expects(:signal).times(2).returns('USR1')
+ @handler.expects(:exit_handler).never
+
+ @handler.expects(:reload!).never
+ @handler.expects(:close_connection).with(cgi).once
+ @handler.expects(:exit).never
+
+ @handler.process!
+ assert_nil @handler.when_ready
+ end
+
+ def test_interrupted_via_USR1_when_in_request
+ cgi = mock
+ FCGI.expects(:each_cgi).once.yields(cgi)
+ Dispatcher.expects(:signal).times(2).returns('USR1')
+
+ @handler.expects(:reload!).never
+ @handler.expects(:close_connection).with(cgi).once
+ @handler.expects(:exit).never
+
+ @handler.process!
+ assert_equal :exit, @handler.when_ready
+ end
+
+ def test_restart_via_USR2_when_in_request
+ cgi = mock
+ FCGI.expects(:each_cgi).once.yields(cgi)
+ @handler.expects(:signal).times(2).returns('USR2')
+ @handler.expects(:exit_handler).never
+
+ @handler.expects(:reload!).never
+ @handler.expects(:close_connection).with(cgi).once
+ @handler.expects(:exit).never
+ @handler.expects(:restart!).once
+
+ @handler.process!
+ assert_equal :restart, @handler.when_ready
+ end
+
+ def test_interrupted_via_TERM
+ cgi = mock
+ FCGI.expects(:each_cgi).once.yields(cgi)
+ Dispatcher.expects(:signal).times(2).returns('TERM')
+
+ @handler.expects(:reload!).never
+ @handler.expects(:close_connection).never
+
+ @handler.process!
+ assert_nil @handler.when_ready
+ end
+
+ def test_runtime_exception_in_fcgi
+ error = RuntimeError.new('foo')
+ FCGI.expects(:each_cgi).times(2).raises(error)
+ @handler.expects(:dispatcher_error).with(error, regexp_matches(/^retrying/))
+ @handler.expects(:dispatcher_error).with(error, regexp_matches(/^stopping/))
+ @handler.process!
+ end
+
+ def test_runtime_error_in_dispatcher
+ cgi = mock
+ error = RuntimeError.new('foo')
+ FCGI.expects(:each_cgi).once.yields(cgi)
+ Dispatcher.expects(:dispatch).once.with(cgi).raises(error)
+ @handler.expects(:dispatcher_error).with(error, regexp_matches(/^unhandled/))
+ @handler.process!
+ end
+
+ def test_signal_exception_in_fcgi
+ error = SignalException.new('USR2')
+ FCGI.expects(:each_cgi).once.raises(error)
+ @handler.expects(:dispatcher_error).with(error, regexp_matches(/^stopping/))
+ @handler.process!
+ end
+
+ def test_signal_exception_in_dispatcher
+ cgi = mock
+ error = SignalException.new('USR2')
+ FCGI.expects(:each_cgi).once.yields(cgi)
+ Dispatcher.expects(:dispatch).once.with(cgi).raises(error)
+ @handler.expects(:dispatcher_error).with(error, regexp_matches(/^stopping/))
+ @handler.process!
+ end
+end
+
+
+class RailsFCGIHandlerPeriodicGCTest < Test::Unit::TestCase
+ def setup
+ @log = StringIO.new
+ end
+
+ def teardown
+ GC.enable
+ end
+
+ def test_normal_gc
+ @handler = RailsFCGIHandler.new(@log)
+ assert_nil @handler.gc_request_period
+
+ # When GC is enabled, GC.disable disables and returns false.
+ assert_equal false, GC.disable
+ end
+
+ def test_periodic_gc
+ @handler = RailsFCGIHandler.new(@log, 10)
+ assert_equal 10, @handler.gc_request_period
+
+ cgi = mock
+ FCGI.expects(:each_cgi).times(10).yields(cgi)
+ Dispatcher.expects(:dispatch).times(10).with(cgi)
+
+ @handler.expects(:run_gc!).never
+ 9.times { @handler.process! }
+ @handler.expects(:run_gc!).once
+ @handler.process!
+
+ assert_nil @handler.when_ready
+ end
+end
+
+end # uses_mocha
diff --git a/vendor/rails-2.1.0/railties/test/fixtures/about_yml_plugins/bad_about_yml/about.yml b/vendor/rails-2.1.0/railties/test/fixtures/about_yml_plugins/bad_about_yml/about.yml
new file mode 100644
index 000000000..fe80872a1
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/fixtures/about_yml_plugins/bad_about_yml/about.yml
@@ -0,0 +1 @@
+# an empty YAML file - any content in here seems to get parsed as a string \ No newline at end of file
diff --git a/vendor/rails-2.1.0/railties/test/fixtures/about_yml_plugins/bad_about_yml/init.rb b/vendor/rails-2.1.0/railties/test/fixtures/about_yml_plugins/bad_about_yml/init.rb
new file mode 100644
index 000000000..d4262f897
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/fixtures/about_yml_plugins/bad_about_yml/init.rb
@@ -0,0 +1 @@
+# intentionally empty \ No newline at end of file
diff --git a/vendor/rails-2.1.0/railties/test/fixtures/about_yml_plugins/plugin_without_about_yml/init.rb b/vendor/rails-2.1.0/railties/test/fixtures/about_yml_plugins/plugin_without_about_yml/init.rb
new file mode 100644
index 000000000..d4262f897
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/fixtures/about_yml_plugins/plugin_without_about_yml/init.rb
@@ -0,0 +1 @@
+# intentionally empty \ No newline at end of file
diff --git a/vendor/rails-2.1.0/railties/test/fixtures/environment_with_constant.rb b/vendor/rails-2.1.0/railties/test/fixtures/environment_with_constant.rb
new file mode 100644
index 000000000..23e1f7afd
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/fixtures/environment_with_constant.rb
@@ -0,0 +1 @@
+$initialize_test_set_from_env = 'success'
diff --git a/vendor/rails-2.1.0/railties/test/fixtures/lib/generators/missing_class/missing_class_generator.rb b/vendor/rails-2.1.0/railties/test/fixtures/lib/generators/missing_class/missing_class_generator.rb
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/fixtures/lib/generators/missing_class/missing_class_generator.rb
diff --git a/vendor/rails-2.1.0/railties/test/fixtures/lib/generators/missing_class/templates/.gitignore b/vendor/rails-2.1.0/railties/test/fixtures/lib/generators/missing_class/templates/.gitignore
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/fixtures/lib/generators/missing_class/templates/.gitignore
diff --git a/vendor/rails-2.1.0/railties/test/fixtures/lib/generators/missing_generator/templates/.gitignore b/vendor/rails-2.1.0/railties/test/fixtures/lib/generators/missing_generator/templates/.gitignore
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/fixtures/lib/generators/missing_generator/templates/.gitignore
diff --git a/vendor/rails-2.1.0/railties/test/fixtures/lib/generators/missing_templates/.gitignore b/vendor/rails-2.1.0/railties/test/fixtures/lib/generators/missing_templates/.gitignore
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/fixtures/lib/generators/missing_templates/.gitignore
diff --git a/vendor/rails-2.1.0/railties/test/fixtures/lib/generators/working/working_generator.rb b/vendor/rails-2.1.0/railties/test/fixtures/lib/generators/working/working_generator.rb
new file mode 100644
index 000000000..465b34319
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/fixtures/lib/generators/working/working_generator.rb
@@ -0,0 +1,2 @@
+class WorkingGenerator < Rails::Generator::NamedBase
+end
diff --git a/vendor/rails-2.1.0/railties/test/fixtures/plugins/alternate/a/generators/a_generator/a_generator.rb b/vendor/rails-2.1.0/railties/test/fixtures/plugins/alternate/a/generators/a_generator/a_generator.rb
new file mode 100644
index 000000000..b33f2dad1
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/fixtures/plugins/alternate/a/generators/a_generator/a_generator.rb
@@ -0,0 +1,4 @@
+class AGenerator < Rails::Generator::Base
+ def manifest
+ end
+end
diff --git a/vendor/rails-2.1.0/railties/test/fixtures/plugins/alternate/a/lib/.gitignore b/vendor/rails-2.1.0/railties/test/fixtures/plugins/alternate/a/lib/.gitignore
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/fixtures/plugins/alternate/a/lib/.gitignore
diff --git a/vendor/rails-2.1.0/railties/test/fixtures/plugins/default/acts/acts_as_chunky_bacon/lib/.gitignore b/vendor/rails-2.1.0/railties/test/fixtures/plugins/default/acts/acts_as_chunky_bacon/lib/.gitignore
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/fixtures/plugins/default/acts/acts_as_chunky_bacon/lib/.gitignore
diff --git a/vendor/rails-2.1.0/railties/test/fixtures/plugins/default/empty/.gitignore b/vendor/rails-2.1.0/railties/test/fixtures/plugins/default/empty/.gitignore
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/fixtures/plugins/default/empty/.gitignore
diff --git a/vendor/rails-2.1.0/railties/test/fixtures/plugins/default/plugin_with_no_lib_dir/init.rb b/vendor/rails-2.1.0/railties/test/fixtures/plugins/default/plugin_with_no_lib_dir/init.rb
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/fixtures/plugins/default/plugin_with_no_lib_dir/init.rb
diff --git a/vendor/rails-2.1.0/railties/test/fixtures/plugins/default/stubby/about.yml b/vendor/rails-2.1.0/railties/test/fixtures/plugins/default/stubby/about.yml
new file mode 100644
index 000000000..d85a7cc0e
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/fixtures/plugins/default/stubby/about.yml
@@ -0,0 +1,2 @@
+author: Plugin Author
+version: 1.0.0 \ No newline at end of file
diff --git a/vendor/rails-2.1.0/railties/test/fixtures/plugins/default/stubby/generators/stubby_generator/stubby_generator.rb b/vendor/rails-2.1.0/railties/test/fixtures/plugins/default/stubby/generators/stubby_generator/stubby_generator.rb
new file mode 100644
index 000000000..8fda8197d
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/fixtures/plugins/default/stubby/generators/stubby_generator/stubby_generator.rb
@@ -0,0 +1,4 @@
+class StubbyGenerator < Rails::Generator::Base
+ def manifest
+ end
+end
diff --git a/vendor/rails-2.1.0/railties/test/fixtures/plugins/default/stubby/init.rb b/vendor/rails-2.1.0/railties/test/fixtures/plugins/default/stubby/init.rb
new file mode 100644
index 000000000..81beeb0d3
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/fixtures/plugins/default/stubby/init.rb
@@ -0,0 +1,7 @@
+# I have access to my directory and the Rails config.
+raise 'directory expected but undefined in init.rb' unless defined? directory
+raise 'config expected but undefined in init.rb' unless defined? config
+
+# My lib/ dir must be in the load path.
+require 'stubby_mixin'
+raise 'missing mixin from my lib/ dir' unless defined? StubbyMixin
diff --git a/vendor/rails-2.1.0/railties/test/fixtures/plugins/default/stubby/lib/stubby_mixin.rb b/vendor/rails-2.1.0/railties/test/fixtures/plugins/default/stubby/lib/stubby_mixin.rb
new file mode 100644
index 000000000..2d569e500
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/fixtures/plugins/default/stubby/lib/stubby_mixin.rb
@@ -0,0 +1,2 @@
+module StubbyMixin
+end
diff --git a/vendor/rails-2.1.0/railties/test/gem_dependency_test.rb b/vendor/rails-2.1.0/railties/test/gem_dependency_test.rb
new file mode 100644
index 000000000..3ae018932
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/gem_dependency_test.rb
@@ -0,0 +1,66 @@
+require 'plugin_test_helper'
+
+class Rails::GemDependency
+ public :install_command, :unpack_command
+end
+
+uses_mocha "Plugin Tests" do
+ class GemDependencyTest < Test::Unit::TestCase
+ def setup
+ @gem = Rails::GemDependency.new "hpricot"
+ @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"
+ end
+
+ def test_configuration_adds_gem_dependency
+ config = Rails::Configuration.new
+ config.gem "aws-s3", :lib => "aws/s3", :version => "0.4.0"
+ assert_equal [["install", "aws-s3", "--version", "= 0.4.0"]], config.gems.collect(&:install_command)
+ end
+
+ def test_gem_creates_install_command
+ assert_equal %w(install hpricot), @gem.install_command
+ end
+
+ def test_gem_with_source_creates_install_command
+ assert_equal %w(install hpricot --source http://code.whytheluckystiff.net), @gem_with_source.install_command
+ end
+
+ def test_gem_with_version_creates_install_command
+ assert_equal ["install", "hpricot", "--version", "= 0.6"], @gem_with_version.install_command
+ end
+
+ def test_gem_creates_unpack_command
+ assert_equal %w(unpack hpricot), @gem.unpack_command
+ end
+
+ def test_gem_with_version_unpack_install_command
+ assert_equal ["unpack", "hpricot", "--version", "= 0.6"], @gem_with_version.unpack_command
+ end
+
+ def test_gem_adds_load_paths
+ @gem.expects(:gem).with(@gem.name)
+ @gem.add_load_paths
+ end
+
+ def test_gem_with_version_adds_load_paths
+ @gem_with_version.expects(:gem).with(@gem_with_version.name, @gem_with_version.requirement.to_s)
+ @gem_with_version.add_load_paths
+ end
+
+ def test_gem_loading
+ @gem.expects(:gem).with(@gem.name)
+ @gem.expects(:require).with(@gem.name)
+ @gem.add_load_paths
+ @gem.load
+ end
+
+ def test_gem_with_lib_loading
+ @gem_with_lib.expects(:gem).with(@gem_with_lib.name)
+ @gem_with_lib.expects(:require).with(@gem_with_lib.lib)
+ @gem_with_lib.add_load_paths
+ @gem_with_lib.load
+ end
+ end
+end \ No newline at end of file
diff --git a/vendor/rails-2.1.0/railties/test/generator_lookup_test.rb b/vendor/rails-2.1.0/railties/test/generator_lookup_test.rb
new file mode 100644
index 000000000..b650f304e
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/generator_lookup_test.rb
@@ -0,0 +1,40 @@
+require 'plugin_test_helper'
+
+class GeneratorLookupTest < Test::Unit::TestCase
+ def setup
+ @fixture_dirs = %w{alternate default}
+ @configuration = Rails.configuration = Rails::Configuration.new
+ # We need to add our testing plugin directory to the plugin paths so
+ # the locator knows where to look for our plugins
+ @configuration.plugin_paths += @fixture_dirs.map{|fd| plugin_fixture_path(fd)}
+ @initializer = Rails::Initializer.new(@configuration)
+ @initializer.add_plugin_load_paths
+ @initializer.load_plugins
+ load 'rails_generator.rb'
+ require 'rails_generator/scripts'
+ end
+
+ def test_should_load_from_all_plugin_paths
+ assert Rails::Generator::Base.lookup('a_generator')
+ assert Rails::Generator::Base.lookup('stubby_generator')
+ end
+
+ def test_should_create_generator_source_for_each_directory_in_plugin_paths
+ sources = Rails::Generator::Base.sources
+ @fixture_dirs.each do |gen_dir|
+ expected_label = "plugins (fixtures/plugins/#{gen_dir})".to_sym
+ assert sources.any? {|source| source.label == expected_label }
+ end
+ end
+
+ def test_should_preserve_order_in_usage_message
+ msg = Rails::Generator::Scripts::Base.new.send(:usage_message)
+ positions = @fixture_dirs.map do |gen_dir|
+ pos = msg.index("Plugins (fixtures/plugins/#{gen_dir})")
+ assert_not_nil pos
+ pos
+ end
+ assert_equal positions.sort, positions
+ end
+
+end
diff --git a/vendor/rails-2.1.0/railties/test/generators/generator_test_helper.rb b/vendor/rails-2.1.0/railties/test/generators/generator_test_helper.rb
new file mode 100644
index 000000000..05dca3400
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/generators/generator_test_helper.rb
@@ -0,0 +1,287 @@
+require 'test/unit'
+require 'fileutils'
+
+# Mock out what we need from AR::Base
+module ActiveRecord
+ class Base
+ class << self
+ attr_accessor :pluralize_table_names
+ end
+ self.pluralize_table_names = true
+ end
+
+ module ConnectionAdapters
+ class Column
+ attr_reader :name, :default, :type, :limit, :null, :sql_type, :precision, :scale
+
+ def initialize(name, default, sql_type = nil)
+ @name = name
+ @default = default
+ @type = @sql_type = sql_type
+ end
+
+ def human_name
+ @name.humanize
+ end
+ end
+ end
+end
+
+# Mock up necessities from ActionView
+module ActionView
+ module Helpers
+ module ActionRecordHelper; end
+ class InstanceTag; end
+ end
+end
+
+# Set RAILS_ROOT appropriately fixture generation
+tmp_dir = "#{File.dirname(__FILE__)}/../fixtures/tmp"
+
+if defined? RAILS_ROOT
+ RAILS_ROOT.replace tmp_dir
+else
+ RAILS_ROOT = tmp_dir
+end
+FileUtils.mkdir_p RAILS_ROOT
+
+$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../lib"
+require 'initializer'
+
+# Mocks out the configuration
+module Rails
+ def self.configuration
+ Rails::Configuration.new
+ end
+end
+
+require 'rails_generator'
+
+class GeneratorTestCase < Test::Unit::TestCase
+ include FileUtils
+
+ def setup
+ ActiveRecord::Base.pluralize_table_names = true
+
+ mkdir_p "#{RAILS_ROOT}/app/views/layouts"
+ mkdir_p "#{RAILS_ROOT}/config"
+ mkdir_p "#{RAILS_ROOT}/db"
+ mkdir_p "#{RAILS_ROOT}/test/fixtures"
+ mkdir_p "#{RAILS_ROOT}/public/stylesheets"
+
+ File.open("#{RAILS_ROOT}/config/routes.rb", 'w') do |f|
+ f << "ActionController::Routing::Routes.draw do |map|\n\nend"
+ end
+ end
+
+ def teardown
+ rm_rf "#{RAILS_ROOT}/app"
+ rm_rf "#{RAILS_ROOT}/test"
+ rm_rf "#{RAILS_ROOT}/config"
+ rm_rf "#{RAILS_ROOT}/db"
+ rm_rf "#{RAILS_ROOT}/public"
+ end
+
+ def test_truth
+ # don't complain, test/unit
+ end
+
+ # Instantiates the Generator.
+ def build_generator(name, params)
+ Rails::Generator::Base.instance(name, params)
+ end
+
+ # Runs the +create+ command (like the command line does).
+ def run_generator(name, params)
+ silence_generator do
+ build_generator(name, params).command(:create).invoke!
+ end
+ end
+
+ # Silences the logger temporarily and returns the output as a String.
+ def silence_generator
+ logger_original = Rails::Generator::Base.logger
+ myout = StringIO.new
+ Rails::Generator::Base.logger = Rails::Generator::SimpleLogger.new(myout)
+ yield if block_given?
+ Rails::Generator::Base.logger = logger_original
+ myout.string
+ end
+
+ # Asserts that the given controller was generated.
+ # It takes a name or symbol without the <tt>_controller</tt> part and an optional super class.
+ # The contents of the class source file is passed to a block.
+ def assert_generated_controller_for(name, parent = "ApplicationController")
+ assert_generated_class "app/controllers/#{name.to_s.underscore}_controller", parent do |body|
+ yield body if block_given?
+ end
+ end
+
+ # Asserts that the given model was generated.
+ # It takes a name or symbol and an optional super class.
+ # The contents of the class source file is passed to a block.
+ def assert_generated_model_for(name, parent = "ActiveRecord::Base")
+ assert_generated_class "app/models/#{name.to_s.underscore}", parent do |body|
+ yield body if block_given?
+ end
+ end
+
+ # Asserts that the given helper was generated.
+ # It takes a name or symbol without the <tt>_helper</tt> part.
+ # The contents of the module source file is passed to a block.
+ def assert_generated_helper_for(name)
+ assert_generated_module "app/helpers/#{name.to_s.underscore}_helper" do |body|
+ yield body if block_given?
+ end
+ end
+
+ # Asserts that the given functional test was generated.
+ # It takes a name or symbol without the <tt>_controller_test</tt> part and an optional super class.
+ # The contents of the class source file is passed to a block.
+ def assert_generated_functional_test_for(name, parent = "ActionController::TestCase")
+ assert_generated_class "test/functional/#{name.to_s.underscore}_controller_test",parent do |body|
+ yield body if block_given?
+ end
+ end
+
+ # Asserts that the given unit test was generated.
+ # It takes a name or symbol without the <tt>_test</tt> part and an optional super class.
+ # The contents of the class source file is passed to a block.
+ def assert_generated_unit_test_for(name, parent = "ActiveSupport::TestCase")
+ assert_generated_class "test/unit/#{name.to_s.underscore}_test", parent do |body|
+ yield body if block_given?
+ end
+ end
+
+ # Asserts that the given file was generated.
+ # The contents of the file is passed to a block.
+ def assert_generated_file(path)
+ assert_file_exists(path)
+ File.open("#{RAILS_ROOT}/#{path}") do |f|
+ yield f.read if block_given?
+ end
+ end
+
+ # asserts that the given file exists
+ def assert_file_exists(path)
+ assert File.exist?("#{RAILS_ROOT}/#{path}"),
+ "The file '#{RAILS_ROOT}/#{path}' should exist"
+ end
+
+ # Asserts that the given class source file was generated.
+ # It takes a path without the <tt>.rb</tt> part and an optional super class.
+ # The contents of the class source file is passed to a block.
+ def assert_generated_class(path, parent = nil)
+ # FIXME: Sucky way to detect namespaced classes
+ if path.split('/').size > 3
+ path =~ /\/?(\d+_)?(\w+)\/(\w+)$/
+ class_name = "#{$2.camelize}::#{$3.camelize}"
+ else
+ path =~ /\/?(\d+_)?(\w+)$/
+ class_name = $2.camelize
+ end
+
+ assert_generated_file("#{path}.rb") do |body|
+ assert_match /class #{class_name}#{parent.nil? ? '':" < #{parent}"}/, body, "the file '#{path}.rb' should be a class"
+ yield body if block_given?
+ end
+ end
+
+ # Asserts that the given module source file was generated.
+ # It takes a path without the <tt>.rb</tt> part.
+ # The contents of the class source file is passed to a block.
+ def assert_generated_module(path)
+ # FIXME: Sucky way to detect namespaced modules
+ if path.split('/').size > 3
+ path =~ /\/?(\w+)\/(\w+)$/
+ module_name = "#{$1.camelize}::#{$2.camelize}"
+ else
+ path =~ /\/?(\w+)$/
+ module_name = $1.camelize
+ end
+
+ assert_generated_file("#{path}.rb") do |body|
+ assert_match /module #{module_name}/, body, "the file '#{path}.rb' should be a module"
+ yield body if block_given?
+ end
+ end
+
+ # Asserts that the given CSS stylesheet file was generated.
+ # It takes a path without the <tt>.css</tt> part.
+ # The contents of the stylesheet source file is passed to a block.
+ def assert_generated_stylesheet(path)
+ assert_generated_file("public/stylesheets/#{path}.css") do |body|
+ yield body if block_given?
+ end
+ end
+
+ # Asserts that the given YAML file was generated.
+ # It takes a path without the <tt>.yml</tt> part.
+ # The parsed YAML tree is passed to a block.
+ def assert_generated_yaml(path)
+ assert_generated_file("#{path}.yml") do |body|
+ yaml = YAML.load(body)
+ assert yaml, 'YAML data missing'
+ yield yaml if block_given?
+ end
+ end
+
+ # Asserts that the given fixtures yaml file was generated.
+ # It takes a fixture name without the <tt>.yml</tt> part.
+ # The parsed YAML tree is passed to a block.
+ def assert_generated_fixtures_for(name)
+ assert_generated_yaml "test/fixtures/#{name.to_s.underscore}" do |yaml|
+ yield yaml if block_given?
+ end
+ end
+
+ # Asserts that the given views were generated.
+ # It takes a controller name and a list of views (including extensions).
+ # The body of each view is passed to a block.
+ def assert_generated_views_for(name, *actions)
+ actions.each do |action|
+ assert_generated_file("app/views/#{name.to_s.underscore}/#{action}") do |body|
+ yield body if block_given?
+ end
+ end
+ end
+
+ def assert_generated_migration(name, parent = "ActiveRecord::Migration")
+ file = Dir.glob("#{RAILS_ROOT}/db/migrate/*_#{name.to_s.underscore}.rb").first
+ file = file.match(/db\/migrate\/[0-9]+_\w+/).to_s
+ assert_generated_class file, parent do |body|
+ assert_match /timestamps/, body, "should have timestamps defined"
+ yield body if block_given?
+ end
+ end
+
+ # Asserts that the given migration file was not generated.
+ # It takes the name of the migration as a parameter.
+ def assert_skipped_migration(name)
+ migration_file = "#{RAILS_ROOT}/db/migrate/001_#{name.to_s.underscore}.rb"
+ assert !File.exist?(migration_file), "should not create migration #{migration_file}"
+ end
+
+ # Asserts that the given resource was added to the routes.
+ def assert_added_route_for(name)
+ assert_generated_file("config/routes.rb") do |body|
+ assert_match /map.resources :#{name.to_s.underscore}/, body,
+ "should add route for :#{name.to_s.underscore}"
+ end
+ end
+
+ # Asserts that the given methods are defined in the body.
+ # This does assume standard rails code conventions with regards to the source code.
+ # The body of each individual method is passed to a block.
+ def assert_has_method(body, *methods)
+ methods.each do |name|
+ assert body =~ /^ def #{name}(\(.+\))?\n((\n| .*\n)*) end/, "should have method #{name}"
+ yield(name, $2) if block_given?
+ end
+ end
+
+ # Asserts that the given column is defined in the migration.
+ def assert_generated_column(body, name, type)
+ assert_match /t\.#{type.to_s} :#{name.to_s}/, body, "should have column #{name.to_s} defined"
+ end
+end
diff --git a/vendor/rails-2.1.0/railties/test/generators/rails_controller_generator_test.rb b/vendor/rails-2.1.0/railties/test/generators/rails_controller_generator_test.rb
new file mode 100644
index 000000000..0090d21b8
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/generators/rails_controller_generator_test.rb
@@ -0,0 +1,20 @@
+require 'generators/generator_test_helper'
+
+class RailsControllerGeneratorTest < GeneratorTestCase
+
+ def test_controller_generates_controller
+ run_generator('controller', %w(products))
+
+ assert_generated_controller_for :products
+ assert_generated_functional_test_for :products
+ assert_generated_helper_for :products
+ end
+
+ def test_controller_generates_namespaced_controller
+ run_generator('controller', %w(admin::products))
+
+ assert_generated_controller_for "admin::products"
+ assert_generated_functional_test_for "admin::products"
+ assert_generated_helper_for "admin::products"
+ end
+end
diff --git a/vendor/rails-2.1.0/railties/test/generators/rails_mailer_generator_test.rb b/vendor/rails-2.1.0/railties/test/generators/rails_mailer_generator_test.rb
new file mode 100644
index 000000000..de61e6736
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/generators/rails_mailer_generator_test.rb
@@ -0,0 +1,29 @@
+require 'generators/generator_test_helper'
+
+class RailsMailerGeneratorTest < GeneratorTestCase
+
+ def test_generates_mailer
+ run_generator('mailer', %w(Notifier reset_password))
+
+ assert_generated_model_for :notifier, 'ActionMailer::Base' do |model|
+ assert_has_method model, :reset_password do |name, body|
+ assert_equal [
+ "subject 'Notifier#reset_password'",
+ "recipients ''",
+ "from ''",
+ "sent_on sent_at",
+ "",
+ "body :greeting => 'Hi,'"
+ ],
+ body.split("\n").map{|line| line.sub(' '*4, '') }
+ end
+
+ assert_no_match /(self.default_url_options =|default_url_options\[.*\] =)/, model,
+ 'individual mailer models should not set default_url_options because the options are shared by all mailers'
+ end
+
+ assert_generated_views_for :notifier, 'reset_password.erb'
+ assert_generated_unit_test_for :notifier, 'ActionMailer::TestCase'
+ assert_generated_file "test/fixtures/notifier/reset_password"
+ end
+end
diff --git a/vendor/rails-2.1.0/railties/test/generators/rails_model_generator_test.rb b/vendor/rails-2.1.0/railties/test/generators/rails_model_generator_test.rb
new file mode 100644
index 000000000..0bfc33856
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/generators/rails_model_generator_test.rb
@@ -0,0 +1,32 @@
+require 'generators/generator_test_helper'
+
+class RailsModelGeneratorTest < GeneratorTestCase
+
+ def test_model_generates_resources
+ run_generator('model', %w(Product name:string))
+
+ assert_generated_model_for :product
+ assert_generated_fixtures_for :products
+ assert_generated_migration :create_products
+ end
+
+ def test_model_skip_migration_skips_migration
+ run_generator('model', %w(Product name:string --skip-migration))
+
+ assert_generated_model_for :product
+ assert_generated_fixtures_for :products
+ assert_skipped_migration :create_products
+ end
+
+ def test_model_with_attributes_generates_resources_with_attributes
+ run_generator('model', %w(Product name:string supplier_id:integer created_at:timestamp))
+
+ assert_generated_model_for :product
+ assert_generated_fixtures_for :products
+ assert_generated_migration :create_products do |t|
+ assert_generated_column t, :name, :string
+ assert_generated_column t, :supplier_id, :integer
+ assert_generated_column t, :created_at, :timestamp
+ end
+ end
+end
diff --git a/vendor/rails-2.1.0/railties/test/generators/rails_resource_generator_test.rb b/vendor/rails-2.1.0/railties/test/generators/rails_resource_generator_test.rb
new file mode 100644
index 000000000..45e4850ef
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/generators/rails_resource_generator_test.rb
@@ -0,0 +1,29 @@
+require 'generators/generator_test_helper'
+
+class RailsResourceGeneratorTest < GeneratorTestCase
+
+ def test_resource_generates_resources
+ run_generator('resource', %w(Product name:string))
+
+ assert_generated_controller_for :products
+ assert_generated_model_for :product
+ assert_generated_fixtures_for :products
+ assert_generated_functional_test_for :products
+ assert_generated_helper_for :products
+ assert_generated_migration :create_products
+ assert_added_route_for :products
+ end
+
+ def test_resource_skip_migration_skips_migration
+ run_generator('resource', %w(Product name:string --skip-migration))
+
+ assert_generated_controller_for :products
+ assert_generated_model_for :product
+ assert_generated_fixtures_for :products
+ assert_generated_functional_test_for :products
+ assert_generated_helper_for :products
+ assert_skipped_migration :create_products
+ assert_added_route_for :products
+ end
+
+end
diff --git a/vendor/rails-2.1.0/railties/test/generators/rails_scaffold_generator_test.rb b/vendor/rails-2.1.0/railties/test/generators/rails_scaffold_generator_test.rb
new file mode 100644
index 000000000..220f9e372
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/generators/rails_scaffold_generator_test.rb
@@ -0,0 +1,107 @@
+require 'generators/generator_test_helper'
+
+class RailsScaffoldGeneratorTest < GeneratorTestCase
+
+ def test_scaffolded_names
+ g = Rails::Generator::Base.instance('scaffold', %w(ProductLine))
+ assert_equal "ProductLines", g.controller_name
+ assert_equal "ProductLines", g.controller_class_name
+ assert_equal "ProductLine", g.controller_singular_name
+ assert_equal "product_lines", g.controller_plural_name
+ assert_equal "product_lines", g.controller_file_name
+ assert_equal "product_lines", g.controller_table_name
+ end
+
+ def test_scaffold_generates_resources
+
+ run_generator('scaffold', %w(Product name:string))
+
+ assert_generated_controller_for :products do |f|
+
+ assert_has_method f, :index do |name, m|
+ assert_match /@products = Product\.find\(:all\)/, m, "#{name} should query products table"
+ end
+
+ assert_has_method f, :show, :edit, :update, :destroy do |name, m|
+ assert_match /@product = Product\.find\(params\[:id\]\)/, m, "#{name.to_s} should query products table"
+ end
+
+ assert_has_method f, :new do |name, m|
+ assert_match /@product = Product\.new/, m, "#{name.to_s} should instantiate a product"
+ end
+
+ assert_has_method f, :create do |name, m|
+ assert_match /@product = Product\.new\(params\[:product\]\)/, m, "#{name.to_s} should instantiate a product"
+ assert_match /format.xml \{ render :xml => @product.errors, :status => :unprocessable_entity \}/, m, "#{name.to_s} should set status to :unprocessable_entity code for xml"
+ end
+
+ end
+
+ assert_generated_model_for :product
+ assert_generated_functional_test_for :products
+ assert_generated_unit_test_for :product
+ assert_generated_fixtures_for :products
+ assert_generated_helper_for :products
+ assert_generated_stylesheet :scaffold
+ assert_generated_views_for :products, "index.html.erb", "new.html.erb", "edit.html.erb", "show.html.erb"
+
+ assert_generated_migration :create_products
+ assert_added_route_for :products
+ end
+
+ def test_scaffold_skip_migration_skips_migration
+ run_generator('scaffold', %w(Product name:string --skip-migration))
+
+ assert_generated_model_for :product
+ assert_generated_functional_test_for :products
+ assert_generated_unit_test_for :product
+ assert_generated_fixtures_for :products
+ assert_generated_helper_for :products
+ assert_generated_stylesheet :scaffold
+ assert_generated_views_for :products, "index.html.erb","new.html.erb","edit.html.erb","show.html.erb"
+ assert_skipped_migration :create_products
+ assert_added_route_for :products
+ end
+
+ def test_scaffold_generates_resources_with_attributes
+ run_generator('scaffold', %w(Product name:string supplier_id:integer created_at:timestamp))
+
+ assert_generated_controller_for :products do |f|
+
+ assert_has_method f, :index do |name, m|
+ assert_match /@products = Product\.find\(:all\)/, m, "#{name} should query products table"
+ end
+
+ assert_has_method f, :show, :edit, :update, :destroy do |name, m|
+ assert_match /@product = Product\.find\(params\[:id\]\)/, m, "#{name.to_s} should query products table"
+ end
+
+ assert_has_method f, :new do |name, m|
+ assert_match /@product = Product\.new/, m, "#{name.to_s} should instantiate a product"
+ end
+
+ assert_has_method f, :create do |name, m|
+ assert_match /@product = Product\.new\(params\[:product\]\)/, m, "#{name.to_s} should instantiate a product"
+ assert_match /format.xml \{ render :xml => @product.errors, :status => :unprocessable_entity \}/, m, "#{name.to_s} should set status to :unprocessable_entity code for xml"
+ end
+
+ end
+
+ assert_generated_model_for :product
+ assert_generated_functional_test_for :products
+ assert_generated_unit_test_for :product
+ assert_generated_fixtures_for :products
+ assert_generated_helper_for :products
+ assert_generated_stylesheet :scaffold
+ assert_generated_views_for :products, "index.html.erb", "new.html.erb", "edit.html.erb", "show.html.erb"
+
+ assert_generated_migration :create_products do |t|
+ assert_generated_column t, :name, :string
+ assert_generated_column t, :supplier_id, :integer
+ assert_generated_column t, :created_at, :timestamp
+ end
+
+ assert_added_route_for :products
+ end
+
+end
diff --git a/vendor/rails-2.1.0/railties/test/initializer_test.rb b/vendor/rails-2.1.0/railties/test/initializer_test.rb
new file mode 100644
index 000000000..0df0164ca
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/initializer_test.rb
@@ -0,0 +1,225 @@
+require 'abstract_unit'
+require 'initializer'
+
+# Mocks out the configuration
+module Rails
+ def self.configuration
+ Rails::Configuration.new
+ end
+end
+
+class ConfigurationMock < Rails::Configuration
+ attr_reader :environment_path
+
+ def initialize(envpath)
+ super()
+ @environment_path = envpath
+ end
+end
+
+class Initializer_load_environment_Test < Test::Unit::TestCase
+
+ def test_load_environment_with_constant
+ config = ConfigurationMock.new("#{File.dirname(__FILE__)}/fixtures/environment_with_constant.rb")
+ assert_nil $initialize_test_set_from_env
+ Rails::Initializer.run(:load_environment, config)
+ assert_equal "success", $initialize_test_set_from_env
+ ensure
+ $initialize_test_set_from_env = nil
+ end
+
+end
+
+class Initializer_after_initialize_with_blocks_environment_Test < Test::Unit::TestCase
+ def setup
+ config = ConfigurationMock.new("")
+ config.after_initialize do
+ $test_after_initialize_block1 = "success"
+ end
+ config.after_initialize do
+ $test_after_initialize_block2 = "congratulations"
+ end
+ assert_nil $test_after_initialize_block1
+ assert_nil $test_after_initialize_block2
+
+ Rails::Initializer.run(:after_initialize, config)
+ end
+
+ def teardown
+ $test_after_initialize_block1 = nil
+ $test_after_initialize_block2 = nil
+ end
+
+ def test_should_have_called_the_first_after_initialize_block
+ assert_equal "success", $test_after_initialize_block1
+ end
+
+ def test_should_have_called_the_second_after_initialize_block
+ assert_equal "congratulations", $test_after_initialize_block2
+ end
+end
+
+class Initializer_after_initialize_with_no_block_environment_Test < Test::Unit::TestCase
+
+ def setup
+ config = ConfigurationMock.new("")
+ config.after_initialize do
+ $test_after_initialize_block1 = "success"
+ end
+ config.after_initialize # don't pass a block, this is what we're testing!
+ config.after_initialize do
+ $test_after_initialize_block2 = "congratulations"
+ end
+ assert_nil $test_after_initialize_block1
+
+ Rails::Initializer.run(:after_initialize, config)
+ end
+
+ def teardown
+ $test_after_initialize_block1 = nil
+ $test_after_initialize_block2 = nil
+ end
+
+ def test_should_have_called_the_first_after_initialize_block
+ assert_equal "success", $test_after_initialize_block1, "should still get set"
+ end
+
+ def test_should_have_called_the_second_after_initialize_block
+ assert_equal "congratulations", $test_after_initialize_block2
+ end
+
+end
+
+uses_mocha 'framework paths' do
+ class ConfigurationFrameworkPathsTests < Test::Unit::TestCase
+ def setup
+ @config = Rails::Configuration.new
+ @config.frameworks.clear
+
+ File.stubs(:directory?).returns(true)
+ @config.stubs(:framework_root_path).returns('')
+ end
+
+ def test_minimal
+ expected = %w(
+ /railties
+ /railties/lib
+ /activesupport/lib
+ )
+ assert_equal expected, @config.framework_paths
+ end
+
+ def test_actioncontroller_or_actionview_add_actionpack
+ @config.frameworks << :action_controller
+ assert_framework_path '/actionpack/lib'
+
+ @config.frameworks = [:action_view]
+ assert_framework_path '/actionpack/lib'
+ end
+
+ def test_paths_for_ar_ares_and_mailer
+ [:active_record, :action_mailer, :active_resource, :action_web_service].each do |framework|
+ @config.frameworks = [framework]
+ assert_framework_path "/#{framework.to_s.gsub('_', '')}/lib"
+ end
+ end
+
+ def test_unknown_framework_raises_error
+ @config.frameworks << :action_foo
+ initializer = Rails::Initializer.new @config
+ initializer.expects(:require).raises(LoadError)
+
+ assert_raise RuntimeError do
+ initializer.send :require_frameworks
+ end
+ end
+
+ protected
+
+ def assert_framework_path(path)
+ assert @config.framework_paths.include?(path),
+ "<#{path.inspect}> not found among <#{@config.framework_paths.inspect}>"
+ end
+ end
+end
+
+uses_mocha "Initializer plugin loading tests" do
+ require File.dirname(__FILE__) + '/plugin_test_helper'
+
+ class InitializerPluginLoadingTests < Test::Unit::TestCase
+ def setup
+ @configuration = Rails::Configuration.new
+ @configuration.plugin_paths << plugin_fixture_root_path
+ @initializer = Rails::Initializer.new(@configuration)
+ @valid_plugin_path = plugin_fixture_path('default/stubby')
+ @empty_plugin_path = plugin_fixture_path('default/empty')
+ end
+
+ def test_no_plugins_are_loaded_if_the_configuration_has_an_empty_plugin_list
+ only_load_the_following_plugins! []
+ @initializer.load_plugins
+ assert_equal [], @initializer.loaded_plugins
+ end
+
+ def test_only_the_specified_plugins_are_located_in_the_order_listed
+ plugin_names = [:plugin_with_no_lib_dir, :acts_as_chunky_bacon]
+ only_load_the_following_plugins! plugin_names
+ load_plugins!
+ assert_plugins plugin_names, @initializer.loaded_plugins
+ end
+
+ def test_all_plugins_are_loaded_when_registered_plugin_list_is_untouched
+ failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
+ load_plugins!
+ assert_plugins [:a, :acts_as_chunky_bacon, :plugin_with_no_lib_dir, :stubby], @initializer.loaded_plugins, failure_tip
+ end
+
+ def test_all_plugins_loaded_when_all_is_used
+ plugin_names = [:stubby, :acts_as_chunky_bacon, :all]
+ only_load_the_following_plugins! plugin_names
+ load_plugins!
+ failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
+ assert_plugins [:stubby, :acts_as_chunky_bacon, :a, :plugin_with_no_lib_dir], @initializer.loaded_plugins, failure_tip
+ end
+
+ def test_all_plugins_loaded_after_all
+ plugin_names = [:stubby, :all, :acts_as_chunky_bacon]
+ only_load_the_following_plugins! plugin_names
+ load_plugins!
+ failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
+ assert_plugins [:stubby, :a, :plugin_with_no_lib_dir, :acts_as_chunky_bacon], @initializer.loaded_plugins, failure_tip
+ end
+
+ def test_plugin_names_may_be_strings
+ plugin_names = ['stubby', 'acts_as_chunky_bacon', :a, :plugin_with_no_lib_dir]
+ only_load_the_following_plugins! plugin_names
+ load_plugins!
+ failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
+ assert_plugins plugin_names, @initializer.loaded_plugins, failure_tip
+ end
+
+ def test_registering_a_plugin_name_that_does_not_exist_raises_a_load_error
+ only_load_the_following_plugins! [:stubby, :acts_as_a_non_existant_plugin]
+ assert_raises(LoadError) do
+ load_plugins!
+ end
+ end
+
+ def test_should_ensure_all_loaded_plugins_load_paths_are_added_to_the_load_path
+ only_load_the_following_plugins! [:stubby, :acts_as_chunky_bacon]
+
+ @initializer.add_plugin_load_paths
+
+ assert $LOAD_PATH.include?(File.join(plugin_fixture_path('default/stubby'), 'lib'))
+ assert $LOAD_PATH.include?(File.join(plugin_fixture_path('default/acts/acts_as_chunky_bacon'), 'lib'))
+ end
+
+ private
+
+ def load_plugins!
+ @initializer.add_plugin_load_paths
+ @initializer.load_plugins
+ end
+ end
+
+end
diff --git a/vendor/rails-2.1.0/railties/test/mocks/routes.rb b/vendor/rails-2.1.0/railties/test/mocks/routes.rb
new file mode 100644
index 000000000..ea1286368
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/mocks/routes.rb
@@ -0,0 +1,6 @@
+module ActionController
+ module Routing
+ class Routes
+ end
+ end
+end
diff --git a/vendor/rails-2.1.0/railties/test/plugin_loader_test.rb b/vendor/rails-2.1.0/railties/test/plugin_loader_test.rb
new file mode 100644
index 000000000..41bd6ec7e
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/plugin_loader_test.rb
@@ -0,0 +1,142 @@
+require 'plugin_test_helper'
+
+# Mocks out the configuration
+module Rails
+ def self.configuration
+ Rails::Configuration.new
+ end
+end
+
+uses_mocha "Plugin Loader Tests" do
+
+ class TestPluginLoader < Test::Unit::TestCase
+ ORIGINAL_LOAD_PATH = $LOAD_PATH.dup
+
+ def setup
+ reset_load_path!
+
+ @configuration = Rails::Configuration.new
+ @configuration.plugin_paths << plugin_fixture_root_path
+ @initializer = Rails::Initializer.new(@configuration)
+ @valid_plugin_path = plugin_fixture_path('default/stubby')
+ @empty_plugin_path = plugin_fixture_path('default/empty')
+
+ @failure_tip = "It's likely someone has added a new plugin fixture without updating this list"
+
+ @loader = Rails::Plugin::Loader.new(@initializer)
+ end
+
+ def test_should_locate_plugins_by_asking_each_locator_specifed_in_configuration_for_its_plugins_result
+ locator_1 = stub(:plugins => [:a, :b, :c])
+ locator_2 = stub(:plugins => [:d, :e, :f])
+ locator_class_1 = stub(:new => locator_1)
+ locator_class_2 = stub(:new => locator_2)
+ @configuration.plugin_locators = [locator_class_1, locator_class_2]
+ assert_equal [:a, :b, :c, :d, :e, :f], @loader.send(:locate_plugins)
+ end
+
+ def test_should_memoize_the_result_of_locate_plugins_as_all_plugins
+ plugin_list = [:a, :b, :c]
+ @loader.expects(:locate_plugins).once.returns(plugin_list)
+ assert_equal plugin_list, @loader.all_plugins
+ assert_equal plugin_list, @loader.all_plugins # ensuring that locate_plugins isn't called again
+ end
+
+ def test_should_return_empty_array_if_configuration_plugins_is_empty
+ @configuration.plugins = []
+ assert_equal [], @loader.plugins
+ end
+
+ def test_should_find_all_availble_plugins_and_return_as_all_plugins
+ assert_plugins [:stubby, :plugin_with_no_lib_dir, :acts_as_chunky_bacon, :a], @loader.all_plugins.reverse, @failure_tip
+ end
+
+ def test_should_return_all_plugins_as_plugins_when_registered_plugin_list_is_untouched
+ assert_plugins [:a, :acts_as_chunky_bacon, :plugin_with_no_lib_dir, :stubby], @loader.plugins, @failure_tip
+ end
+
+ def test_should_return_all_plugins_as_plugins_when_registered_plugin_list_is_nil
+ @configuration.plugins = nil
+ assert_plugins [:a, :acts_as_chunky_bacon, :plugin_with_no_lib_dir, :stubby], @loader.plugins, @failure_tip
+ end
+
+ def test_should_return_specific_plugins_named_in_config_plugins_array_if_set
+ plugin_names = [:acts_as_chunky_bacon, :stubby]
+ only_load_the_following_plugins! plugin_names
+ assert_plugins plugin_names, @loader.plugins
+ end
+
+ def test_should_respect_the_order_of_plugins_given_in_configuration
+ plugin_names = [:stubby, :acts_as_chunky_bacon]
+ only_load_the_following_plugins! plugin_names
+ assert_plugins plugin_names, @loader.plugins
+ end
+
+ def test_should_load_all_plugins_in_natural_order_when_all_is_used
+ only_load_the_following_plugins! [:all]
+ assert_plugins [:a, :acts_as_chunky_bacon, :plugin_with_no_lib_dir, :stubby], @loader.plugins, @failure_tip
+ end
+
+ def test_should_load_specified_plugins_in_order_and_then_all_remaining_plugins_when_all_is_used
+ only_load_the_following_plugins! [:stubby, :acts_as_chunky_bacon, :all]
+ assert_plugins [:stubby, :acts_as_chunky_bacon, :a, :plugin_with_no_lib_dir], @loader.plugins, @failure_tip
+ end
+
+ def test_should_be_able_to_specify_loading_of_plugins_loaded_after_all
+ only_load_the_following_plugins! [:stubby, :all, :acts_as_chunky_bacon]
+ assert_plugins [:stubby, :a, :plugin_with_no_lib_dir, :acts_as_chunky_bacon], @loader.plugins, @failure_tip
+ end
+
+ def test_should_accept_plugin_names_given_as_strings
+ only_load_the_following_plugins! ['stubby', 'acts_as_chunky_bacon', :a, :plugin_with_no_lib_dir]
+ assert_plugins [:stubby, :acts_as_chunky_bacon, :a, :plugin_with_no_lib_dir], @loader.plugins, @failure_tip
+ end
+
+ def test_should_add_plugin_load_paths_to_global_LOAD_PATH_array
+ only_load_the_following_plugins! [:stubby, :acts_as_chunky_bacon]
+ stubbed_application_lib_index_in_LOAD_PATHS = 5
+ @loader.stubs(:application_lib_index).returns(stubbed_application_lib_index_in_LOAD_PATHS)
+
+ @loader.add_plugin_load_paths
+
+ assert $LOAD_PATH.index(File.join(plugin_fixture_path('default/stubby'), 'lib')) >= stubbed_application_lib_index_in_LOAD_PATHS
+ assert $LOAD_PATH.index(File.join(plugin_fixture_path('default/acts/acts_as_chunky_bacon'), 'lib')) >= stubbed_application_lib_index_in_LOAD_PATHS
+ end
+
+ def test_should_add_plugin_load_paths_to_Dependencies_load_paths
+ only_load_the_following_plugins! [:stubby, :acts_as_chunky_bacon]
+
+ @loader.add_plugin_load_paths
+
+ assert Dependencies.load_paths.include?(File.join(plugin_fixture_path('default/stubby'), 'lib'))
+ assert Dependencies.load_paths.include?(File.join(plugin_fixture_path('default/acts/acts_as_chunky_bacon'), 'lib'))
+ end
+
+ def test_should_add_plugin_load_paths_to_Dependencies_load_once_paths
+ only_load_the_following_plugins! [:stubby, :acts_as_chunky_bacon]
+
+ @loader.add_plugin_load_paths
+
+ assert Dependencies.load_once_paths.include?(File.join(plugin_fixture_path('default/stubby'), 'lib'))
+ assert Dependencies.load_once_paths.include?(File.join(plugin_fixture_path('default/acts/acts_as_chunky_bacon'), 'lib'))
+ end
+
+ def test_should_add_all_load_paths_from_a_plugin_to_LOAD_PATH_array
+ plugin_load_paths = ["a", "b"]
+ plugin = stub(:load_paths => plugin_load_paths)
+ @loader.stubs(:plugins).returns([plugin])
+
+ @loader.add_plugin_load_paths
+
+ plugin_load_paths.each { |path| assert $LOAD_PATH.include?(path) }
+ end
+
+ private
+
+ def reset_load_path!
+ $LOAD_PATH.clear
+ ORIGINAL_LOAD_PATH.each { |path| $LOAD_PATH << path }
+ end
+ end
+
+end
diff --git a/vendor/rails-2.1.0/railties/test/plugin_locator_test.rb b/vendor/rails-2.1.0/railties/test/plugin_locator_test.rb
new file mode 100644
index 000000000..5f1dd991e
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/plugin_locator_test.rb
@@ -0,0 +1,69 @@
+require 'plugin_test_helper'
+
+uses_mocha "Plugin Locator Tests" do
+
+ class PluginLocatorTest < Test::Unit::TestCase
+
+ def test_should_require_subclasses_to_implement_the_plugins_method
+ assert_raises(RuntimeError) do
+ Rails::Plugin::Locator.new(nil).plugins
+ end
+ end
+
+ def test_should_iterator_over_plugins_returned_by_plugins_when_calling_each
+ locator = Rails::Plugin::Locator.new(nil)
+ locator.stubs(:plugins).returns([:a, :b, :c])
+ plugin_consumer = mock
+ plugin_consumer.expects(:consume).with(:a)
+ plugin_consumer.expects(:consume).with(:b)
+ plugin_consumer.expects(:consume).with(:c)
+
+ locator.each do |plugin|
+ plugin_consumer.consume(plugin)
+ end
+ end
+
+ end
+
+
+ class PluginFileSystemLocatorTest < Test::Unit::TestCase
+ def setup
+ @configuration = Rails::Configuration.new
+ # We need to add our testing plugin directory to the plugin paths so
+ # the locator knows where to look for our plugins
+ @configuration.plugin_paths << plugin_fixture_root_path
+ @initializer = Rails::Initializer.new(@configuration)
+ @locator = Rails::Plugin::FileSystemLocator.new(@initializer)
+ @valid_plugin_path = plugin_fixture_path('default/stubby')
+ @empty_plugin_path = plugin_fixture_path('default/empty')
+ end
+
+ def test_should_return_rails_plugin_instances_when_calling_create_plugin_with_a_valid_plugin_directory
+ assert_kind_of Rails::Plugin, @locator.send(:create_plugin, @valid_plugin_path)
+ end
+
+ def test_should_return_nil_when_calling_create_plugin_with_an_invalid_plugin_directory
+ assert_nil @locator.send(:create_plugin, @empty_plugin_path)
+ end
+
+ def test_should_return_all_plugins_found_under_the_set_plugin_paths
+ assert_equal ["a", "acts_as_chunky_bacon", "plugin_with_no_lib_dir", "stubby"].sort, @locator.plugins.map(&:name).sort
+ end
+
+ def test_should_find_plugins_only_under_the_plugin_paths_set_in_configuration
+ @configuration.plugin_paths = [File.join(plugin_fixture_root_path, "default")]
+ assert_equal ["acts_as_chunky_bacon", "plugin_with_no_lib_dir", "stubby"].sort, @locator.plugins.map(&:name).sort
+
+ @configuration.plugin_paths = [File.join(plugin_fixture_root_path, "alternate")]
+ assert_equal ["a"], @locator.plugins.map(&:name)
+ end
+
+ def test_should_not_raise_any_error_and_return_no_plugins_if_the_plugin_path_value_does_not_exist
+ @configuration.plugin_paths = ["some_missing_directory"]
+ assert_nothing_raised do
+ assert @locator.plugins.empty?
+ end
+ end
+ end
+
+end # uses_mocha
diff --git a/vendor/rails-2.1.0/railties/test/plugin_test.rb b/vendor/rails-2.1.0/railties/test/plugin_test.rb
new file mode 100644
index 000000000..1445338f1
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/plugin_test.rb
@@ -0,0 +1,159 @@
+require 'plugin_test_helper'
+
+uses_mocha "Plugin Tests" do
+
+ class PluginTest < Test::Unit::TestCase
+
+ def setup
+ @initializer = Rails::Initializer.new(Rails::Configuration.new)
+ @valid_plugin_path = plugin_fixture_path('default/stubby')
+ @empty_plugin_path = plugin_fixture_path('default/empty')
+ end
+
+ def test_should_determine_plugin_name_from_the_directory_of_the_plugin
+ assert_equal 'stubby', plugin_for(@valid_plugin_path).name
+ assert_equal 'empty', plugin_for(@empty_plugin_path).name
+ end
+
+ def test_should_not_be_loaded_when_created
+ assert !plugin_for(@valid_plugin_path).loaded?
+ end
+
+ def test_should_be_marked_as_loaded_when_load_is_called
+ plugin = plugin_for(@valid_plugin_path)
+ assert !plugin.loaded?
+ plugin.stubs(:evaluate_init_rb)
+ assert_nothing_raised do
+ plugin.send(:load, anything)
+ end
+ assert plugin.loaded?
+ end
+
+ def test_should_determine_validity_of_given_path
+ # This is a plugin path, with a lib dir
+ assert plugin_for(@valid_plugin_path).valid?
+ # This just has an init.rb and no lib dir
+ assert plugin_for(plugin_fixture_path('default/plugin_with_no_lib_dir')).valid?
+ # This would be a plugin path, but the directory is empty
+ assert !plugin_for(plugin_fixture_path('default/empty')).valid?
+ # This is a non sense path
+ assert !plugin_for(plugin_fixture_path('default/this_directory_does_not_exist')).valid?
+ end
+
+ def test_should_return_empty_array_for_load_paths_when_plugin_has_no_lib_directory
+ assert_equal [], plugin_for(plugin_fixture_path('default/plugin_with_no_lib_dir')).load_paths
+ end
+
+ def test_should_return_array_with_lib_path_for_load_paths_when_plugin_has_a_lib_directory
+ expected_lib_dir = File.join(plugin_fixture_path('default/stubby'), 'lib')
+ assert_equal [expected_lib_dir], plugin_for(plugin_fixture_path('default/stubby')).load_paths
+ end
+
+ def test_should_raise_a_load_error_when_trying_to_determine_the_load_paths_from_an_invalid_plugin
+ assert_nothing_raised do
+ plugin_for(@valid_plugin_path).load_paths
+ end
+
+ assert_raises(LoadError) do
+ plugin_for(@empty_plugin_path).load_paths
+ end
+
+ assert_raises(LoadError) do
+ plugin_for('this_is_not_a_plugin_directory').load_paths
+ end
+ end
+
+ def test_should_raise_a_load_error_when_trying_to_load_an_invalid_plugin
+ # This path is fine so nothing is raised
+ assert_nothing_raised do
+ plugin = plugin_for(@valid_plugin_path)
+ plugin.stubs(:evaluate_init_rb)
+ plugin.send(:load, @initializer)
+ end
+
+ # This is an empty path so it raises
+ assert_raises(LoadError) do
+ plugin = plugin_for(@empty_plugin_path)
+ plugin.stubs(:evaluate_init_rb)
+ plugin.send(:load, @initializer)
+ end
+
+ assert_raises(LoadError) do
+ plugin = plugin_for('this_is_not_a_plugin_directory')
+ plugin.stubs(:evaluate_init_rb)
+ plugin.send(:load, @initializer)
+ end
+ end
+
+ def test_should_raise_a_load_error_when_trying_to_access_load_paths_of_an_invalid_plugin
+ # This path is fine so nothing is raised
+ assert_nothing_raised do
+ plugin_for(@valid_plugin_path).load_paths
+ end
+
+ # This is an empty path so it raises
+ assert_raises(LoadError) do
+ plugin_for(@empty_plugin_path).load_paths
+ end
+
+ assert_raises(LoadError) do
+ plugin_for('this_is_not_a_plugin_directory').load_paths
+ end
+ end
+
+ def test_loading_a_plugin_gives_the_init_file_access_to_all_it_needs
+ failure_tip = "Perhaps someone has written another test that loads this same plugin and therefore makes the StubbyMixin constant defined already."
+ assert !defined?(StubbyMixin), failure_tip
+ plugin = plugin_for(@valid_plugin_path)
+ plugin.load_paths.each { |path| $LOAD_PATH.unshift(path) }
+ # The init.rb of this plugin raises if it doesn't have access to all the things it needs
+ assert_nothing_raised do
+ plugin.load(@initializer)
+ end
+ assert defined?(StubbyMixin)
+ end
+
+ def test_should_sort_naturally_by_name
+ a = plugin_for("path/a")
+ b = plugin_for("path/b")
+ z = plugin_for("path/z")
+ assert_equal [a, b, z], [b, z, a].sort
+ end
+
+ def test_should_only_be_loaded_once
+ plugin = plugin_for(@valid_plugin_path)
+ assert !plugin.loaded?
+ plugin.expects(:evaluate_init_rb)
+ assert_nothing_raised do
+ plugin.send(:load, @initializer)
+ plugin.send(:load, @initializer)
+ end
+ assert plugin.loaded?
+ end
+
+ def test_should_make_about_yml_available_as_about_method_on_plugin
+ plugin = plugin_for(@valid_plugin_path)
+ assert_equal "Plugin Author", plugin.about['author']
+ assert_equal "1.0.0", plugin.about['version']
+ end
+
+ def test_should_return_empty_hash_for_about_if_about_yml_is_missing
+ assert_equal({}, plugin_for(about_yml_plugin_path('plugin_without_about_yaml')).about)
+ end
+
+ def test_should_return_empty_hash_for_about_if_about_yml_is_malformed
+ assert_equal({}, plugin_for(about_yml_plugin_path('bad_about_yml')).about)
+ end
+
+ private
+
+ def about_yml_plugin_path(name)
+ File.join(File.dirname(__FILE__), 'fixtures', 'about_yml_plugins', name)
+ end
+
+ def plugin_for(path)
+ Rails::Plugin.new(path)
+ end
+ end
+
+end # uses_mocha
diff --git a/vendor/rails-2.1.0/railties/test/plugin_test_helper.rb b/vendor/rails-2.1.0/railties/test/plugin_test_helper.rb
new file mode 100644
index 000000000..f8c094d19
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/plugin_test_helper.rb
@@ -0,0 +1,29 @@
+$:.unshift File.dirname(__FILE__) + "/../lib"
+$:.unshift File.dirname(__FILE__) + "/../../activesupport/lib"
+
+require 'test/unit'
+require 'active_support'
+require 'initializer'
+require File.join(File.dirname(__FILE__), 'abstract_unit')
+
+# We need to set RAILS_ROOT if it isn't already set
+RAILS_ROOT = '.' unless defined?(RAILS_ROOT)
+
+class Test::Unit::TestCase
+ private
+ def plugin_fixture_root_path
+ File.join(File.dirname(__FILE__), 'fixtures', 'plugins')
+ end
+
+ def only_load_the_following_plugins!(plugins)
+ @initializer.configuration.plugins = plugins
+ end
+
+ def plugin_fixture_path(path)
+ File.join(plugin_fixture_root_path, path)
+ end
+
+ def assert_plugins(list_of_names, array_of_plugins, message=nil)
+ assert_equal list_of_names.map(&:to_s), array_of_plugins.map(&:name), message
+ end
+end \ No newline at end of file
diff --git a/vendor/rails-2.1.0/railties/test/rails_generator_test.rb b/vendor/rails-2.1.0/railties/test/rails_generator_test.rb
new file mode 100644
index 000000000..b2fc2f585
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/rails_generator_test.rb
@@ -0,0 +1,145 @@
+require 'test/unit'
+
+# Optionally load RubyGems.
+begin
+ require 'rubygems'
+rescue LoadError
+end
+
+# Mock out what we need from AR::Base.
+module ActiveRecord
+ class Base
+ class << self
+ attr_accessor :pluralize_table_names
+ end
+ self.pluralize_table_names = true
+ end
+end
+
+# And what we need from ActionView
+module ActionView
+ module Helpers
+ module ActiveRecordHelper; end
+ class InstanceTag; end
+ end
+end
+
+
+# Must set before requiring generator libs.
+if defined?(RAILS_ROOT)
+ RAILS_ROOT.replace "#{File.dirname(__FILE__)}/fixtures"
+else
+ RAILS_ROOT = "#{File.dirname(__FILE__)}/fixtures"
+end
+
+$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
+require 'initializer'
+
+# Mocks out the configuration
+module Rails
+ def self.configuration
+ Rails::Configuration.new
+ end
+end
+
+require 'rails_generator'
+
+class RailsGeneratorTest < Test::Unit::TestCase
+ BUILTINS = %w(controller integration_test mailer migration model observer plugin resource scaffold session_migration)
+ CAPITALIZED_BUILTINS = BUILTINS.map { |b| b.capitalize }
+
+ def setup
+ ActiveRecord::Base.pluralize_table_names = true
+ end
+
+ def test_sources
+ expected = [:lib, :vendor,
+ "plugins (vendor/plugins)".to_sym, # <plugin>/generators and <plugin>/rails_generators
+ :user,
+ :RubyGems, :RubyGems, # gems named <x>_generator, gems containing /rails_generator/ folder
+ :builtin]
+ expected.delete(:RubyGems) unless Object.const_defined?(:Gem)
+ assert_equal expected, Rails::Generator::Base.sources.map { |s| s.label }
+ end
+
+ def test_lookup_builtins
+ (BUILTINS + CAPITALIZED_BUILTINS).each do |name|
+ assert_nothing_raised do
+ spec = Rails::Generator::Base.lookup(name)
+ assert_not_nil spec
+ assert_kind_of Rails::Generator::Spec, spec
+
+ klass = spec.klass
+ assert klass < Rails::Generator::Base
+ assert_equal spec, klass.spec
+ end
+ end
+ end
+
+ def test_autolookup
+ assert_nothing_raised { ControllerGenerator }
+ assert_nothing_raised { ModelGenerator }
+ end
+
+ def test_lookup_missing_generator
+ assert_raise Rails::Generator::GeneratorError do
+ Rails::Generator::Base.lookup('missing').klass
+ end
+ end
+
+ def test_lookup_missing_class
+ spec = nil
+ assert_nothing_raised { spec = Rails::Generator::Base.lookup('missing_class') }
+ assert_not_nil spec
+ assert_kind_of Rails::Generator::Spec, spec
+ assert_raise(NameError) { spec.klass }
+ end
+
+ def test_generator_usage
+ (BUILTINS - ["session_migration"]).each do |name|
+ assert_raise(Rails::Generator::UsageError, "Generator '#{name}' should raise an error without arguments") {
+ Rails::Generator::Base.instance(name)
+ }
+ end
+ end
+
+ def test_generator_spec
+ spec = Rails::Generator::Base.lookup('working')
+ assert_equal 'working', spec.name
+ assert_match(/#{spec.path}$/, "#{RAILS_ROOT}/lib/generators/working")
+ assert_equal :lib, spec.source
+ assert_nothing_raised { assert_match(/WorkingGenerator$/, spec.klass.name) }
+ end
+
+ def test_named_generator_attributes
+ g = Rails::Generator::Base.instance('working', %w(admin/foo bar baz))
+ assert_equal 'admin/foo', g.name
+ assert_equal %w(admin), g.class_path
+ assert_equal 'Admin', g.class_nesting
+ assert_equal 'Admin::Foo', g.class_name
+ assert_equal 'foo', g.singular_name
+ assert_equal 'foos', g.plural_name
+ assert_equal g.singular_name, g.file_name
+ assert_equal "admin_#{g.plural_name}", g.table_name
+ assert_equal %w(bar baz), g.args
+ end
+
+ def test_named_generator_attributes_without_pluralized
+ ActiveRecord::Base.pluralize_table_names = false
+ g = Rails::Generator::Base.instance('working', %w(admin/foo bar baz))
+ assert_equal "admin_#{g.singular_name}", g.table_name
+ end
+
+ def test_session_migration_generator_with_pluralization
+ g = Rails::Generator::Base.instance('session_migration')
+ assert_equal 'session'.pluralize, g.send(:default_session_table_name)
+ ActiveRecord::Base.pluralize_table_names = false
+ assert_equal 'session', g.send(:default_session_table_name)
+ end
+
+ def test_scaffold_controller_name
+ # Default behaviour is use the model name
+ g = Rails::Generator::Base.instance('scaffold', %w(Product))
+ assert_equal "Products", g.controller_name
+ end
+end
diff --git a/vendor/rails-2.1.0/railties/test/rails_info_controller_test.rb b/vendor/rails-2.1.0/railties/test/rails_info_controller_test.rb
new file mode 100644
index 000000000..17c7d9dee
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/rails_info_controller_test.rb
@@ -0,0 +1,48 @@
+require 'abstract_unit'
+require 'action_controller'
+require 'action_controller/test_process'
+
+module Rails; end
+require 'rails/info'
+require 'rails/info_controller'
+
+class Rails::InfoController < ActionController::Base
+ @local_request = false
+ class << self
+ cattr_accessor :local_request
+ end
+
+ # Re-raise errors caught by the controller.
+ def rescue_action(e) raise e end;
+
+protected
+ def local_request?
+ self.class.local_request
+ end
+end
+
+ActionController::Routing::Routes.draw do |map|
+ map.connect ':controller/:action/:id'
+end
+
+class Rails::InfoControllerTest < Test::Unit::TestCase
+ def setup
+ @controller = Rails::InfoController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ end
+
+ def test_rails_info_properties_table_rendered_for_local_request
+ Rails::InfoController.local_request = true
+ get :properties
+ assert_tag :tag => 'table'
+ assert_response :success
+ end
+
+ def test_rails_info_properties_error_rendered_for_non_local_request
+ Rails::InfoController.local_request = false
+ get :properties
+ assert_tag :tag => 'p'
+ assert_response 500
+ end
+end
diff --git a/vendor/rails-2.1.0/railties/test/rails_info_test.rb b/vendor/rails-2.1.0/railties/test/rails_info_test.rb
new file mode 100644
index 000000000..3e91e2f2e
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/rails_info_test.rb
@@ -0,0 +1,99 @@
+$:.unshift File.dirname(__FILE__) + "/../lib"
+$:.unshift File.dirname(__FILE__) + "/../builtin/rails_info"
+$:.unshift File.dirname(__FILE__) + "/../../activesupport/lib"
+
+require 'test/unit'
+require 'active_support'
+
+unless defined?(Rails) && defined?(Rails::Info)
+ module Rails
+ class Info; end
+ end
+end
+
+class InfoTest < Test::Unit::TestCase
+ def setup
+ Rails.send :remove_const, :Info
+ silence_warnings { load 'rails/info.rb' }
+ end
+
+ def test_edge_rails_revision_not_set_when_svn_info_is_empty
+ Rails::Info.property 'Test that this will not be defined' do
+ Rails::Info.edge_rails_revision ''
+ end
+ assert !property_defined?('Test that this will not be defined')
+ end
+
+ def test_edge_rails_revision_extracted_from_svn_info
+ Rails::Info.property 'Test Edge Rails revision' do
+ Rails::Info.edge_rails_revision <<-EOS
+ commit 420c4b3d8878156d04f45e47050ddc62ae00c68c
+ Author: David Heinemeier Hansson <david@loudthinking.com>
+ Date: Sun Apr 13 17:33:27 2008 -0500
+
+ Added Rails.public_path to control where HTML and assets are expected to be loaded from
+EOS
+ end
+
+ assert_property 'Test Edge Rails revision', '420c4b3d8878156d04f45e47050ddc62ae00c68c'
+ end
+
+ def test_property_with_block_swallows_exceptions_and_ignores_property
+ assert_nothing_raised do
+ Rails::Info.module_eval do
+ property('Bogus') {raise}
+ end
+ end
+ assert !property_defined?('Bogus')
+ end
+
+ def test_property_with_string
+ Rails::Info.module_eval do
+ property 'Hello', 'World'
+ end
+ assert_property 'Hello', 'World'
+ end
+
+ def test_property_with_block
+ Rails::Info.module_eval do
+ property('Goodbye') {'World'}
+ end
+ assert_property 'Goodbye', 'World'
+ end
+
+ def test_component_version
+ assert_property 'Active Support version', ActiveSupport::VERSION::STRING
+ end
+
+ def test_components_exist
+ Rails::Info.components.each do |component|
+ dir = File.dirname(__FILE__) + "/../../" + component.gsub('_', '')
+ assert File.directory?(dir), "#{component.classify} does not exist"
+ end
+ end
+
+ protected
+ def svn_info=(info)
+ Rails::Info.module_eval do
+ class << self
+ def svn_info
+ info
+ end
+ end
+ end
+ end
+
+ def properties
+ Rails::Info.properties
+ end
+
+ def property_defined?(property_name)
+ properties.names.include? property_name
+ end
+
+ def assert_property(property_name, value)
+ raise "Property #{property_name.inspect} not defined" unless
+ property_defined? property_name
+ assert_equal value, properties.value_for(property_name)
+ end
+end
diff --git a/vendor/rails-2.1.0/railties/test/secret_key_generation_test.rb b/vendor/rails-2.1.0/railties/test/secret_key_generation_test.rb
new file mode 100644
index 000000000..ea1b0dae3
--- /dev/null
+++ b/vendor/rails-2.1.0/railties/test/secret_key_generation_test.rb
@@ -0,0 +1,44 @@
+require 'test/unit'
+
+# Must set before requiring generator libs.
+if defined?(RAILS_ROOT)
+ RAILS_ROOT.replace "#{File.dirname(__FILE__)}/fixtures"
+else
+ RAILS_ROOT = "#{File.dirname(__FILE__)}/fixtures"
+end
+
+$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
+
+require 'initializer'
+
+# Mocks out the configuration
+module Rails
+ def self.configuration
+ Rails::Configuration.new
+ end
+end
+
+require 'rails_generator'
+require 'rails_generator/secret_key_generator'
+require 'rails_generator/generators/applications/app/app_generator'
+
+class SecretKeyGenerationTest < Test::Unit::TestCase
+ SECRET_KEY_MIN_LENGTH = 128
+ APP_NAME = "foo"
+
+ def setup
+ @generator = Rails::SecretKeyGenerator.new(APP_NAME)
+ 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
+ end
+ end
+end