Permalink
Browse files

Merge commit 'rails/master'

  • Loading branch information...
2 parents 4864f92 + 4417a19 commit b9088dce07f8525cdb84a1312a77b81db79067d6 @miloops miloops committed Jun 23, 2009
Showing with 813 additions and 698 deletions.
  1. +8 −0 actionpack/lib/action_controller/base/compatibility.rb
  2. +1 −4 actionpack/lib/action_controller/base/filter_parameter_logging.rb
  3. +21 −53 actionpack/lib/action_controller/base/flash.rb
  4. +1 −1 actionpack/lib/action_controller/base/http.rb
  5. +2 −5 actionpack/lib/action_controller/base/layouts.rb
  6. +2 −5 actionpack/lib/action_controller/base/mime_responds.rb
  7. +7 −11 actionpack/lib/action_controller/base/request_forgery_protection.rb
  8. +1 −4 actionpack/lib/action_controller/base/streaming.rb
  9. +1 −4 actionpack/lib/action_controller/base/verification.rb
  10. +5 −21 actionpack/lib/action_controller/caching/actions.rb
  11. +0 −3 actionpack/lib/action_controller/legacy/layout.rb
  12. +1 −2 actionpack/lib/action_controller/routing/generation/polymorphic_routes.rb
  13. +13 −1 actionpack/lib/action_dispatch/http/mime_type.rb
  14. +4 −6 actionpack/lib/action_dispatch/http/request.rb
  15. +15 −14 actionpack/lib/action_view.rb
  16. +17 −38 actionpack/lib/action_view/base.rb
  17. +11 −48 actionpack/lib/action_view/helpers/active_record_helper.rb
  18. +24 −7 actionpack/lib/action_view/helpers/capture_helper.rb
  19. +1 −1 actionpack/lib/action_view/paths.rb
  20. +0 −7 actionpack/lib/action_view/render/partials.rb
  21. +48 −22 actionpack/lib/action_view/render/rendering.rb
  22. +1 −2 actionpack/lib/action_view/template/handlers/builder.rb
  23. +0 −1 actionpack/lib/action_view/template/handlers/rjs.rb
  24. +0 −152 actionpack/lib/action_view/template/path.rb
  25. +150 −0 actionpack/lib/action_view/template/resolver.rb
  26. +2 −2 actionpack/lib/action_view/template/template.rb
  27. +1 −1 actionpack/lib/action_view/template/text.rb
  28. +1 −1 actionpack/test/abstract_controller/layouts_test.rb
  29. +1 −0 actionpack/test/abstract_unit.rb
  30. +6 −3 actionpack/test/activerecord/polymorphic_routes_test.rb
  31. +1 −0 actionpack/test/activerecord/render_partial_with_record_identification_test.rb
  32. +19 −5 actionpack/test/controller/action_pack_assertions_test.rb
  33. +1 −5 actionpack/test/controller/base_test.rb
  34. +18 −50 actionpack/test/controller/filters_test.rb
  35. +3 −16 actionpack/test/controller/helper_test.rb
  36. +3 −19 actionpack/test/controller/layout_test.rb
  37. +10 −22 actionpack/test/controller/mime_responds_test.rb
  38. +2 −0 actionpack/test/controller/record_identifier_test.rb
  39. +1 −0 actionpack/test/controller/redirect_test.rb
  40. +7 −7 actionpack/test/controller/render_test.rb
  41. +2 −2 actionpack/test/controller/send_file_test.rb
  42. +2 −2 actionpack/test/dispatch/mime_type_test.rb
  43. +1 −1 actionpack/test/fixtures/layouts/builder.builder
  44. +1 −1 actionpack/test/fixtures/layouts/standard.html.erb
  45. +2 −2 actionpack/test/fixtures/layouts/talk_from_action.erb
  46. +1 −0 actionpack/test/fixtures/test/render_implicit_js_template_without_layout.js.erb
  47. +6 −0 actionpack/test/lib/controller/fake_models.rb
  48. +2 −39 actionpack/test/lib/fixture_template.rb
  49. +1 −1 actionpack/test/new_base/content_type_test.rb
  50. +1 −1 actionpack/test/new_base/etag_test.rb
  51. +4 −4 actionpack/test/new_base/render_action_test.rb
  52. +1 −1 actionpack/test/new_base/render_implicit_action_test.rb
  53. +3 −3 actionpack/test/new_base/render_layout_test.rb
  54. +1 −1 actionpack/test/new_base/render_partial_test.rb
  55. +46 −0 actionpack/test/new_base/render_rjs_test.rb
  56. +3 −3 actionpack/test/new_base/render_template_test.rb
  57. +1 −1 actionpack/test/new_base/render_test.rb
  58. +2 −2 actionpack/test/new_base/render_text_test.rb
  59. +1 −1 actionpack/test/new_base/render_xml_test.rb
  60. +7 −7 actionpack/test/template/active_record_helper_test.rb
  61. +1 −0 actionpack/test/template/atom_feed_helper_test.rb
  62. +5 −8 actionpack/test/template/body_parts_test.rb
  63. +15 −0 actionpack/test/template/capture_helper_test.rb
  64. +1 −1 actionpack/test/template/compiled_templates_test.rb
  65. +2 −2 actionpack/test/template/form_helper_test.rb
  66. +3 −0 actionpack/test/template/prototype_helper_test.rb
  67. +1 −0 actionpack/test/template/record_tag_helper_test.rb
  68. +3 −26 actionpack/test/template/render_test.rb
  69. +1 −0 actionpack/test/template/test_test.rb
  70. +2 −0 actionpack/test/template/url_helper_test.rb
  71. +7 −0 activemodel/lib/active_model.rb
  72. +17 −0 activemodel/lib/active_model/attributes.rb
  73. +3 −3 activemodel/lib/active_model/errors.rb
  74. +8 −8 ...pport/lib/active_support/core_ext/module/model_naming.rb → activemodel/lib/active_model/naming.rb
  75. +38 −0 activemodel/lib/active_model/serializers/json.rb
  76. +1 −5 activemodel/lib/active_model/validations.rb
  77. +30 −0 activemodel/test/cases/attributes_test.rb
  78. +64 −0 activemodel/test/cases/json_serialization_test.rb
  79. +3 −4 activesupport/test/core_ext/module/model_naming_test.rb → activemodel/test/cases/naming_test.rb
  80. +9 −9 activemodel/test/cases/validations/presence_validation_test.rb
  81. +7 −0 activerecord/lib/active_record/associations/through_association_scope.rb
  82. +1 −0 activerecord/lib/active_record/base.rb
  83. +1 −1 activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
  84. +1 −1 activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
  85. +1 −1 activerecord/lib/active_record/serializers/json_serializer.rb
  86. +0 −4 activerecord/lib/active_record/validations.rb
  87. +6 −0 activerecord/test/cases/associations/has_many_through_associations_test.rb
  88. +33 −0 activerecord/test/cases/migration_test.rb
  89. +2 −0 activerecord/test/models/post.rb
  90. +1 −0 activerecord/test/schema/schema.rb
  91. +1 −0 activeresource/lib/active_resource/base.rb
  92. +10 −2 activesupport/lib/active_support/cache.rb
  93. +13 −1 activesupport/lib/active_support/cache/file_store.rb
  94. +0 −4 activesupport/lib/active_support/cache/mem_cache_store.rb
  95. +0 −1 activesupport/lib/active_support/core_ext/module.rb
  96. +1 −0 activesupport/lib/active_support/json/decoding.rb
  97. +5 −0 activesupport/lib/active_support/json/encoding.rb
  98. +16 −0 activesupport/test/caching_test.rb
  99. +1 −1 railties/lib/initializer.rb
  100. +1 −1 railties/test/rails_info_controller_test.rb
