Skip to content
Browse files

Merge

  • Loading branch information...
2 parents ec09545 + f737c2d commit e7ef57dd0ddec3d487d3ffd58ff028bdf11a33f9 @dhh dhh committed Dec 22, 2009
Showing with 354 additions and 385 deletions.
  1. +1 −1 Gemfile
  2. +0 −15 actionmailer/lib/action_mailer.rb
  3. +19 −44 actionmailer/lib/action_mailer/base.rb
  4. +2 −3 actionmailer/lib/action_mailer/delivery_method.rb
  5. +2 −2 actionmailer/lib/action_mailer/delivery_method/smtp.rb
  6. +5 −3 actionmailer/test/mail_service_test.rb
  7. +2 −2 actionmailer/test/url_test.rb
  8. +1 −1 actionpack/actionpack.gemspec
  9. +7 −9 actionpack/lib/abstract_controller.rb
  10. +4 −4 actionpack/lib/abstract_controller/base.rb
  11. +0 −28 actionpack/lib/abstract_controller/logger.rb
  12. +56 −55 actionpack/lib/action_controller.rb
  13. +2 −1 actionpack/lib/action_controller/base.rb
  14. +7 −5 actionpack/lib/action_controller/caching.rb
  15. +1 −1 actionpack/lib/action_controller/metal.rb
  16. +0 −1 actionpack/lib/action_controller/metal/benchmarking.rb
  17. +34 −0 actionpack/lib/action_controller/metal/logger.rb
  18. +3 −0 actionpack/lib/action_controller/metal/rack_delegation.rb
  19. +4 −4 actionpack/lib/action_controller/metal/redirecting.rb
  20. +14 −12 actionpack/lib/action_controller/vendor/html-scanner.rb
  21. +25 −30 actionpack/lib/action_dispatch.rb
  22. +1 −1 actionpack/lib/action_dispatch/http/request.rb
  23. +2 −2 actionpack/lib/action_dispatch/http/response.rb
  24. +0 −33 actionpack/lib/action_dispatch/http/status_codes.rb
  25. +1 −0 actionpack/lib/action_dispatch/middleware/params_parser.rb
  26. +1 −0 actionpack/lib/action_dispatch/middleware/session/abstract_store.rb
  27. +5 −4 actionpack/lib/action_dispatch/middleware/session/cookie_store.rb
  28. +3 −2 actionpack/lib/action_dispatch/middleware/show_exceptions.rb
  29. +3 −1 actionpack/lib/action_dispatch/testing/assertions/dom.rb
  30. +1 −1 actionpack/lib/action_dispatch/testing/assertions/response.rb
  31. +12 −10 actionpack/lib/action_dispatch/testing/assertions/selector.rb
  32. +2 −0 actionpack/lib/action_dispatch/testing/assertions/tag.rb
  33. +21 −20 actionpack/lib/action_view.rb
  34. +1 −0 actionpack/lib/action_view/helpers/sanitize_helper.rb
  35. +8 −6 actionpack/lib/action_view/template.rb
  36. +2 −2 actionpack/test/controller/render_test.rb
  37. +1 −0 activemodel/lib/active_model/validations.rb
  38. +64 −52 activerecord/lib/active_record.rb
  39. +3 −0 activeresource/lib/active_resource/base.rb
  40. +28 −25 activesupport/lib/active_support.rb
  41. +5 −5 activesupport/lib/active_support/dependencies/autoload.rb
  42. +1 −0 railties/lib/rails/application.rb
