Permalink
Browse files

Merge master.

  • Loading branch information...
2 parents d4e008f + 762088a commit 3f948a0e2951a8bb7f32e98a404fb5ff97cb2896 @josevalim josevalim committed Feb 16, 2010
Showing with 136 additions and 67 deletions.
  1. +4 −0 Gemfile
  2. +5 −2 actionmailer/test/abstract_unit.rb
  3. +3 −0 actionmailer/test/log_subscriber_test.rb
  4. +1 −1 actionpack/actionpack.gemspec
  5. +2 −2 actionpack/lib/abstract_controller/helpers.rb
  6. +1 −1 actionpack/lib/abstract_controller/rendering.rb
  7. +1 −1 actionpack/lib/action_controller/base.rb
  8. +8 −0 actionpack/lib/action_controller/metal.rb
  9. +2 −2 actionpack/lib/action_controller/metal/helpers.rb
  10. +4 −6 actionpack/lib/action_controller/metal/hide_actions.rb
  11. +1 −1 actionpack/lib/action_dispatch/routing/route_set.rb
  12. +7 −1 actionpack/test/abstract_unit.rb
  13. +5 −2 actionpack/test/activerecord/controller_runtime_test.rb
  14. +3 −0 actionpack/test/controller/log_subscriber_test.rb
  15. +4 −1 actionpack/test/template/log_subscriber_test.rb
  16. +1 −1 activemodel/Rakefile
  17. +6 −1 activemodel/test/cases/helper.rb
  18. +3 −1 activemodel/test/cases/tests_database.rb
  19. +0 −1 activerecord/lib/active_record.rb
  20. +4 −1 activerecord/test/cases/helper.rb
  21. +4 −1 activerecord/test/cases/log_subscriber_test.rb
  22. +4 −2 activeresource/test/abstract_unit.rb
  23. +5 −1 activeresource/test/cases/log_subscriber_test.rb
  24. +4 −1 activesupport/test/abstract_unit.rb
  25. +0 −1 activesupport/test/callback_inheritance_test.rb
  26. +0 −1 activesupport/test/callbacks_test.rb
  27. +2 −0 activesupport/test/core_ext/class/delegating_attributes_test.rb
  28. +15 −0 activesupport/test/load_paths_test.rb
  29. +10 −0 bundler.rb
  30. +0 −21 load_paths.rb
  31. +1 −1 railties/Rakefile
  32. +1 −1 railties/railties.gemspec
  33. +6 −1 railties/test/abstract_unit.rb
  34. +1 −1 railties/test/application/configuration_test.rb
  35. +14 −0 railties/test/edge_rails.rb
  36. +4 −10 railties/test/isolation/abstract_unit.rb
