diff options
author | Mikel Lindsaar <raasdnil@gmail.com> | 2010-02-02 13:30:08 +1100 |
---|---|---|
committer | Mikel Lindsaar <raasdnil@gmail.com> | 2010-02-02 13:30:08 +1100 |
commit | 535ae3b946b387af7eb6cb4bb4aed3d5cac1cf81 (patch) | |
tree | dcbd2acf8e83493eea719bf0a0c51a9c121bf194 /railties/test | |
parent | 49a26c533366eff63acd3c99ed0dffc04f85f55c (diff) | |
parent | 9b5dae7af5757769c1e69d74a59ff036adc1f30f (diff) | |
download | rails-535ae3b946b387af7eb6cb4bb4aed3d5cac1cf81.tar.gz rails-535ae3b946b387af7eb6cb4bb4aed3d5cac1cf81.tar.bz2 rails-535ae3b946b387af7eb6cb4bb4aed3d5cac1cf81.zip |
Merge branch 'master' of github.com:lifo/docrails
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/abstract_unit.rb | 12 | ||||
-rw-r--r-- | railties/test/application/configuration_test.rb | 2 | ||||
-rw-r--r-- | railties/test/application/generators_test.rb | 13 | ||||
-rw-r--r-- | railties/test/application/middleware_test.rb | 2 | ||||
-rw-r--r-- | railties/test/initializable_test.rb | 2 | ||||
-rw-r--r-- | railties/test/isolation/abstract_unit.rb | 26 | ||||
-rw-r--r-- | railties/test/rails_info_controller_test.rb | 8 |
7 files changed, 28 insertions, 37 deletions
diff --git a/railties/test/abstract_unit.rb b/railties/test/abstract_unit.rb index 77ef82856a..aa66dbb9be 100644 --- a/railties/test/abstract_unit.rb +++ b/railties/test/abstract_unit.rb @@ -1,15 +1,7 @@ ORIG_ARGV = ARGV.dup -root = File.expand_path('../../..', __FILE__) -begin - require "#{root}/vendor/gems/environment" -rescue LoadError - %w(activesupport activemodel activerecord actionpack actionmailer activeresource railties).each do |lib| - $:.unshift "#{root}/#{lib}/lib" - end -end - -$:.unshift "#{root}/railties/builtin/rails_info" +require File.expand_path("../../../load_paths", __FILE__) +$:.unshift File.expand_path("../../builtin/rails_info", __FILE__) require 'stringio' require 'test/unit' diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 60d644bd59..56f45582c8 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -93,7 +93,7 @@ module ApplicationTests RUBY require "#{app_path}/config/application" - assert AppTemplate::Application.config.action_controller.allow_concurrency + assert AppTemplate::Application.config.allow_concurrency end test "the application can be marked as threadsafe when there are no frameworks" do diff --git a/railties/test/application/generators_test.rb b/railties/test/application/generators_test.rb index e54edea07c..25fa100275 100644 --- a/railties/test/application/generators_test.rb +++ b/railties/test/application/generators_test.rb @@ -30,6 +30,7 @@ module ApplicationTests assert_equal(true, c.generators.colorize_logging) assert_equal({}, c.generators.aliases) assert_equal({}, c.generators.options) + assert_equal({}, c.generators.fallbacks) end end @@ -51,11 +52,20 @@ module ApplicationTests end end - test "generators aliases and options on initialization" do + test "generators set rails fallbacks" do + with_config do |c| + c.generators.fallbacks[:shoulda] = :test_unit + expected = { :shoulda => :test_unit } + assert_equal expected, c.generators.fallbacks + end + end + + test "generators aliases, options and fallbacks on initialization" do add_to_config <<-RUBY config.generators.rails :aliases => { :test_framework => "-w" } config.generators.orm :datamapper config.generators.test_framework :rspec + config.generators.fallbacks[:shoulda] = :test_unit RUBY # Initialize the application @@ -65,6 +75,7 @@ module ApplicationTests assert_equal :rspec, Rails::Generators.options[:rails][:test_framework] assert_equal "-w", Rails::Generators.aliases[:rails][:test_framework] + assert_equal :test_unit, Rails::Generators.fallbacks[:shoulda] end test "generators no color on initialization" do diff --git a/railties/test/application/middleware_test.rb b/railties/test/application/middleware_test.rb index 0b92cdba54..ce9cd510a3 100644 --- a/railties/test/application/middleware_test.rb +++ b/railties/test/application/middleware_test.rb @@ -39,7 +39,7 @@ module ApplicationTests end test "removes lock if allow concurrency is set" do - add_to_config "config.action_controller.allow_concurrency = true" + add_to_config "config.allow_concurrency = true" boot! assert !middleware.include?("Rack::Lock") end diff --git a/railties/test/initializable_test.rb b/railties/test/initializable_test.rb index 6a7e4dcc25..74301a5dc5 100644 --- a/railties/test/initializable_test.rb +++ b/railties/test/initializable_test.rb @@ -10,7 +10,7 @@ module InitializableTests attr_accessor :foo, :bar end - initializer :omg do + initializer :start do @foo ||= 0 @foo += 1 end diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb index 940585836c..ff4ee6332b 100644 --- a/railties/test/isolation/abstract_unit.rb +++ b/railties/test/isolation/abstract_unit.rb @@ -183,23 +183,7 @@ module TestHelpers end def boot_rails - root = File.expand_path('../../../..', __FILE__) - begin - require "#{root}/vendor/gems/environment" - rescue LoadError - %w( - actionmailer/lib - actionpack/lib - activemodel/lib - activerecord/lib - activeresource/lib - activesupport/lib - railties/lib - railties - ).reverse_each do |path| - $:.unshift "#{root}/#{path}" - end - end + require File.expand_path('../../../../load_paths', __FILE__) end end end @@ -220,14 +204,18 @@ Module.new do end FileUtils.mkdir(tmp_path) - environment = File.expand_path('../../../../vendor/gems/environment', __FILE__) + environment = File.expand_path('../../../../load_paths', __FILE__) if File.exist?("#{environment}.rb") require_environment = "-r #{environment}" end `#{Gem.ruby} #{require_environment} #{RAILS_FRAMEWORK_ROOT}/railties/bin/rails #{tmp_path('app_template')}` File.open("#{tmp_path}/app_template/config/boot.rb", 'w') do |f| - f.puts "require '#{environment}'" if require_environment + if require_environment + f.puts "Dir.chdir('#{File.dirname(environment)}') do" + f.puts " require '#{environment}'" + f.puts "end" + end f.puts "require 'rails/all'" end end diff --git a/railties/test/rails_info_controller_test.rb b/railties/test/rails_info_controller_test.rb index edab27465e..4163fb2c6d 100644 --- a/railties/test/rails_info_controller_test.rb +++ b/railties/test/rails_info_controller_test.rb @@ -17,23 +17,23 @@ class InfoControllerTest < ActionController::TestCase ActionController::Routing::Routes.draw do |map| match ':controller/:action' end - @controller.stubs(:consider_all_requests_local => false, :local_request? => true) + @controller.stubs(:consider_all_requests_local? => false, :local_request? => true) end test "info controller does not allow remote requests" do - @controller.stubs(:consider_all_requests_local => false, :local_request? => false) + @controller.stubs(:consider_all_requests_local? => false, :local_request? => false) get :properties assert_response :forbidden end test "info controller renders an error message when request was forbidden" do - @controller.stubs(:consider_all_requests_local => false, :local_request? => false) + @controller.stubs(:consider_all_requests_local? => false, :local_request? => false) get :properties assert_select 'p' end test "info controller allows requests when all requests are considered local" do - @controller.stubs(:consider_all_requests_local => true, :local_request? => false) + @controller.stubs(:consider_all_requests_local? => true, :local_request? => false) get :properties assert_response :success end |