View
2 Gemfile
@@ -13,7 +13,7 @@ gem "pg", ">= 0.8.0"
gem "mysql", ">= 2.8.1"
# AP
-gem "rack", "1.0.1", :git => "git://github.com/rails/rack.git"
+gem "rack", "1.1.0", :git => "git://github.com/rack/rack.git"
gem "rack-test", "0.5.3"
gem "RedCloth", ">= 4.2.2"
View
15 actionmailer/lib/action_mailer.rb
@@ -41,18 +41,3 @@ module ActionMailer
autoload :TestHelper
autoload :Utils
end
-
-module Text
- extend ActiveSupport::Autoload
-
- autoload :Format, 'action_mailer/vendor/text_format'
-end
-
-module Net
- extend ActiveSupport::Autoload
-
- autoload :SMTP
-end
-
-
-require 'action_mailer/vendor/tmail'
View
63 actionmailer/lib/action_mailer/base.rb
@@ -1,4 +1,7 @@
require 'active_support/core_ext/class'
+require 'action_mailer/part'
+require 'action_mailer/vendor/text_format'
+require 'action_mailer/vendor/tmail'
module ActionMailer #:nodoc:
# Action Mailer allows you to send email from your application using a mailer model and views.
@@ -250,31 +253,21 @@ module ActionMailer #:nodoc:
# <tt>["text/html", "text/enriched", "text/plain"]</tt>. Items that appear first in the array have higher priority in the mail client
# and appear last in the mime encoded message. You can also pick a different order from inside a method with
# +implicit_parts_order+.
- class Base
+ class Base < AbstractController::Base
include AdvAttrAccessor, PartContainer, Quoting, Utils
include AbstractController::Rendering
include AbstractController::LocalizedCache
include AbstractController::Layouts
-
include AbstractController::Helpers
- helper ActionMailer::MailHelper
- if Object.const_defined?(:ActionController)
- include ActionController::UrlWriter
- end
+ helper ActionMailer::MailHelper
+ include ActionController::UrlWriter
include ActionMailer::DeprecatedBody
private_class_method :new #:nodoc:
- class_inheritable_accessor :view_paths
- self.view_paths = []
-
- attr_internal :formats
-
- cattr_accessor :logger
-
@@raise_delivery_errors = true
cattr_accessor :raise_delivery_errors
@@ -346,24 +339,13 @@ class Base
# have multiple mailer methods share the same template.
adv_attr_accessor :template
- # The mail and action_name instances referenced by this mailer.
- attr_reader :mail, :action_name
-
- # Where the response body is stored.
- attr_internal :response_body
-
# Override the mailer name, which defaults to an inflected version of the
# mailer's class name. If you want to use a template in a non-standard
# location, you can use this to specify that location.
- attr_writer :mailer_name
+ adv_attr_accessor :mailer_name
- def mailer_name(value = nil)
- if value
- @mailer_name = value
- else
- @mailer_name || self.class.mailer_name
- end
- end
+ # Expose the internal mail
+ attr_reader :mail
# Alias controller_path to mailer_name so render :partial in views work.
alias :controller_path :mailer_name
@@ -453,18 +435,16 @@ def matches_dynamic_method?(method_name) #:nodoc:
# will be initialized according to the named method. If not, the mailer will
# remain uninitialized (useful when you only need to invoke the "receive"
# method, for instance).
- def initialize(method_name=nil, *parameters) #:nodoc:
- @_formats = []
- @_response_body = nil
+ def initialize(method_name=nil, *args) #:nodoc:
super()
- create!(method_name, *parameters) if method_name
+ process(method_name, *args) if method_name
end
- # Initialize the mailer via the given +method_name+. The body will be
+ # Process the mailer via the given +method_name+. The body will be
# rendered and a new TMail::Mail object created.
- def create!(method_name, *parameters) #:nodoc:
+ def process(method_name, *args) #:nodoc:
initialize_defaults(method_name)
- __send__(method_name, *parameters)
+ super
# Create e-mail parts
create_parts
@@ -473,7 +453,7 @@ def create!(method_name, *parameters) #:nodoc:
@subject ||= I18n.t(:subject, :scope => [:actionmailer, mailer_name, method_name],
:default => method_name.humanize)
- # build the mail object itself
+ # Build the mail object itself
@mail = create_mail
end
@@ -488,7 +468,7 @@ def deliver!(mail = @mail)
logger.debug "\n#{mail.encoded}"
end
- ActiveSupport::Notifications.instrument(:deliver_mail, :mail => @mail) do
+ ActiveSupport::Notifications.instrument(:deliver_mail, :mail => mail) do
begin
self.delivery_method.perform_delivery(mail) if perform_deliveries
rescue Exception => e # Net::SMTP errors or sendmail pipe errors
@@ -510,23 +490,18 @@ def initialize_defaults(method_name)
@implicit_parts_order ||= @@default_implicit_parts_order.dup
@mime_version ||= @@default_mime_version.dup if @@default_mime_version
- @mailer_name ||= self.class.mailer_name
+ @mailer_name ||= self.class.mailer_name.dup
@template ||= method_name
- @action_name = @template
@parts ||= []
@headers ||= {}
@sent_on ||= Time.now
- ActiveSupport::Deprecation.silence do
- super # Run deprecation hooks
- end
+ super # Run deprecation hooks
end
def create_parts
- ActiveSupport::Deprecation.silence do
- super # Run deprecation hooks
- end
+ super # Run deprecation hooks
if String === response_body
@parts.unshift Part.new(
View
5 actionmailer/lib/action_mailer/delivery_method.rb
@@ -1,7 +1,7 @@
-require "active_support/core_ext/class"
+require 'active_support/core_ext/class'
+
module ActionMailer
module DeliveryMethod
-
autoload :File, 'action_mailer/delivery_method/file'
autoload :Sendmail, 'action_mailer/delivery_method/sendmail'
autoload :Smtp, 'action_mailer/delivery_method/smtp'
@@ -52,6 +52,5 @@ class Method
superclass_delegating_accessor :settings
self.settings = {}
end
-
end
end
View
4 actionmailer/lib/action_mailer/delivery_method/smtp.rb
@@ -1,8 +1,9 @@
+require 'net/smtp'
+
module ActionMailer
module DeliveryMethod
# A delivery method implementation which sends via smtp.
class Smtp < Method
-
self.settings = {
:address => "localhost",
:port => 25,
@@ -26,6 +27,5 @@ def perform_delivery(mail)
end
end
end
-
end
end
View
8 actionmailer/test/mail_service_test.rb
@@ -34,13 +34,13 @@ def cancelled_account(recipient)
def from_with_name
from "System <system@loudthinking.com>"
recipients "root@loudthinking.com"
- body "Nothing to see here."
+ render :text => "Nothing to see here."
end
def from_without_name
from "system@loudthinking.com"
recipients "root@loudthinking.com"
- body "Nothing to see here."
+ render :text => "Nothing to see here."
end
def cc_bcc(recipient)
@@ -301,6 +301,7 @@ def return_path
render :text => "testing"
end
+ # This tests body calls accepeting a hash, which is deprecated.
def body_ivar(recipient)
recipients recipient
subject "Body as a local variable"
@@ -1043,7 +1044,8 @@ def test_return_path_with_deliver
end
def test_body_is_stored_as_an_ivar
- mail = TestMailer.create_body_ivar(@recipient)
+ mail = nil
+ ActiveSupport::Deprecation.silence { mail = TestMailer.create_body_ivar(@recipient) }
assert_equal "body: foo\nbar: baz", mail.body
end
View
4 actionmailer/test/url_test.rb
@@ -12,8 +12,8 @@ def signed_up_with_url(recipient)
@from = "system@loudthinking.com"
@sent_on = Time.local(2004, 12, 12)
- @body["recipient"] = recipient
- @body["welcome_url"] = url_for :host => "example.com", :controller => "welcome", :action => "greeting"
+ @recipient = recipient
+ @welcome_url = url_for :host => "example.com", :controller => "welcome", :action => "greeting"
end
class <<self
View
2 actionpack/actionpack.gemspec
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
s.add_dependency('activesupport', '= 3.0.pre')
s.add_dependency('activemodel', '= 3.0.pre')
- s.add_dependency('rack', '~> 1.0.1')
+ s.add_dependency('rack', '~> 1.1.0')
s.add_dependency('rack-test', '~> 0.5.0')
s.add_dependency('rack-mount', '~> 0.3.2')
s.add_dependency('erubis', '~> 2.6.5')
View
16 actionpack/lib/abstract_controller.rb
@@ -8,13 +8,11 @@
module AbstractController
extend ActiveSupport::Autoload
- deferrable do
- autoload :Base
- autoload :Callbacks
- autoload :Helpers
- autoload :Layouts
- autoload :LocalizedCache
- autoload :Logger
- autoload :Rendering
- end
+ autoload :Base
+ autoload :Callbacks
+ autoload :Helpers
+ autoload :Layouts
+ autoload :LocalizedCache
+ autoload :Logger
+ autoload :Rendering
end
View
8 actionpack/lib/abstract_controller/base.rb
@@ -84,7 +84,7 @@ def action_methods
#
# ==== Returns
# self
- def process(action)
+ def process(action, *args)
@_action_name = action_name = action.to_s
unless action_name = method_for_action(action_name)
@@ -93,7 +93,7 @@ def process(action)
@_response_body = nil
- process_action(action_name)
+ process_action(action_name, *args)
end
private
@@ -113,8 +113,8 @@ def action_method?(name)
# Call the action. Override this in a subclass to modify the
# behavior around processing an action. This, and not #process,
# is the intended way to override action dispatching.
- def process_action(method_name)
- send_action(method_name)
+ def process_action(method_name, *args)
+ send_action(method_name, *args)
end
# Actually call the method associated with the action. Override
View
28 actionpack/lib/abstract_controller/logger.rb
@@ -29,33 +29,5 @@ def method_missing(*args, &block)
@str.send(*args, &block)
end
end
-
- # Override process_action in the AbstractController::Base
- # to log details about the method.
- def process_action(action)
- result = ActiveSupport::Notifications.instrument(:process_action,
- :controller => self, :action => action) do
- super
- end
-
- if logger
- log = DelayedLog.new do
- "\n\nProcessing #{self.class.name}\##{action_name} " \
- "to #{request.formats} (for #{request_origin}) " \
- "[#{request.method.to_s.upcase}]"
- end
-
- logger.info(log)
- end
-
- result
- end
-
- private
- # Returns the request origin with the IP and time. This needs to be cached,
- # otherwise we would get different results for each time it calls.
- def request_origin
- @request_origin ||= "#{request.remote_ip} at #{Time.now.to_s(:db)}"
- end
end
end
View
111 actionpack/lib/action_controller.rb
@@ -5,65 +5,66 @@
module ActionController
extend ActiveSupport::Autoload
- deferrable do
- autoload :Base
- autoload :Caching
- autoload :PolymorphicRoutes
- autoload :Translation
- autoload :Metal
- autoload :Middleware
+ autoload :Base
+ autoload :Caching
+ autoload :PolymorphicRoutes
+ autoload :Translation
+ autoload :Metal
+ autoload :Middleware
- autoload_under "metal" do
- autoload :Benchmarking
- autoload :ConditionalGet
- autoload :Configuration
- autoload :Head
- autoload :Helpers
- autoload :HideActions
- autoload :Layouts
- autoload :MimeResponds
- autoload :RackDelegation
- autoload :Compatibility
- autoload :Redirecting
- autoload :Rendering
- autoload :Renderers
- autoload :Rescue
- autoload :Responder
- autoload :SessionManagement
- autoload :UrlFor
- autoload :Verification
- autoload :Flash
- autoload :RequestForgeryProtection
- autoload :Streaming
- autoload :HttpAuthentication
- autoload :FilterParameterLogging
- autoload :Cookies
- end
-
- autoload :Dispatcher, 'action_controller/dispatch/dispatcher'
- autoload :PerformanceTest, 'action_controller/deprecated/performance_test'
- autoload :Routing, 'action_controller/deprecated'
- autoload :Integration, 'action_controller/deprecated/integration_test'
- autoload :IntegrationTest, 'action_controller/deprecated/integration_test'
+ autoload_under "metal" do
+ autoload :Benchmarking
+ autoload :ConditionalGet
+ autoload :Configuration
+ autoload :Head
+ autoload :Helpers
+ autoload :HideActions
+ autoload :Layouts
+ autoload :Logger
+ autoload :MimeResponds
+ autoload :RackDelegation
+ autoload :Compatibility
+ autoload :Redirecting
+ autoload :Rendering
+ autoload :Renderers
+ autoload :Rescue
+ autoload :Responder
+ autoload :SessionManagement
+ autoload :UrlFor
+ autoload :Verification
+ autoload :Flash
+ autoload :RequestForgeryProtection
+ autoload :Streaming
+ autoload :HttpAuthentication
+ autoload :FilterParameterLogging
+ autoload :Cookies
end
- autoload :RecordIdentifier
- autoload :UrlRewriter
- autoload :UrlWriter, 'action_controller/url_rewriter'
+ autoload :Dispatcher, 'action_controller/dispatch/dispatcher'
+ autoload :PerformanceTest, 'action_controller/deprecated/performance_test'
+ autoload :Routing, 'action_controller/deprecated'
+ autoload :Integration, 'action_controller/deprecated/integration_test'
+ autoload :IntegrationTest, 'action_controller/deprecated/integration_test'
- # TODO: Don't autoload exceptions, setup explicit
- # requires for files that need them
- autoload_at "action_controller/metal/exceptions" do
- autoload :ActionControllerError
- autoload :RenderError
- autoload :RoutingError
- autoload :MethodNotAllowed
- autoload :NotImplemented
- autoload :UnknownController
- autoload :MissingFile
- autoload :RenderError
- autoload :SessionOverflowError
- autoload :UnknownHttpMethod
+ eager_autoload do
+ autoload :RecordIdentifier
+ autoload :UrlRewriter
+ autoload :UrlWriter, 'action_controller/url_rewriter'
+
+ # TODO: Don't autoload exceptions, setup explicit
+ # requires for files that need them
+ autoload_at "action_controller/metal/exceptions" do
+ autoload :ActionControllerError
+ autoload :RenderError
+ autoload :RoutingError
+ autoload :MethodNotAllowed
+ autoload :NotImplemented
+ autoload :UnknownController
+ autoload :MissingFile
+ autoload :RenderError
+ autoload :SessionOverflowError
+ autoload :UnknownHttpMethod
+ end
end
end
View
3 actionpack/lib/action_controller/base.rb
@@ -14,6 +14,7 @@ class Base < Metal
include ActionController::Layouts
include ActionController::ConditionalGet
include ActionController::RackDelegation
+ include ActionController::Logger
include ActionController::Benchmarking
include ActionController::Configuration
@@ -89,7 +90,7 @@ def _normalize_options(action = nil, options = {}, &blk)
end
if options[:status]
- options[:status] = ActionDispatch::StatusCodes[options[:status]]
+ options[:status] = Rack::Utils.status_code(options[:status])
end
options[:update] = blk if block_given?
View
12 actionpack/lib/action_controller/caching.rb
@@ -32,11 +32,13 @@ module Caching
extend ActiveSupport::Concern
extend ActiveSupport::Autoload
- autoload :Actions
- autoload :Fragments
- autoload :Pages
- autoload :Sweeper, 'action_controller/caching/sweeping'
- autoload :Sweeping, 'action_controller/caching/sweeping'
+ eager_autoload do
+ autoload :Actions
+ autoload :Fragments
+ autoload :Pages
+ autoload :Sweeper, 'action_controller/caching/sweeping'
+ autoload :Sweeping, 'action_controller/caching/sweeping'
+ end
included do
@@cache_store = nil
View
2 actionpack/lib/action_controller/metal.rb
@@ -69,7 +69,7 @@ def location=(url)
end
def status=(status)
- @_status = ActionDispatch::StatusCodes[status]
+ @_status = Rack::Utils.status_code(status)
end
# :api: private
View
1 actionpack/lib/action_controller/metal/benchmarking.rb
@@ -53,7 +53,6 @@ def process_action(*args)
log_message << " [#{complete_request_uri rescue "unknown"}]"
logger.info(log_message)
- response.headers["X-Runtime"] = "%.0f" % ms
else
super
end
View
34 actionpack/lib/action_controller/metal/logger.rb
@@ -0,0 +1,34 @@
+require 'abstract_controller/logger'
+
+module ActionController
+ module Logger
+ # Override process_action in the AbstractController::Base
+ # to log details about the method.
+ def process_action(action)
+ result = ActiveSupport::Notifications.instrument(:process_action,
+ :controller => self, :action => action) do
+ super
+ end
+
+ if logger
+ log = AbstractController::Logger::DelayedLog.new do
+ "\n\nProcessing #{self.class.name}\##{action_name} " \
+ "to #{request.formats} (for #{request_origin}) " \
+ "[#{request.method.to_s.upcase}]"
+ end
+
+ logger.info(log)
+ end
+
+ result
+ end
+
+ private
+
+ # Returns the request origin with the IP and time. This needs to be cached,
+ # otherwise we would get different results for each time it calls.
+ def request_origin
+ @request_origin ||= "#{request.remote_ip} at #{Time.now.to_s(:db)}"
+ end
+ end
+end
View
3 actionpack/lib/action_controller/metal/rack_delegation.rb
@@ -1,3 +1,6 @@
+require 'action_dispatch/http/request'
+require 'action_dispatch/http/response'
+
module ActionController
module RackDelegation
extend ActiveSupport::Concern
View
8 actionpack/lib/action_controller/metal/redirecting.rb
@@ -58,18 +58,18 @@ def redirect_to(options = {}, response_status = {}) #:doc:
logger.info("Redirected to #{location}") if logger && logger.info?
end
-
+
private
def _extract_redirect_to_status(options, response_status)
status = if options.is_a?(Hash) && options.key?(:status)
- ActionDispatch::StatusCodes[options.delete(:status)]
+ Rack::Utils.status_code(options.delete(:status))
elsif response_status.key?(:status)
- ActionDispatch::StatusCodes[response_status[:status]]
+ Rack::Utils.status_code(response_status[:status])
else
302
end
end
-
+
def _compute_redirect_to_location(options)
case options
# The scheme name consist of a letter followed by any combination of
View
26 actionpack/lib/action_controller/vendor/html-scanner.rb
@@ -3,16 +3,18 @@
module HTML
extend ActiveSupport::Autoload
- autoload :CDATA, 'html/node'
- autoload :Document, 'html/document'
- autoload :FullSanitizer, 'html/sanitizer'
- autoload :LinkSanitizer, 'html/sanitizer'
- autoload :Node, 'html/node'
- autoload :Sanitizer, 'html/sanitizer'
- autoload :Selector, 'html/selector'
- autoload :Tag, 'html/node'
- autoload :Text, 'html/node'
- autoload :Tokenizer, 'html/tokenizer'
- autoload :Version, 'html/version'
- autoload :WhiteListSanitizer, 'html/sanitizer'
+ eager_autoload do
+ autoload :CDATA, 'html/node'
+ autoload :Document, 'html/document'
+ autoload :FullSanitizer, 'html/sanitizer'
+ autoload :LinkSanitizer, 'html/sanitizer'
+ autoload :Node, 'html/node'
+ autoload :Sanitizer, 'html/sanitizer'
+ autoload :Selector, 'html/selector'
+ autoload :Tag, 'html/node'
+ autoload :Text, 'html/node'
+ autoload :Tokenizer, 'html/tokenizer'
+ autoload :Version, 'html/version'
+ autoload :WhiteListSanitizer, 'html/sanitizer'
+ end
end
View
55 actionpack/lib/action_dispatch.rb
@@ -37,43 +37,38 @@ module ActionDispatch
autoload_under 'http' do
autoload :Request
autoload :Response
- autoload :StatusCodes
end
- deferrable do
- autoload_under 'middleware' do
- autoload :Callbacks
- autoload :ParamsParser
- autoload :Rescue
- autoload :ShowExceptions
- autoload :Static
- autoload :StringCoercion
- end
-
- autoload :MiddlewareStack, 'action_dispatch/middleware/stack'
- autoload :Routing
+ autoload_under 'middleware' do
+ autoload :Callbacks
+ autoload :ParamsParser
+ autoload :Rescue
+ autoload :ShowExceptions
+ autoload :Static
+ autoload :StringCoercion
+ end
- module Http
- autoload :Headers, 'action_dispatch/http/headers'
- end
+ autoload :MiddlewareStack, 'action_dispatch/middleware/stack'
+ autoload :Routing
- module Session
- autoload :AbstractStore, 'action_dispatch/middleware/session/abstract_store'
- autoload :CookieStore, 'action_dispatch/middleware/session/cookie_store'
- autoload :MemCacheStore, 'action_dispatch/middleware/session/mem_cache_store'
- end
+ module Http
+ autoload :Headers, 'action_dispatch/http/headers'
+ end
- autoload_under 'testing' do
- autoload :Assertions
- autoload :Integration
- autoload :PerformanceTest
- autoload :TestProcess
- autoload :TestRequest
- autoload :TestResponse
- end
+ module Session
+ autoload :AbstractStore, 'action_dispatch/middleware/session/abstract_store'
+ autoload :CookieStore, 'action_dispatch/middleware/session/cookie_store'
+ autoload :MemCacheStore, 'action_dispatch/middleware/session/mem_cache_store'
end
- autoload :HTML, 'action_controller/vendor/html-scanner'
+ autoload_under 'testing' do
+ autoload :Assertions
+ autoload :Integration
+ autoload :PerformanceTest
+ autoload :TestProcess
+ autoload :TestRequest
+ autoload :TestResponse
+ end
end
autoload :Mime, 'action_dispatch/http/mime_type'
View
2 actionpack/lib/action_dispatch/http/request.rb
@@ -18,7 +18,7 @@ class Request < Rack::Request
HTTP_ACCEPT HTTP_ACCEPT_CHARSET HTTP_ACCEPT_ENCODING
HTTP_ACCEPT_LANGUAGE HTTP_CACHE_CONTROL HTTP_FROM
- HTTP_NEGOTIATE HTTP_PRAGMA HTTP_REFERER HTTP_USER_AGENT ].each do |env|
+ HTTP_NEGOTIATE HTTP_PRAGMA ].each do |env|
define_method(env.sub(/^HTTP_/n, '').downcase) do
@env[env]
end
View
4 actionpack/lib/action_dispatch/http/response.rb
@@ -60,7 +60,7 @@ def cache_control
end
def status=(status)
- @status = ActionDispatch::StatusCodes[status]
+ @status = Rack::Utils.status_code(status)
end
# The response code of the request
@@ -74,7 +74,7 @@ def code
end
def message
- StatusCodes::STATUS_CODES[@status]
+ Rack::Utils::HTTP_STATUS_CODES[@status]
end
alias_method :status_message, :message
View
33 actionpack/lib/action_dispatch/http/status_codes.rb
@@ -1,33 +0,0 @@
-require 'active_support/inflector'
-
-module ActionDispatch
- module StatusCodes #:nodoc:
- STATUS_CODES = Rack::Utils::HTTP_STATUS_CODES.merge({
- 102 => "Processing",
- 207 => "Multi-Status",
- 226 => "IM Used",
- 422 => "Unprocessable Entity",
- 423 => "Locked",
- 424 => "Failed Dependency",
- 426 => "Upgrade Required",
- 507 => "Insufficient Storage",
- 510 => "Not Extended"
- }).freeze
-
- def self.[](status)
- if status.is_a?(Symbol)
- SYMBOL_TO_STATUS_CODE[status] || 500
- else
- status.to_i
- end
- end
-
- # Provides a symbol-to-fixnum lookup for converting a symbol (like
- # :created or :not_implemented) into its corresponding HTTP status
- # code (like 200 or 501).
- SYMBOL_TO_STATUS_CODE = STATUS_CODES.inject({}) { |hash, (code, message)|
- hash[ActiveSupport::Inflector.underscore(message.gsub(/ /, "")).to_sym] = code
- hash
- }.freeze
- end
-end
View
1 actionpack/lib/action_dispatch/middleware/params_parser.rb
@@ -1,4 +1,5 @@
require 'active_support/json'
+require 'action_dispatch/http/request'
module ActionDispatch
class ParamsParser
View
1 actionpack/lib/action_dispatch/middleware/session/abstract_store.rb
@@ -1,4 +1,5 @@
require 'rack/utils'
+require 'rack/request'
module ActionDispatch
module Session
View
9 actionpack/lib/action_dispatch/middleware/session/cookie_store.rb
@@ -1,4 +1,5 @@
-require "active_support/core_ext/hash/keys"
+require 'active_support/core_ext/hash/keys'
+require 'rack/request'
module ActionDispatch
module Session
@@ -49,7 +50,7 @@ class CookieStore
:expire_after => nil,
:httponly => true
}.freeze
-
+
class OptionsHash < Hash
def initialize(by, env, default_options)
@session_data = env[CookieStore::ENV_SESSION_KEY]
@@ -60,7 +61,7 @@ def [](key)
key == :id ? @session_data[:session_id] : super(key)
end
end
-
+
ENV_SESSION_KEY = "rack.session".freeze
ENV_SESSION_OPTIONS_KEY = "rack.session.options".freeze
HTTP_SET_COOKIE = "Set-Cookie".freeze
@@ -102,7 +103,7 @@ def initialize(app, options = {})
def call(env)
env[ENV_SESSION_KEY] = AbstractStore::SessionHash.new(self, env)
env[ENV_SESSION_OPTIONS_KEY] = OptionsHash.new(self, env, @default_options)
-
+
status, headers, body = @app.call(env)
session_data = env[ENV_SESSION_KEY]
View
5 actionpack/lib/action_dispatch/middleware/show_exceptions.rb
@@ -1,4 +1,5 @@
-require "active_support/core_ext/exception"
+require 'active_support/core_ext/exception'
+require 'action_dispatch/http/request'
module ActionDispatch
class ShowExceptions
@@ -101,7 +102,7 @@ def local_request?(request)
end
def status_code(exception)
- ActionDispatch::StatusCodes::SYMBOL_TO_STATUS_CODE[@@rescue_responses[exception.class.name]]
+ Rack::Utils.status_code(@@rescue_responses[exception.class.name])
end
def render(status, body)
View
4 actionpack/lib/action_dispatch/testing/assertions/dom.rb
@@ -1,3 +1,5 @@
+require 'action_controller/vendor/html-scanner'
+
module ActionDispatch
module Assertions
module DomAssertions
@@ -15,7 +17,7 @@ def assert_dom_equal(expected, actual, message = "")
assert_block(full_message) { expected_dom == actual_dom }
end
-
+
# The negated form of +assert_dom_equivalent+.
#
# ==== Examples
View
2 actionpack/lib/action_dispatch/testing/assertions/response.rb
@@ -28,7 +28,7 @@ def assert_response(type, message = nil)
assert_block("") { true } # to count the assertion
elsif type.is_a?(Fixnum) && @response.response_code == type
assert_block("") { true } # to count the assertion
- elsif type.is_a?(Symbol) && @response.response_code == ActionDispatch::StatusCodes::SYMBOL_TO_STATUS_CODE[type]
+ elsif type.is_a?(Symbol) && @response.response_code == Rack::Utils::SYMBOL_TO_STATUS_CODE[type]
assert_block("") { true } # to count the assertion
else
assert_block(build_message(message, "Expected response to be a <?>, but was <?>", type, @response.response_code)) { false }
View
22 actionpack/lib/action_dispatch/testing/assertions/selector.rb
@@ -1,3 +1,5 @@
+require 'action_controller/vendor/html-scanner'
+
#--
# Copyright (c) 2006 Assaf Arkin (http://labnotes.org)
# Under MIT and/or CC By license.
@@ -16,7 +18,7 @@ module Assertions
#
# Use +css_select+ to select elements without making an assertions, either
# from the response HTML or elements selected by the enclosing assertion.
- #
+ #
# In addition to HTML responses, you can make the following assertions:
# * +assert_select_rjs+ - Assertions on HTML content of RJS update and insertion operations.
# * +assert_select_encoded+ - Assertions on HTML encoded inside XML, for example for dealing with feed item descriptions.
@@ -53,8 +55,8 @@ module SelectorAssertions
# end
#
# # Selects all list items in unordered lists
- # items = css_select("ul>li")
- #
+ # items = css_select("ul>li")
+ #
# # Selects all form tags and then all inputs inside the form
# forms = css_select("form")
# forms.each do |form|
@@ -212,7 +214,7 @@ def assert_select(*args, &block)
# Otherwise just operate on the response document.
root = response_from_page_or_rjs
end
-
+
# First or second argument is the selector: string and we pass
# all remaining arguments. Array and we pass the argument. Also
# accepts selector itself.
@@ -225,7 +227,7 @@ def assert_select(*args, &block)
selector = arg
else raise ArgumentError, "Expecting a selector as the first argument"
end
-
+
# Next argument is used for equality tests.
equals = {}
case arg = args.shift
@@ -315,10 +317,10 @@ def assert_select(*args, &block)
# Returns all matches elements.
matches
end
-
+
def count_description(min, max) #:nodoc:
pluralize = lambda {|word, quantity| word << (quantity == 1 ? '' : 's')}
-
+
if min && max && (max != min)
"between #{min} and #{max} elements"
elsif min && !(min == 1 && max == 1)
@@ -327,7 +329,7 @@ def count_description(min, max) #:nodoc:
"at most #{max} #{pluralize['element', max]}"
end
end
-
+
# :call-seq:
# assert_select_rjs(id?) { |elements| ... }
# assert_select_rjs(statement, id?) { |elements| ... }
@@ -344,7 +346,7 @@ def count_description(min, max) #:nodoc:
# that update or insert an element with that identifier.
#
# Use the first argument to narrow down assertions to only statements
- # of that type. Possible values are <tt>:replace</tt>, <tt>:replace_html</tt>,
+ # of that type. Possible values are <tt>:replace</tt>, <tt>:replace_html</tt>,
# <tt>:show</tt>, <tt>:hide</tt>, <tt>:toggle</tt>, <tt>:remove</tta>,
# <tt>:insert_html</tt> and <tt>:redirect</tt>.
#
@@ -494,7 +496,7 @@ def assert_select_rjs(*args, &block)
# end
# end
# end
- #
+ #
#
# # Selects all paragraph tags from within the description of an RSS feed
# assert_select_feed :rss, 2.0 do
View
2 actionpack/lib/action_dispatch/testing/assertions/tag.rb
@@ -1,3 +1,5 @@
+require 'action_controller/vendor/html-scanner'
+
module ActionDispatch
module Assertions
# Pair of assertions to testing elements in the HTML output of the response.
View
41 actionpack/lib/action_view.rb
@@ -31,27 +31,28 @@
module ActionView
extend ActiveSupport::Autoload
- autoload :Base
- autoload :Context
- autoload :Template
- autoload :Helpers
- autoload :SafeBuffer
-
-
- autoload_under "render" do
- autoload :Partials
- autoload :Rendering
+ eager_autoload do
+ autoload :Base
+ autoload :Context
+ autoload :Template
+ autoload :Helpers
+ autoload :SafeBuffer
+
+ autoload_under "render" do
+ autoload :Partials
+ autoload :Rendering
+ end
+
+ autoload :MissingTemplate, 'action_view/base'
+ autoload :Resolver, 'action_view/template/resolver'
+ autoload :PathResolver, 'action_view/template/resolver'
+ autoload :PathSet, 'action_view/paths'
+ autoload :FileSystemResolverWithFallback, 'action_view/template/resolver'
+
+ autoload :TemplateError, 'action_view/template/error'
+ autoload :TemplateHandler, 'action_view/template'
+ autoload :TemplateHandlers, 'action_view/template'
end
-
- autoload :MissingTemplate, 'action_view/base'
- autoload :Resolver, 'action_view/template/resolver'
- autoload :PathResolver, 'action_view/template/resolver'
- autoload :PathSet, 'action_view/paths'
- autoload :FileSystemResolverWithFallback, 'action_view/template/resolver'
-
- autoload :TemplateError, 'action_view/template/error'
- autoload :TemplateHandler, 'action_view/template'
- autoload :TemplateHandlers, 'action_view/template'
end
require 'action_view/erb/util'
View
1 actionpack/lib/action_view/helpers/sanitize_helper.rb
@@ -1,3 +1,4 @@
+require 'action_controller/vendor/html-scanner'
require 'action_view/helpers/tag_helper'
module ActionView
View
14 actionpack/lib/action_view/template.rb
@@ -7,12 +7,14 @@
module ActionView
class Template
extend ActiveSupport::Autoload
-
- autoload :Error
- autoload :Handler
- autoload :Handlers
- autoload :Text
-
+
+ eager_autoload do
+ autoload :Error
+ autoload :Handler
+ autoload :Handlers
+ autoload :Text
+ end
+
extend Template::Handlers
attr_reader :source, :identifier, :handler, :mime_type, :formats, :details
View
4 actionpack/test/controller/render_test.rb
@@ -1125,15 +1125,15 @@ def test_head_with_symbolic_status
assert !@response.headers.include?('Content-Length')
assert_response :no_content
- ActionDispatch::StatusCodes::SYMBOL_TO_STATUS_CODE.each do |status, code|
+ Rack::Utils::SYMBOL_TO_STATUS_CODE.each do |status, code|
get :head_with_symbolic_status, :status => status.to_s
assert_equal code, @response.response_code
assert_response status
end
end
def test_head_with_integer_status
- ActionDispatch::StatusCodes::STATUS_CODES.each do |code, message|
+ Rack::Utils::HTTP_STATUS_CODES.each do |code, message|
get :head_with_integer_status, :status => code.to_s
assert_equal message, @response.message
end
View
1 activemodel/lib/active_model/validations.rb
@@ -1,5 +1,6 @@
require 'active_support/core_ext/array/extract_options'
require 'active_support/core_ext/hash/keys'
+require 'active_model/errors'
module ActiveModel
module Validations
View
116 activerecord/lib/active_record.rb
@@ -35,82 +35,94 @@
module ActiveRecord
extend ActiveSupport::Autoload
- autoload :VERSION
-
- autoload :ActiveRecordError, 'active_record/base'
- autoload :ConnectionNotEstablished, 'active_record/base'
-
- autoload :Aggregations
- autoload :AssociationPreload
- autoload :Associations
- autoload :AttributeMethods
- autoload :Attributes
- autoload :AutosaveAssociation
- autoload :Relation
- autoload :Base
- autoload :Batches
- autoload :Calculations
- autoload :Callbacks
- autoload :DynamicFinderMatch
- autoload :DynamicScopeMatch
- autoload :Migration
- autoload :Migrator, 'active_record/migration'
- autoload :NamedScope
- autoload :NestedAttributes
- autoload :Observer
- autoload :QueryCache
- autoload :Reflection
- autoload :Schema
- autoload :SchemaDumper
- autoload :Serialization
- autoload :SessionStore
- autoload :StateMachine
- autoload :Timestamp
- autoload :Transactions
- autoload :Types
- autoload :Validations
+ eager_autoload do
+ autoload :VERSION
+
+ autoload :ActiveRecordError, 'active_record/base'
+ autoload :ConnectionNotEstablished, 'active_record/base'
+
+ autoload :Aggregations
+ autoload :AssociationPreload
+ autoload :Associations
+ autoload :AttributeMethods
+ autoload :Attributes
+ autoload :AutosaveAssociation
+ autoload :Relation
+ autoload :Base
+ autoload :Batches
+ autoload :Calculations
+ autoload :Callbacks
+ autoload :DynamicFinderMatch
+ autoload :DynamicScopeMatch
+ autoload :Migration
+ autoload :Migrator, 'active_record/migration'
+ autoload :NamedScope
+ autoload :NestedAttributes
+ autoload :Observer
+ autoload :QueryCache
+ autoload :Reflection
+ autoload :Schema
+ autoload :SchemaDumper
+ autoload :Serialization
+ autoload :SessionStore
+ autoload :StateMachine
+ autoload :Timestamp
+ autoload :Transactions
+ autoload :Types
+ autoload :Validations
+ end
module AttributeMethods
extend ActiveSupport::Autoload
- autoload :BeforeTypeCast
- autoload :Dirty
- autoload :PrimaryKey
- autoload :Query
- autoload :Read
- autoload :TimeZoneConversion
- autoload :Write
+ eager_autoload do
+ autoload :BeforeTypeCast
+ autoload :Dirty
+ autoload :PrimaryKey
+ autoload :Query
+ autoload :Read
+ autoload :TimeZoneConversion
+ autoload :Write
+ end
end
module Attributes
extend ActiveSupport::Autoload
- autoload :Aliasing
- autoload :Store
- autoload :Typecasting
+ eager_autoload do
+ autoload :Aliasing
+ autoload :Store
+ autoload :Typecasting
+ end
end
module Type
extend ActiveSupport::Autoload
- autoload :Number, 'active_record/types/number'
- autoload :Object, 'active_record/types/object'
- autoload :Serialize, 'active_record/types/serialize'
- autoload :TimeWithZone, 'active_record/types/time_with_zone'
- autoload :Unknown, 'active_record/types/unknown'
+ eager_autoload do
+ autoload :Number, 'active_record/types/number'
+ autoload :Object, 'active_record/types/object'
+ autoload :Serialize, 'active_record/types/serialize'
+ autoload :TimeWithZone, 'active_record/types/time_with_zone'
+ autoload :Unknown, 'active_record/types/unknown'
+ end
end
module Locking
extend ActiveSupport::Autoload
- autoload :Optimistic
- autoload :Pessimistic
+ eager_autoload do
+ autoload :Optimistic
+ autoload :Pessimistic
+ end
end
module ConnectionAdapters
extend ActiveSupport::Autoload
- autoload :AbstractAdapter
+ eager_autoload do
+ autoload :AbstractAdapter
+ end
end
end
View
3 activeresource/lib/active_resource/base.rb
@@ -13,6 +13,9 @@
require 'uri'
require 'active_resource/exceptions'
+require 'active_resource/connection'
+require 'active_resource/formats'
+require 'active_resource/schema'
module ActiveResource
# ActiveResource::Base is the main class for mapping RESTful resources as models in a Rails application.
View
53 activesupport/lib/active_support.rb
@@ -39,31 +39,34 @@ def load_all!; load_all_hooks.each { |hook| hook.call } end
module ActiveSupport
extend ActiveSupport::Autoload
- autoload :BacktraceCleaner
- autoload :Base64
- autoload :BasicObject
- autoload :Benchmarkable
- autoload :BufferedLogger
- autoload :Cache
- autoload :Callbacks
- autoload :Concern
- autoload :Configurable
- autoload :DeprecatedCallbacks
- autoload :Deprecation
- autoload :Gzip
- autoload :Inflector
- autoload :Memoizable
- autoload :MessageEncryptor
- autoload :MessageVerifier
- autoload :Multibyte
- autoload :OptionMerger
- autoload :OrderedHash
- autoload :OrderedOptions
- autoload :Notifications
- autoload :Rescuable
- autoload :SecureRandom
- autoload :StringInquirer
- autoload :XmlMini
+ # TODO: Narrow this list down
+ eager_autoload do
+ autoload :BacktraceCleaner
+ autoload :Base64
+ autoload :BasicObject
+ autoload :Benchmarkable
+ autoload :BufferedLogger
+ autoload :Cache
+ autoload :Callbacks
+ autoload :Concern
+ autoload :Configurable
+ autoload :DeprecatedCallbacks
+ autoload :Deprecation
+ autoload :Gzip
+ autoload :Inflector
+ autoload :Memoizable
+ autoload :MessageEncryptor
+ autoload :MessageVerifier
+ autoload :Multibyte
+ autoload :OptionMerger
+ autoload :OrderedHash
+ autoload :OrderedOptions
+ autoload :Notifications
+ autoload :Rescuable
+ autoload :SecureRandom
+ autoload :StringInquirer
+ autoload :XmlMini
+ end
end
require 'active_support/vendor'
View
10 activesupport/lib/active_support/dependencies/autoload.rb
@@ -5,13 +5,13 @@ module Autoload
@@autoloads = {}
@@under_path = nil
@@at_path = nil
- @@autoload_defer = false
+ @@eager_autoload = false
def autoload(const_name, path = @@at_path)
full = [self.name, @@under_path, const_name.to_s, path].compact.join("::")
location = path || Inflector.underscore(full)
- unless @@autoload_defer
+ if @@eager_autoload
@@autoloads[const_name] = location
end
super const_name, location
@@ -31,11 +31,11 @@ def autoload_at(path)
@@at_path = old_path
end
- def deferrable
- old_defer, @@autoload_defer = @@autoload_defer, true
+ def eager_autoload
+ old_eager, @@eager_autoload = @@eager_autoload, true
yield
ensure
- @@autoload_defer = old_defer
+ @@eager_autoload = old_eager
end
def self.eager_autoload!
View
1 railties/lib/rails/application.rb
@@ -208,6 +208,7 @@ def call(env)
initializer :initialize_middleware_stack do
if config.frameworks.include?(:action_controller)
config.middleware.use(::Rack::Lock, :if => lambda { ActionController::Base.allow_concurrency })
+ config.middleware.use(::Rack::Runtime)
config.middleware.use(ActionDispatch::ShowExceptions, lambda { ActionController::Base.consider_all_requests_local })
config.middleware.use(ActionDispatch::Callbacks, lambda { ActionController::Dispatcher.prepare_each_request })
config.middleware.use(lambda { ActionController::Base.session_store }, lambda { ActionController::Base.session_options })

0 comments on commit e7ef57d

Please sign in to comment.
Something went wrong with that request. Please try again.