View
@@ -22,6 +22,10 @@ end
gem "rack-test", "0.5.3", :require => 'rack/test'
gem "RedCloth", ">= 4.2.2"
+group :documentation do
+ gem 'rdoc', '2.1'
+end
+
if ENV['CI']
gem "nokogiri", ">= 1.4.0"
@@ -1,4 +1,7 @@
-require File.expand_path('../../../load_paths', __FILE__)
+require File.expand_path('../../../bundler', __FILE__)
+
+lib = File.expand_path("#{File.dirname(__FILE__)}/../lib")
+$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib)
require 'test/unit'
require 'action_mailer'
@@ -14,7 +17,7 @@
FIXTURE_LOAD_PATH = File.expand_path('fixtures', File.dirname(__FILE__))
ActionMailer::Base.view_paths = FIXTURE_LOAD_PATH
-class MockSMTP
+class MockSMTP
def self.deliveries
@@deliveries
end
@@ -1,3 +1,6 @@
+railties_path = File.expand_path('../../../railties/lib', __FILE__)
+$:.unshift(railties_path) if File.directory?(railties_path) && !$:.include?(railties_path)
+
require "abstract_unit"
require "rails/log_subscriber/test_helper"
require "action_mailer/railties/log_subscriber"
@@ -21,6 +21,6 @@ Gem::Specification.new do |s|
s.add_dependency('activemodel', '= 3.0.0.beta1')
s.add_dependency('rack', '~> 1.1.0')
s.add_dependency('rack-test', '~> 0.5.0')
- s.add_dependency('rack-mount', '~> 0.4.7')
+ s.add_dependency('rack-mount', '~> 0.5.1')
s.add_dependency('erubis', '~> 2.6.5')
end
@@ -100,7 +100,7 @@ def #{meth}(*args, &blk)
def helper(*args, &block)
self._helper_serial = AbstractController::Helpers.next_serial + 1
- _modules_for_helpers(args).each do |mod|
+ modules_for_helpers(args).each do |mod|
add_template_helper(mod)
end
@@ -135,7 +135,7 @@ def add_template_helper(mod)
# ==== Returns
# Array[Module]:: A normalized list of modules for the list of
# helpers provided.
- def _modules_for_helpers(args)
+ def modules_for_helpers(args)
args.flatten.map! do |arg|
case arg
when String, Symbol
@@ -37,7 +37,7 @@ module Rendering
# options<Hash>:: See _render_template_with_layout in ActionView::Base
# partial<Boolean>:: Whether or not the template to render is a partial
#
- # Override this method in a to change the default behavior.
+ # Override this method in a module to change the default behavior.
def view_context
@_view_context ||= ActionView::Base.for_controller(self)
end
@@ -52,7 +52,7 @@ def default_render
def method_for_action(action_name)
super || begin
- if template_exists?(action_name.to_s, {:formats => formats}, :_prefix => controller_path)
+ if view_paths.exists?(action_name.to_s, {:formats => formats}, controller_path)
"default_render"
end
end
@@ -49,6 +49,14 @@ def content_type=(type)
headers["Content-Type"] = type.to_s
end
+ def content_type
+ headers["Content-Type"]
+ end
+
+ def location
+ headers["Location"]
+ end
+
def location=(url)
headers["Location"] = url
end
@@ -86,7 +86,7 @@ def helpers
end
private
- # Overwrite _modules_for_helpers to accept :all as argument, which loads
+ # Overwrite modules_for_helpers to accept :all as argument, which loads
# all helpers in helpers_dir.
#
# ==== Parameters
@@ -95,7 +95,7 @@ def helpers
# ==== Returns
# Array[Module]:: A normalized list of modules for the list of
# helpers provided.
- def _modules_for_helpers(args)
+ def modules_for_helpers(args)
args += all_application_helpers if args.delete(:all)
super(args)
end
@@ -15,10 +15,8 @@ module HideActions
# Overrides AbstractController::Base#action_method? to return false if the
# action name is in the list of hidden actions.
- def action_method?(action_name)
- self.class.visible_action?(action_name) do
- !self.class.hidden_actions.include?(action_name) && super
- end
+ def method_for_action(action_name)
+ self.class.visible_action?(action_name) && super
end
module ClassMethods
@@ -31,13 +29,13 @@ def hide_action(*args)
end
def inherited(klass)
- klass.instance_variable_set("@visible_actions", {})
+ klass.class_eval { @visible_actions = {} }
super
end
def visible_action?(action_name)
return @visible_actions[action_name] if @visible_actions.key?(action_name)
- @visible_actions[action_name] = yield
+ @visible_actions[action_name] = !hidden_actions.include?(action_name)
end
# Overrides AbstractController::Base#action_methods to remove any methods
@@ -430,7 +430,7 @@ def recognize_path(path, environment = {})
end
req = Rack::Request.new(env)
- @set.recognize(req) do |route, params|
+ @set.recognize(req) do |route, matches, params|
dispatcher = route.app
if dispatcher.is_a?(Dispatcher) && dispatcher.controller(params, false)
dispatcher.prepare_params!(params)
@@ -1,4 +1,10 @@
-require File.expand_path('../../../load_paths', __FILE__)
+require File.expand_path('../../../bundler', __FILE__)
+
+lib = File.expand_path("#{File.dirname(__FILE__)}/../lib")
+$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib)
+
+activemodel_path = File.expand_path('../../../activemodel/lib', __FILE__)
+$:.unshift(activemodel_path) if File.directory?(activemodel_path) && !$:.include?(activemodel_path)
$:.unshift(File.dirname(__FILE__) + '/lib')
$:.unshift(File.dirname(__FILE__) + '/fixtures/helpers')
@@ -1,3 +1,6 @@
+railties_path = File.expand_path('../../../../railties/lib', __FILE__)
+$:.unshift(railties_path) if File.directory?(railties_path) && !$:.include?(railties_path)
+
require 'active_record_unit'
require 'active_record/railties/controller_runtime'
require 'fixtures/project'
@@ -31,12 +34,12 @@ def teardown
def set_logger(logger)
ActionController::Base.logger = logger
end
-
+
def test_log_with_active_record
get :show
wait
assert_equal 2, @logger.logged(:info).size
assert_match /\(Views: [\d\.]+ms | ActiveRecord: [\d\.]+ms\)/, @logger.logged(:info)[1]
end
-end
+end
@@ -1,3 +1,6 @@
+railties_path = File.expand_path('../../../../railties/lib', __FILE__)
+$:.unshift(railties_path) if File.directory?(railties_path) && !$:.include?(railties_path)
+
require "abstract_unit"
require "rails/log_subscriber/test_helper"
require "action_controller/railties/log_subscriber"
@@ -1,3 +1,6 @@
+railties_path = File.expand_path('../../../../railties/lib', __FILE__)
+$:.unshift(railties_path) if File.directory?(railties_path) && !$:.include?(railties_path)
+
require "abstract_unit"
require "rails/log_subscriber/test_helper"
require "action_view/railties/log_subscriber"
@@ -90,4 +93,4 @@ def test_render_collection_template_without_path
assert_equal 1, @logger.logged(:info).size
assert_match /Rendered collection/, @logger.logged(:info).last
end
-end
+end
View
@@ -13,7 +13,7 @@ require 'rake/testtask'
task :default => :test
Rake::TestTask.new do |t|
- t.libs << "#{dir}/test"
+ t.libs << "test"
t.test_files = Dir.glob("#{dir}/test/cases/**/*_test.rb").sort
t.warning = true
end
@@ -1,4 +1,9 @@
-require File.expand_path('../../../../load_paths', __FILE__)
+require File.expand_path('../../../../bundler', __FILE__)
+
+lib = File.expand_path("#{File.dirname(__FILE__)}/../../lib")
+$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib)
+
+puts $LOAD_PATH.inspect
require 'config'
require 'active_model'
@@ -1,6 +1,8 @@
require 'logger'
-$:.unshift(File.dirname(__FILE__) + '/../../../activerecord/lib')
+activerecord_path = File.expand_path('../../../../activerecord/lib', __FILE__)
+$:.unshift(activerecord_path) if File.directory?(activerecord_path) && !$:.include?(activerecord_path)
+
require 'active_record'
module ActiveModel
@@ -21,7 +21,6 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#++
-
activesupport_path = File.expand_path('../../../activesupport/lib', __FILE__)
$:.unshift(activesupport_path) if File.directory?(activesupport_path) && !$:.include?(activesupport_path)
@@ -1,4 +1,7 @@
-require File.expand_path('../../../../load_paths', __FILE__)
+require File.expand_path('../../../../bundler', __FILE__)
+
+lib = File.expand_path("#{File.dirname(__FILE__)}/../../lib")
+$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib)
require 'config'
@@ -1,3 +1,6 @@
+railties_path = File.expand_path('../../../../railties/lib', __FILE__)
+$:.unshift(railties_path) if File.directory?(railties_path) && !$:.include?(railties_path)
+
require "cases/helper"
require "models/developer"
require "rails/log_subscriber/test_helper"
@@ -39,4 +42,4 @@ def test_cached_queries
assert_match /CACHE/, @logger.logged(:debug).last
assert_match /SELECT .*?FROM .?developers.?/, @logger.logged(:debug).last
end
-end
+end
@@ -1,12 +1,14 @@
-require File.expand_path('../../../load_paths', __FILE__)
+require File.expand_path('../../../bundler', __FILE__)
+
+lib = File.expand_path("#{File.dirname(__FILE__)}/../lib")
+$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib)
require 'rubygems'
require 'test/unit'
require 'active_resource'
require 'active_support'
require 'active_support/test_case'
-$:.unshift "#{File.dirname(__FILE__)}/../test"
require 'setter_trap'
require 'logger'
@@ -1,9 +1,13 @@
+railties_path = File.expand_path('../../../../railties/lib', __FILE__)
+$:.unshift(railties_path) if File.directory?(railties_path) && !$:.include?(railties_path)
+
require "abstract_unit"
require "fixtures/person"
require "rails/log_subscriber/test_helper"
require "active_resource/railties/log_subscriber"
require "active_support/core_ext/hash/conversions"
+# TODO: This test should be part of Railties
class LogSubscriberTest < ActiveSupport::TestCase
include Rails::LogSubscriber::TestHelper
Rails::LogSubscriber.add(:active_resource, ActiveResource::Railties::LogSubscriber.new)
@@ -28,4 +32,4 @@ def test_request_notification
assert_equal "GET http://37s.sunrise.i:3000/people/1.xml", @logger.logged(:info)[0]
assert_match /\-\-\> 200 200 106/, @logger.logged(:info)[1]
end
-end
+end
@@ -1,4 +1,7 @@
-require File.expand_path('../../../load_paths', __FILE__)
+require File.expand_path('../../../bundler', __FILE__)
+
+lib = File.expand_path("#{File.dirname(__FILE__)}/../lib")
+$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib)
require 'test/unit'
require 'mocha'
@@ -1,5 +1,4 @@
require 'test/unit'
-$:.unshift "#{File.dirname(__FILE__)}/../lib"
require 'active_support'
class GrandParent
@@ -1,6 +1,5 @@
# require 'abstract_unit'
require 'test/unit'
-$:.unshift "#{File.dirname(__FILE__)}/../lib"
require 'active_support'
module CallbacksTest
@@ -84,6 +84,8 @@ def test_delegation_stops_for_nil
assert_equal "1", Child.some_attribute
assert_nil Mokopuna.some_attribute
+ ensure
+ Child.some_attribute=nil
end
end
@@ -0,0 +1,15 @@
+require 'abstract_unit'
+
+class LoadPathsTest < Test::Unit::TestCase
+ def test_uniq_load_paths
+ load_paths_count = $LOAD_PATH.inject({}) { |paths, path|
+ expanded_path = File.expand_path(path)
+ paths[expanded_path] ||= 0
+ paths[expanded_path] += 1
+ paths
+ }
+
+ # CI has a bunch of duplicate load paths
+ # assert_equal [], load_paths_count.select { |k, v| v > 1 }, $LOAD_PATH.inspect
+ end
+end
View
@@ -0,0 +1,10 @@
+begin
+ require File.expand_path('../.bundle/environment', __FILE__)
+rescue LoadError
+ begin
+ require 'rubygems'
+ require 'bundler'
+ Bundler.setup
+ rescue LoadError
+ end
+end
View
@@ -1,21 +0,0 @@
-begin
- require File.expand_path('../.bundle/environment', __FILE__)
-rescue LoadError
- begin
- require 'rubygems'
- require 'bundler'
- Bundler.setup
- rescue LoadError
- %w(
- actionmailer
- actionpack
- activemodel
- activerecord
- activeresource
- activesupport
- railties
- ).each do |framework|
- $:.unshift File.expand_path("../#{framework}/lib", __FILE__)
- end
- end
-end
View
@@ -1,4 +1,4 @@
-require File.expand_path('../../load_paths', __FILE__)
+require File.expand_path('../../bundler', __FILE__)
require 'rake'
require 'rake/testtask'
Oops, something went wrong.

0 comments on commit 3f948a0

Please sign in to comment.