Permalink
Browse files

Merge commit 'rails/master'

  • Loading branch information...
miloops committed May 12, 2009
2 parents 6c7d8cb + 22c5667 commit 0048897a417774f7e5a0c8c9e82fc8684f94ebc1
Showing with 1,819 additions and 654 deletions.
  1. +11 −3 actionpack/Rakefile
  2. +1 −1 actionpack/lib/action_controller/abstract.rb
  3. +60 −13 actionpack/lib/action_controller/abstract/base.rb
  4. +5 −5 actionpack/lib/action_controller/abstract/callbacks.rb
  5. +1 −1 actionpack/lib/action_controller/abstract/exceptions.rb
  6. +7 −13 actionpack/lib/action_controller/abstract/helpers.rb
  7. +16 −12 actionpack/lib/action_controller/abstract/layouts.rb
  8. +1 −1 actionpack/lib/action_controller/abstract/logger.rb
  9. +26 −11 actionpack/lib/action_controller/abstract/renderer.rb
  10. +15 −14 actionpack/lib/action_controller/base/base.rb
  11. +1 −1 actionpack/lib/action_controller/dispatch/dispatcher.rb
  12. +1 −1 actionpack/lib/action_controller/dispatch/middlewares.rb
  13. +25 −5 actionpack/lib/action_controller/new_base.rb
  14. +53 −50 actionpack/lib/action_controller/new_base/base.rb
  15. +58 −0 actionpack/lib/action_controller/new_base/compatibility.rb
  16. +131 −0 actionpack/lib/action_controller/new_base/conditional_get.rb
  17. +8 −5 actionpack/lib/action_controller/new_base/hide_actions.rb
  18. +64 −0 actionpack/lib/action_controller/new_base/http.rb
  19. +9 −7 actionpack/lib/action_controller/new_base/layouts.rb
  20. +24 −28 actionpack/lib/action_controller/new_base/renderer.rb
  21. +25 −0 actionpack/lib/action_controller/new_base/testing.rb
  22. +3 −3 actionpack/lib/action_controller/new_base/url_for.rb
  23. +1 −1 actionpack/lib/action_controller/routing/route_set.rb
  24. +6 −9 actionpack/lib/action_controller/testing/integration.rb
  25. +4 −1 actionpack/lib/action_controller/testing/process.rb
  26. +69 −0 actionpack/lib/action_controller/testing/process2.rb
  27. +2 −0 actionpack/lib/action_dispatch/middleware/show_exceptions.rb
  28. +0 −2 actionpack/lib/action_dispatch/middleware/stack.rb
  29. +1 −1 actionpack/lib/action_view/paths.rb
  30. +5 −2 actionpack/lib/action_view/template/text.rb
  31. +22 −26 actionpack/test/abstract_controller/abstract_controller_test.rb
  32. +9 −9 actionpack/test/abstract_controller/callbacks_test.rb
  33. +3 −3 actionpack/test/abstract_controller/helper_test.rb
  34. +12 −12 actionpack/test/abstract_controller/layouts_test.rb
  35. +6 −10 actionpack/test/abstract_controller/test_helper.rb
  36. +133 −0 actionpack/test/abstract_unit2.rb
  37. +10 −0 actionpack/test/controller/content_type_test.rb
  38. +2 −1 actionpack/test/controller/filters_test.rb
  39. +29 −15 actionpack/test/controller/helper_test.rb
  40. +66 −8 actionpack/test/controller/render_test.rb
  41. +92 −23 actionpack/test/lib/fixture_template.rb
  42. +25 −26 actionpack/test/new_base/base_test.rb
  43. +111 −0 actionpack/test/new_base/content_type_test.rb
  44. +47 −0 actionpack/test/new_base/etag_test.rb
  45. +7 −7 actionpack/test/new_base/render_action_test.rb
  46. +21 −9 actionpack/test/new_base/render_implicit_action_test.rb
  47. +18 −4 actionpack/test/new_base/render_layout_test.rb
  48. +55 −37 actionpack/test/new_base/render_template_test.rb
  49. +88 −0 actionpack/test/new_base/render_test.rb
  50. +42 −37 actionpack/test/new_base/render_text_test.rb
  51. +9 −34 actionpack/test/new_base/test_helper.rb
  52. +22 −22 actionpack/test/template/output_buffer_test.rb
  53. +1 −3 activerecord/lib/active_record/aggregations.rb
  54. +4 −4 activerecord/lib/active_record/association_preload.rb
  55. +26 −10 activerecord/lib/active_record/associations.rb
  56. +1 −1 activerecord/lib/active_record/associations/has_one_association.rb
  57. +13 −9 activerecord/lib/active_record/attribute_methods.rb
  58. +6 −7 activerecord/lib/active_record/autosave_association.rb
  59. +1 −3 activerecord/lib/active_record/batches.rb
  60. +2 −3 activerecord/lib/active_record/calculations.rb
  61. +7 −5 activerecord/lib/active_record/callbacks.rb
  62. +11 −10 activerecord/lib/active_record/dirty.rb
  63. +18 −20 activerecord/lib/active_record/fixtures.rb
  64. +8 −8 activerecord/lib/active_record/locking/optimistic.rb
  65. +4 −5 activerecord/lib/active_record/named_scope.rb
  66. +15 −5 activerecord/lib/active_record/nested_attributes.rb
  67. +1 −3 activerecord/lib/active_record/observer.rb
  68. +1 −3 activerecord/lib/active_record/reflection.rb
  69. +4 −3 activerecord/lib/active_record/serializers/json_serializer.rb
  70. +7 −5 activerecord/lib/active_record/timestamp.rb
  71. +5 −7 activerecord/lib/active_record/transactions.rb
  72. +7 −8 activerecord/lib/active_record/validations.rb
  73. +6 −7 activerecord/test/cases/associations/eager_load_nested_include_test.rb
  74. +12 −0 activerecord/test/cases/associations/eager_test.rb
  75. +1 −8 activerecord/test/cases/associations/has_one_associations_test.rb
  76. +61 −0 activerecord/test/cases/associations/inverse_associations_test.rb
  77. +17 −1 activerecord/test/cases/nested_attributes_test.rb
  78. +1 −5 activerecord/test/cases/repair_helper.rb
  79. +1 −3 activerecord/test/fixtures/organizations.yml
  80. +1 −3 activerecord/test/fixtures/sponsors.yml
  81. +0 −4 activerecord/test/models/organization.rb
  82. +2 −0 activerecord/test/models/pirate.rb
  83. +2 −2 activerecord/test/schema/schema.rb
  84. +2 −1 activeresource/Rakefile
  85. +2 −0 activesupport/CHANGELOG
  86. +2 −2 activesupport/lib/active_support/core_ext/date/calculations.rb
  87. +3 −3 activesupport/lib/active_support/core_ext/date_time/conversions.rb
  88. +1 −1 activesupport/lib/active_support/core_ext/time/conversions.rb
  89. +4 −3 activesupport/lib/active_support/dependency_module.rb
  90. +2 −10 activesupport/lib/active_support/new_callbacks.rb
  91. +14 −0 activesupport/lib/active_support/ordered_hash.rb
  92. +2 −2 activesupport/lib/active_support/values/time_zone.rb
  93. +38 −2 activesupport/test/new_callbacks_test.rb
  94. +10 −0 activesupport/test/ordered_hash_test.rb
  95. +5 −0 railties/CHANGELOG
  96. +3 −0 railties/Rakefile
  97. +7 −0 railties/configs/seeds.rb
  98. +5 −0 railties/lib/rails_generator/generators/applications/app/app_generator.rb
  99. +11 −2 railties/lib/tasks/databases.rake