@@ -118,6 +118,14 @@ def _find_by_parts(name, details)
details[:prefix] = nil if name =~ /\blayouts/
super
end
+
+ # Move this into a "don't run in production" module
+ def _default_layout(details, require_layout = false)
+ super
+ rescue ActionView::MissingTemplate
+ _find_by_parts(_layout({}), {})
+ nil
+ end
def performed?
response_body
@@ -2,10 +2,7 @@ module ActionController
module FilterParameterLogging
extend ActiveSupport::Concern
- # TODO : Remove the defined? check when new base is the main base
- if defined?(ActionController::Http)
- include AbstractController::Logger
- end
+ include AbstractController::Logger
included do
include InstanceMethodsForNewBase
@@ -28,20 +28,7 @@ module ActionController #:nodoc:
module Flash
extend ActiveSupport::Concern
- # TODO : Remove the defined? check when new base is the main base
- include Session if defined?(ActionController::Http)
-
- included do
- # TODO : Remove the defined? check when new base is the main base
- if defined?(ActionController::Http)
- include InstanceMethodsForNewBase
- else
- include InstanceMethodsForBase
-
- alias_method_chain :perform_action, :flash
- alias_method_chain :reset_session, :flash
- end
- end
+ include Session
class FlashNow #:nodoc:
def initialize(flash)
@@ -148,49 +135,30 @@ def use(key = nil, used = true)
end
end
- module InstanceMethodsForBase #:nodoc:
- protected
- def perform_action_with_flash
- perform_action_without_flash
- if defined? @_flash
- @_flash.store(session)
- remove_instance_variable(:@_flash)
- end
- end
-
- def reset_session_with_flash
- reset_session_without_flash
- remove_instance_variable(:@_flash) if defined?(@_flash)
- end
+ protected
+ def process_action(method_name)
+ super
+ if defined? @_flash
+ @_flash.store(session)
+ remove_instance_variable(:@_flash)
+ end
end
- module InstanceMethodsForNewBase #:nodoc:
- protected
- def process_action(method_name)
- super
- if defined? @_flash
- @_flash.store(session)
- remove_instance_variable(:@_flash)
- end
- end
-
- def reset_session
- super
- remove_instance_variable(:@_flash) if defined?(@_flash)
- end
+ def reset_session
+ super
+ remove_instance_variable(:@_flash) if defined?(@_flash)
end
- protected
- # Access the contents of the flash. Use <tt>flash["notice"]</tt> to
- # read a notice you put there or <tt>flash["notice"] = "hello"</tt>
- # to put a new one.
- def flash #:doc:
- if !defined?(@_flash)
- @_flash = session["flash"] || FlashHash.new
- @_flash.sweep
- end
-
- @_flash
+ # Access the contents of the flash. Use <tt>flash["notice"]</tt> to
+ # read a notice you put there or <tt>flash["notice"] = "hello"</tt>
+ # to put a new one.
+ def flash #:doc:
+ if !defined?(@_flash)
+ @_flash = session["flash"] || FlashHash.new
+ @_flash.sweep
end
+
+ @_flash
+ end
end
end
@@ -36,7 +36,7 @@ def controller_name
# ==== Returns
# String
def self.controller_path
- @controller_path ||= self.name.sub(/Controller$/, '').underscore
+ @controller_path ||= name && name.sub(/Controller$/, '').underscore
end
# Delegates to the class' #controller_path
@@ -26,9 +26,6 @@ module ActionController
# hello world
# // The footer part of this layout
#
- # NOTE: The old notation for rendering the view from a layout was to expose the magic <tt>@content_for_layout</tt> instance
- # variable. The preferred notation now is to use <tt>yield</tt>, as documented above.
- #
# == Accessing shared variables
#
# Layouts have access to variables specified in the content pages and vice versa. This allows you to have layouts with
@@ -176,15 +173,15 @@ def _determine_template(options)
super
return if (options.key?(:text) || options.key?(:inline) || options.key?(:partial)) && !options.key?(:layout)
- layout = options.key?(:layout) ? options[:layout] : :none
+ layout = options.key?(:layout) ? options[:layout] : :default
options[:_layout] = _layout_for_option(layout, options[:_template].details)
end
def _layout_for_option(name, details)
case name
when String then _layout_for_name(name, details)
when true then _default_layout(details, true)
- when :none then _default_layout(details, false)
+ when :default then _default_layout(details, false)
when false, nil then nil
else
raise ArgumentError,
@@ -120,12 +120,9 @@ def custom(mime_type, &block)
@responses[mime_type] ||= Proc.new do
# TODO: Remove this when new base is merged in
- if defined?(Http)
- @controller.formats = [mime_type.to_sym]
- end
-
+ @controller.formats = [mime_type.to_sym]
+ @controller.content_type = mime_type
@controller.template.formats = [mime_type.to_sym]
- @response.content_type = mime_type
block_given? ? block.call : @controller.send(:render, :action => @controller.action_name)
end
@@ -6,20 +6,16 @@ module RequestForgeryProtection
extend ActiveSupport::Concern
# TODO : Remove the defined? check when new base is the main base
- if defined?(ActionController::Http)
- include AbstractController::Helpers, Session
- end
+ include AbstractController::Helpers, Session
included do
- if defined?(ActionController::Http)
- # Sets the token parameter name for RequestForgery. Calling +protect_from_forgery+
- # sets it to <tt>:authenticity_token</tt> by default.
- cattr_accessor :request_forgery_protection_token
+ # Sets the token parameter name for RequestForgery. Calling +protect_from_forgery+
+ # sets it to <tt>:authenticity_token</tt> by default.
+ cattr_accessor :request_forgery_protection_token
- # Controls whether request forgergy protection is turned on or not. Turned off by default only in test mode.
- class_inheritable_accessor :allow_forgery_protection
- self.allow_forgery_protection = true
- end
+ # Controls whether request forgergy protection is turned on or not. Turned off by default only in test mode.
+ class_inheritable_accessor :allow_forgery_protection
+ self.allow_forgery_protection = true
helper_method :form_authenticity_token
helper_method :protect_against_forgery?
@@ -4,10 +4,7 @@ module ActionController #:nodoc:
module Streaming
extend ActiveSupport::Concern
- # TODO : Remove the defined? check when new base is the main base
- if defined?(ActionController::Http)
- include ActionController::Renderer
- end
+ include ActionController::Renderer
DEFAULT_SEND_FILE_OPTIONS = {
:type => 'application/octet-stream'.freeze,
@@ -2,10 +2,7 @@ module ActionController #:nodoc:
module Verification #:nodoc:
extend ActiveSupport::Concern
- # TODO : Remove the defined? check when new base is the main base
- if defined?(ActionController::Http)
- include AbstractController::Callbacks, Session, Flash, Renderer
- end
+ include AbstractController::Callbacks, Session, Flash, Renderer
# This module provides a class-level method for specifying that certain
# actions are guarded against being called without certain prerequisites
@@ -62,14 +62,7 @@ def caches_action(*actions)
cache_filter = ActionCacheFilter.new(:layout => options.delete(:layout), :cache_path => options.delete(:cache_path), :store_options => options)
- # TODO: Remove this once new base is swapped in.
- if defined?(ActionController::Http)
- around_filter cache_filter, filter_options
- else
- around_filter(filter_options) do |controller, action|
- cache_filter.filter(controller, action)
- end
- end
+ around_filter cache_filter, filter_options
end
end
@@ -91,19 +84,10 @@ def initialize(options, &block)
@options = options
end
- # TODO: Remove once New Base is merged
- if defined?(ActionController::Http)
- def filter(controller)
- should_continue = before(controller)
- yield if should_continue
- after(controller)
- end
- else
- def filter(controller, action)
- should_continue = before(controller)
- action.call if should_continue
- after(controller)
- end
+ def filter(controller)
+ should_continue = before(controller)
+ yield if should_continue
+ after(controller)
end
def before(controller)
@@ -44,9 +44,6 @@ def self.included(base)
# hello world
# // The footer part of this layout
#
- # NOTE: The old notation for rendering the view from a layout was to expose the magic <tt>@content_for_layout</tt> instance
- # variable. The preferred notation now is to use <tt>yield</tt>, as documented above.
- #
# == Accessing shared variables
#
# Layouts have access to variables specified in the content pages and vice versa. This allows you to have layouts with
@@ -112,8 +112,7 @@ def polymorphic_url(record_or_hash_or_array, options = {})
# Returns the path component of a URL for the given record. It uses
# <tt>polymorphic_url</tt> with <tt>:routing_type => :path</tt>.
def polymorphic_path(record_or_hash_or_array, options = {})
- options[:routing_type] = :path
- polymorphic_url(record_or_hash_or_array, options)
+ polymorphic_url(record_or_hash_or_array, options.merge(:routing_type => :path))
end
%w(edit new).each do |action|
@@ -2,7 +2,19 @@
require 'active_support/core_ext/class/attribute_accessors'
module Mime
- SET = []
+ class Mimes < Array
+ def symbols
+ @symbols ||= map {|m| m.to_sym }
+ end
+
+ %w(<< concat shift unshift push pop []= clear compact! collect!
+ delete delete_at delete_if flatten! map! insert reject! reverse!
+ replace slice! sort! uniq!).each do |method|
+ define_method(method) {|*args| @symbols = nil; super(*args) }
+ end
+ end
+
+ SET = Mimes.new
EXTENSION_LOOKUP = {}
LOOKUP = Hash.new { |h, k| h[k] = Type.new(k) unless k.blank? }
@@ -180,12 +180,10 @@ def formats
else
accepts.dup
end.tap do |ret|
- if defined?(ActionController::Http)
- if ret == ONLY_ALL
- ret.replace Mime::SET
- elsif all = ret.index(Mime::ALL)
- ret.delete_at(all) && ret.insert(all, *Mime::SET)
- end
+ if ret == ONLY_ALL
+ ret.replace Mime::SET
+ elsif all = ret.index(Mime::ALL)
+ ret.delete_at(all) && ret.insert(all, *Mime::SET)
end
end
else
@@ -33,21 +33,22 @@ def self.load_all!
[Base, InlineTemplate, TemplateError]
end
- autoload :Base, 'action_view/base'
- autoload :Helpers, 'action_view/helpers'
- autoload :InlineTemplate, 'action_view/template/inline'
- autoload :Partials, 'action_view/render/partials'
- autoload :Path, 'action_view/template/path'
- autoload :PathSet, 'action_view/paths'
- autoload :Rendering, 'action_view/render/rendering'
- autoload :Renderable, 'action_view/template/renderable'
+ autoload :Base, 'action_view/base'
+ autoload :Helpers, 'action_view/helpers'
+ autoload :InlineTemplate, 'action_view/template/inline'
+ autoload :Partials, 'action_view/render/partials'
+ autoload :Resolver, 'action_view/template/resolver'
+ autoload :PathSet, 'action_view/paths'
+ autoload :Rendering, 'action_view/render/rendering'
+ autoload :Renderable, 'action_view/template/renderable'
autoload :RenderablePartial, 'action_view/template/partial'
- autoload :Template, 'action_view/template/template'
- autoload :TemplateError, 'action_view/template/error'
- autoload :TemplateHandler, 'action_view/template/handler'
- autoload :TemplateHandlers, 'action_view/template/handlers'
- autoload :TextTemplate, 'action_view/template/text'
- autoload :Helpers, 'action_view/helpers'
+ autoload :Template, 'action_view/template/template'
+ autoload :TemplateError, 'action_view/template/error'
+ autoload :TemplateHandler, 'action_view/template/handler'
+ autoload :TemplateHandlers, 'action_view/template/handlers'
+ autoload :TextTemplate, 'action_view/template/text'
+ autoload :Helpers, 'action_view/helpers'
+ autoload :FileSystemResolverWithFallback, 'action_view/template/resolver'
end
class ERB
Oops, something went wrong.

0 comments on commit b9088dc

Please sign in to comment.