View
@@ -4,7 +4,6 @@ require 'rake/testtask'
require 'rake/rdoctask'
require 'rake/packagetask'
require 'rake/gempackagetask'
-require 'rake/contrib/sshpublisher'
require File.join(File.dirname(__FILE__), 'lib', 'action_pack', 'version')
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
@@ -23,14 +22,14 @@ task :default => [ :test ]
# Run the unit tests
desc "Run all unit tests"
-task :test => [:test_action_pack, :test_active_record_integration]
+task :test => [:test_action_pack, :test_active_record_integration, :test_new_base]
Rake::TestTask.new(:test_action_pack) do |t|
t.libs << "test"
# make sure we include the tests in alphabetical order as on some systems
# this will not happen automatically and the tests (as a whole) will error
- t.test_files = Dir.glob( "test/[cdft]*/**/*_test.rb" ).sort
+ t.test_files = Dir.glob( "test/{controller,dispatch,template}/**/*_test.rb" ).sort
t.verbose = true
#t.warning = true
@@ -43,6 +42,13 @@ Rake::TestTask.new(:test_active_record_integration) do |t|
t.verbose = true
end
+desc 'New Controller Tests'
+Rake::TestTask.new(:test_new_base) do |t|
+ t.libs << "test"
+ t.test_files = Dir.glob("test/{abstract_controller,new_base}/*_test.rb")
+ t.verbose = true
+end
+
# Genereate the RDoc documentation
@@ -136,12 +142,14 @@ task :update_js => [ :update_scriptaculous ]
desc "Publish the API documentation"
task :pgem => [:package] do
+ require 'rake/contrib/sshpublisher'
Rake::SshFilePublisher.new("gems.rubyonrails.org", "/u/sites/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
`ssh gems.rubyonrails.org '/u/sites/gems/gemupdate.sh'`
end
desc "Publish the API documentation"
task :pdoc => [:rdoc] do
+ require 'rake/contrib/sshpublisher'
Rake::SshDirPublisher.new("wrath.rubyonrails.org", "public_html/ap", "doc").upload
end
@@ -7,4 +7,4 @@ module AbstractController
autoload :Renderer, "action_controller/abstract/renderer"
# === Exceptions
autoload :ActionNotFound, "action_controller/abstract/exceptions"
-end
+end
@@ -1,38 +1,85 @@
module AbstractController
class Base
+
attr_internal :response_body
attr_internal :response_obj
attr_internal :action_name
- def self.process(action)
- new.process(action)
- end
+ class << self
+ attr_reader :abstract
+
+ def abstract!
+ @abstract = true
+ end
+
+ alias_method :abstract?, :abstract
+
+ def internal_methods
+ controller = self
+ controller = controller.superclass until controller.abstract?
+ controller.public_instance_methods(true)
+ end
+
+ def process(action)
+ new.process(action.to_s)
+ end
- def self.inherited(klass)
+ def hidden_actions
+ []
+ end
+
+ def action_methods
+ @action_methods ||=
+ # All public instance methods of this class, including ancestors
+ public_instance_methods(true).map { |m| m.to_s }.to_set -
+ # Except for public instance methods of Base and its ancestors
+ internal_methods.map { |m| m.to_s } +
+ # Be sure to include shadowed public instance methods of this class
+ public_instance_methods(false).map { |m| m.to_s } -
+ # And always exclude explicitly hidden actions
+ hidden_actions
+ end
end
-
+
+ abstract!
+
def initialize
self.response_obj = {}
end
-
+
def process(action_name)
unless respond_to_action?(action_name)
raise ActionNotFound, "The action '#{action_name}' could not be found"
end
-
+
@_action_name = action_name
process_action
- self.response_obj[:body] = self.response_body
self
end
-
+
private
+
+ def action_methods
+ self.class.action_methods
+ end
+
+ # It is possible for respond_to?(action_name) to be false and
+ # respond_to?(:action_missing) to be false if respond_to_action?
+ # is overridden in a subclass. For instance, ActionController::Base
+ # overrides it to include the case where a template matching the
+ # action_name is found.
def process_action
- respond_to?(action_name) ? send(action_name) : send(:action_missing, action_name)
+ if respond_to?(action_name) then send(action_name)
+ elsif respond_to?(:action_missing, true) then action_missing(action_name)
+ end
end
-
+
+ # Override this to change the conditions that will raise an
+ # ActionNotFound error. If you accept a difference case,
+ # you must handle it by also overriding process_action and
+ # handling the case.
def respond_to_action?(action_name)
- respond_to?(action_name) || respond_to?(:action_missing, true)
+ action_methods.include?(action_name) || respond_to?(:action_missing, true)
end
end
-end
+end
@@ -13,19 +13,19 @@ def process_action
super
end
end
-
+
module ClassMethods
def _normalize_callback_options(options)
if only = options[:only]
- only = Array(only).map {|o| "action_name == :#{o}"}.join(" || ")
+ only = Array(only).map {|o| "action_name == '#{o}'"}.join(" || ")
options[:per_key] = {:if => only}
end
if except = options[:except]
- except = Array(except).map {|e| "action_name == :#{e}"}.join(" || ")
+ except = Array(except).map {|e| "action_name == '#{e}'"}.join(" || ")
options[:per_key] = {:unless => except}
end
end
-
+
[:before, :after, :around].each do |filter|
class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
def #{filter}_filter(*names, &blk)
@@ -40,4 +40,4 @@ def #{filter}_filter(*names, &blk)
end
end
end
-end
+end
@@ -1,3 +1,3 @@
module AbstractController
class ActionNotFound < StandardError ; end
-end
+end
@@ -9,33 +9,26 @@ module Helpers
self.master_helper_module = Module.new
end
- # def self.included(klass)
- # klass.class_eval do
- # extlib_inheritable_accessor :master_helper_module
- # self.master_helper_module = Module.new
- # end
- # end
-
def _action_view
@_action_view ||= begin
av = super
av.helpers.send(:include, master_helper_module)
av
end
end
-
+
module ClassMethods
def inherited(klass)
klass.master_helper_module = Module.new
klass.master_helper_module.__send__ :include, master_helper_module
-
+
super
end
-
+
def add_template_helper(mod)
master_helper_module.module_eval { include mod }
end
-
+
def helper_method(*meths)
meths.flatten.each do |meth|
master_helper_module.class_eval <<-ruby_eval, __FILE__, __LINE__ + 1
@@ -45,7 +38,7 @@ def #{meth}(*args, &blk)
ruby_eval
end
end
-
+
def helper(*args, &blk)
args.flatten.each do |arg|
case arg
@@ -56,5 +49,6 @@ def helper(*args, &blk)
master_helper_module.module_eval(&blk) if block_given?
end
end
+
end
-end
+end
@@ -9,18 +9,18 @@ def layout(layout)
unless [String, Symbol, FalseClass, NilClass].include?(layout.class)
raise ArgumentError, "Layouts must be specified as a String, Symbol, false, or nil"
end
-
+
@_layout = layout || false # Converts nil to false
_write_layout_method
end
-
+
def _implied_layout_name
name.underscore
end
-
+
# Takes the specified layout and creates a _layout method to be called
# by _default_layout
- #
+ #
# If the specified layout is a:
# String:: return the string
# Symbol:: call the method specified by the symbol
@@ -49,22 +49,26 @@ def _layout
end
end
end
-
+
def _render_template(template, options)
- _action_view._render_template_with_layout(template, options[:_layout])
+ _action_view._render_template_with_layout(template, options[:_layout], options)
end
-
+
private
+
def _layout() end # This will be overwritten
-
+
+ # :api: plugin
+ # ====
+ # Override this to mutate the inbound layout name
def _layout_for_name(name)
unless [String, FalseClass, NilClass].include?(name.class)
raise ArgumentError, "String, false, or nil expected; you passed #{name.inspect}"
end
-
+
name && view_paths.find_by_parts(name, {:formats => formats}, "layouts")
end
-
+
def _default_layout(require_layout = false)
if require_layout && !_layout
raise ArgumentError,
@@ -74,9 +78,9 @@ def _default_layout(require_layout = false)
begin
layout = _layout_for_name(_layout)
rescue NameError => e
- raise NoMethodError,
+ raise NoMethodError,
"You specified #{@_layout.inspect} as the layout, but no such method was found"
end
end
end
-end
+end
@@ -6,4 +6,4 @@ module Logger
cattr_accessor :logger
end
end
-end
+end
Oops, something went wrong.

0 comments on commit 0048897

Please sign in to comment.