Permalink
Browse files

Merge branch 'master' of git@github.com:lifo/docrails

  • Loading branch information...
2 parents c5069bd + e8f7da6 commit f08a78a057782577d5efbc82662d7898e26dcb8c Ahmed El-Daly committed Jan 22, 2009
Showing with 2,986 additions and 1,834 deletions.
  1. +1 −1 actionmailer/MIT-LICENSE
  2. +1 −1 actionmailer/lib/action_mailer.rb
  3. +13 −7 actionmailer/lib/action_mailer/base.rb
  4. +12 −0 actionmailer/test/mail_service_test.rb
  5. +4 −2 actionmailer/test/quoting_test.rb
  6. +1 −1 actionpack/MIT-LICENSE
  7. +3 −2 actionpack/lib/action_controller.rb
  8. +1 −4 actionpack/lib/action_controller/base.rb
  9. +0 −16 actionpack/lib/action_controller/lock.rb
  10. +2 −1 actionpack/lib/action_controller/middlewares.rb
  11. +71 −0 actionpack/lib/action_controller/params_parser.rb
  12. +3 −22 actionpack/lib/action_controller/rack_ext.rb
  13. +21 −0 actionpack/lib/action_controller/rack_ext/lock.rb
  14. +22 −0 actionpack/lib/action_controller/rack_ext/multipart.rb
  15. +18 −0 actionpack/lib/action_controller/rack_ext/parse_query.rb
  16. +24 −10 actionpack/lib/action_controller/request.rb
  17. +0 −315 actionpack/lib/action_controller/request_parser.rb
  18. +0 −168 actionpack/lib/action_controller/request_profiler.rb
  19. +7 −23 actionpack/lib/action_controller/rewindable_input.rb
  20. +7 −0 actionpack/lib/action_controller/uploaded_file.rb
  21. +61 −0 actionpack/lib/action_controller/url_encoded_pair_parser.rb
  22. +1 −1 actionpack/lib/action_pack.rb
  23. +1 −1 actionpack/lib/action_view.rb
  24. +62 −44 actionpack/lib/action_view/helpers/asset_tag_helper.rb
  25. +5 −5 actionpack/lib/action_view/helpers/date_helper.rb
  26. +1 −1 actionpack/lib/action_view/template.rb
  27. +5 −1 actionpack/lib/action_view/template_handlers.rb
  28. +1 −1 actionpack/test/controller/rack_test.rb
  29. +3 −3 actionpack/test/controller/request/multipart_params_parsing_test.rb
  30. +12 −0 actionpack/test/controller/request/url_encoded_params_parsing_test.rb
  31. +80 −15 actionpack/test/template/date_helper_test.rb
  32. +4 −0 activerecord/CHANGELOG
  33. +1 −1 activerecord/MIT-LICENSE
  34. +1 −1 activerecord/lib/active_record.rb
  35. +2 −2 activerecord/lib/active_record/associations.rb
  36. +9 −3 activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
  37. +3 −2 activerecord/lib/active_record/callbacks.rb
  38. +2 −2 activerecord/lib/active_record/dirty.rb
  39. +8 −0 activerecord/lib/active_record/reflection.rb
  40. +11 −0 activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
  41. +2 −1 activerecord/test/cases/associations/has_many_associations_test.rb
  42. +41 −3 activerecord/test/cases/callbacks_test.rb
  43. +25 −1 activerecord/test/cases/dirty_test.rb
  44. +1 −1 activerecord/test/cases/helper.rb
  45. +1 −1 activerecord/test/cases/json_serialization_test.rb
  46. +1 −0 activerecord/test/schema/schema.rb
  47. +1 −1 activeresource/MIT-LICENSE
  48. +1 −1 activesupport/MIT-LICENSE
  49. +4 −0 activesupport/lib/active_support/cache.rb
  50. +6 −1 activesupport/lib/active_support/cache/mem_cache_store.rb
  51. +104 −0 activesupport/lib/active_support/cache/strategy/local_cache.rb
  52. +0 −17 activesupport/lib/active_support/core_ext/object/misc.rb
  53. +30 −0 activesupport/lib/active_support/core_ext/try.rb
  54. +2 −2 activesupport/lib/active_support/json/encoders/hash.rb
  55. +22 −9 activesupport/lib/active_support/ordered_hash.rb
  56. +105 −16 activesupport/test/caching_test.rb
  57. +2 −2 activesupport/test/json/encoding_test.rb
  58. +9 −1 activesupport/test/ordered_hash_test.rb
  59. +6 −0 railties/CHANGELOG
  60. +1 −1 railties/MIT-LICENSE
  61. +15 −5 railties/Rakefile
  62. +0 −3 railties/bin/performance/request
  63. +16 −16 railties/doc/guides/html/2_2_release_notes.html
  64. +197 −0 railties/doc/guides/html/action_mailer_basics.html
  65. +31 −31 railties/doc/guides/html/actioncontroller_basics.html
  66. +402 −0 railties/doc/guides/html/active_record_basics.html
  67. +68 −68 railties/doc/guides/html/active_record_querying.html
  68. +48 −48 railties/doc/guides/html/activerecord_validations_callbacks.html
  69. +105 −105 railties/doc/guides/html/association_basics.html
  70. +19 −19 railties/doc/guides/html/caching_with_rails.html
  71. +15 −15 railties/doc/guides/html/command_line.html
  72. +3 −3 railties/doc/guides/html/configuring.html
  73. +48 −48 railties/doc/guides/html/creating_plugins.html
  74. +15 −15 railties/doc/guides/html/debugging_rails_applications.html
  75. +148 −156 railties/doc/guides/html/form_helpers.html
  76. +57 −57 railties/doc/guides/html/getting_started_with_rails.html
  77. +335 −72 railties/doc/guides/html/i18n.html
  78. +1 −1 railties/doc/guides/html/index.html
  79. +82 −82 railties/doc/guides/html/layouts_and_rendering.html
  80. +23 −23 railties/doc/guides/html/migrations.html
  81. +29 −29 railties/doc/guides/html/performance_testing.html
  82. +12 −12 railties/doc/guides/html/rails_on_rack.html
  83. +69 −69 railties/doc/guides/html/routing_outside_in.html
  84. +25 −25 railties/doc/guides/html/security.html
  85. +36 −36 railties/doc/guides/html/testing_rails_applications.html
  86. +1 −1 railties/doc/guides/source/creating_plugins/appendix.txt
  87. +137 −124 railties/doc/guides/source/form_helpers.txt
  88. +193 −48 railties/doc/guides/source/i18n.txt
  89. +1 −1 railties/doc/guides/source/index.txt
  90. +0 −6 railties/lib/commands/performance/request.rb
  91. +1 −1 railties/lib/dispatcher.rb
  92. +5 −0 railties/lib/initializer.rb
  93. +1 −1 railties/lib/rails_generator/generators/applications/app/app_generator.rb
View
@@ -1,4 +1,4 @@
-Copyright (c) 2004-2008 David Heinemeier Hansson
+Copyright (c) 2004-2009 David Heinemeier Hansson
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
@@ -1,5 +1,5 @@
#--
-# Copyright (c) 2004-2008 David Heinemeier Hansson
+# Copyright (c) 2004-2009 David Heinemeier Hansson
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -213,6 +213,8 @@ module ActionMailer #:nodoc:
# * <tt>:password</tt> - If your mail server requires authentication, set the password in this setting.
# * <tt>:authentication</tt> - If your mail server requires authentication, you need to specify the authentication type here.
# This is a symbol and one of <tt>:plain</tt>, <tt>:login</tt>, <tt>:cram_md5</tt>.
+ # * <tt>:enable_starttls_auto</tt> - When set to true, detects if STARTTLS is enabled in your SMTP server and starts to use it.
+ # It works only on Ruby >= 1.8.7 and Ruby >= 1.9. Default is true.
#
# * <tt>sendmail_settings</tt> - Allows you to override options for the <tt>:sendmail</tt> delivery method.
# * <tt>:location</tt> - The location of the sendmail executable. Defaults to <tt>/usr/sbin/sendmail</tt>.
@@ -230,10 +232,13 @@ module ActionMailer #:nodoc:
#
# * <tt>default_charset</tt> - The default charset used for the body and to encode the subject. Defaults to UTF-8. You can also
# pick a different charset from inside a method with +charset+.
+ #
# * <tt>default_content_type</tt> - The default content type used for the main part of the message. Defaults to "text/plain". You
# can also pick a different content type from inside a method with +content_type+.
+ #
# * <tt>default_mime_version</tt> - The default mime version used for the message. Defaults to <tt>1.0</tt>. You
# can also pick a different value from inside a method with +mime_version+.
+ #
# * <tt>default_implicit_parts_order</tt> - When a message is built implicitly (i.e. multiple parts are assembled from templates
# which specify the content type in their filenames) this variable controls how the parts are ordered. Defaults to
# <tt>["text/html", "text/enriched", "text/plain"]</tt>. Items that appear first in the array have higher priority in the mail client
@@ -252,12 +257,13 @@ class Base
cattr_accessor :logger
@@smtp_settings = {
- :address => "localhost",
- :port => 25,
- :domain => 'localhost.localdomain',
- :user_name => nil,
- :password => nil,
- :authentication => nil
+ :address => "localhost",
+ :port => 25,
+ :domain => 'localhost.localdomain',
+ :user_name => nil,
+ :password => nil,
+ :authentication => nil,
+ :enable_starttls_auto => true,
}
cattr_accessor :smtp_settings
@@ -669,7 +675,7 @@ def perform_delivery_smtp(mail)
sender = mail['return-path'] || mail.from
smtp = Net::SMTP.new(smtp_settings[:address], smtp_settings[:port])
- smtp.enable_starttls_auto if smtp.respond_to?(:enable_starttls_auto)
+ smtp.enable_starttls_auto if smtp_settings[:enable_starttls_auto] && smtp.respond_to?(:enable_starttls_auto)
smtp.start(smtp_settings[:domain], smtp_settings[:user_name], smtp_settings[:password],
smtp_settings[:authentication]) do |smtp|
smtp.sendmail(mail.encoded, sender, destinations)
@@ -948,18 +948,30 @@ def test_body_is_stored_as_an_ivar
end
def test_starttls_is_enabled_if_supported
+ ActionMailer::Base.smtp_settings[:enable_starttls_auto] = true
MockSMTP.any_instance.expects(:respond_to?).with(:enable_starttls_auto).returns(true)
MockSMTP.any_instance.expects(:enable_starttls_auto)
ActionMailer::Base.delivery_method = :smtp
TestMailer.deliver_signed_up(@recipient)
end
def test_starttls_is_disabled_if_not_supported
+ ActionMailer::Base.smtp_settings[:enable_starttls_auto] = true
MockSMTP.any_instance.expects(:respond_to?).with(:enable_starttls_auto).returns(false)
MockSMTP.any_instance.expects(:enable_starttls_auto).never
ActionMailer::Base.delivery_method = :smtp
TestMailer.deliver_signed_up(@recipient)
end
+
+ def test_starttls_is_not_enabled
+ ActionMailer::Base.smtp_settings[:enable_starttls_auto] = false
+ MockSMTP.any_instance.expects(:respond_to?).never
+ MockSMTP.any_instance.expects(:enable_starttls_auto).never
+ ActionMailer::Base.delivery_method = :smtp
+ TestMailer.deliver_signed_up(@recipient)
+ ensure
+ ActionMailer::Base.smtp_settings[:enable_starttls_auto] = true
+ end
end
end # uses_mocha
@@ -48,8 +48,10 @@ def test_quote_multibyte_chars
result = execute_in_sandbox(<<-CODE)
$:.unshift(File.dirname(__FILE__) + "/../lib/")
- $KCODE = 'u'
- require 'jcode'
+ if RUBY_VERSION < '1.9'
+ $KCODE = 'u'
+ require 'jcode'
+ end
require 'action_mailer/quoting'
include ActionMailer::Quoting
quoted_printable(#{original.inspect}, "UTF-8")
View
@@ -1,4 +1,4 @@
-Copyright (c) 2004-2008 David Heinemeier Hansson
+Copyright (c) 2004-2009 David Heinemeier Hansson
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
@@ -1,5 +1,5 @@
#--
-# Copyright (c) 2004-2008 David Heinemeier Hansson
+# Copyright (c) 2004-2009 David Heinemeier Hansson
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -56,9 +56,9 @@ def self.load_all!
autoload :Integration, 'action_controller/integration'
autoload :IntegrationTest, 'action_controller/integration'
autoload :Layout, 'action_controller/layout'
- autoload :Lock, 'action_controller/lock'
autoload :MiddlewareStack, 'action_controller/middleware_stack'
autoload :MimeResponds, 'action_controller/mime_responds'
+ autoload :ParamsParser, 'action_controller/params_parser'
autoload :PolymorphicRoutes, 'action_controller/polymorphic_routes'
autoload :RecordIdentifier, 'action_controller/record_identifier'
autoload :Request, 'action_controller/request'
@@ -75,6 +75,7 @@ def self.load_all!
autoload :TestCase, 'action_controller/test_case'
autoload :TestProcess, 'action_controller/test_process'
autoload :Translation, 'action_controller/translation'
+ autoload :UploadedFile, 'action_controller/uploaded_file'
autoload :UploadedStringIO, 'action_controller/uploaded_file'
autoload :UploadedTempfile, 'action_controller/uploaded_file'
autoload :UrlEncodedPairParser, 'action_controller/url_encoded_pair_parser'
@@ -301,10 +301,7 @@ class Base
# A YAML parser is also available and can be turned on with:
#
# ActionController::Base.param_parsers[Mime::YAML] = :yaml
- @@param_parsers = { Mime::MULTIPART_FORM => :multipart_form,
- Mime::URL_ENCODED_FORM => :url_encoded_form,
- Mime::XML => :xml_simple,
- Mime::JSON => :json }
+ @@param_parsers = {}
cattr_accessor :param_parsers
# Controls the default charset for all renders.
@@ -1,16 +0,0 @@
-module ActionController
- class Lock
- FLAG = 'rack.multithread'.freeze
-
- def initialize(app, lock = Mutex.new)
- @app, @lock = app, lock
- end
-
- def call(env)
- old, env[FLAG] = env[FLAG], false
- @lock.synchronize { @app.call(env) }
- ensure
- env[FLAG] = old
- end
- end
-end
@@ -1,4 +1,4 @@
-use "ActionController::Lock", :if => lambda {
+use "Rack::Lock", :if => lambda {
!ActionController::Base.allow_concurrency
}
@@ -19,4 +19,5 @@
end
use ActionController::RewindableInput
+use ActionController::ParamsParser
use Rack::MethodOverride
@@ -0,0 +1,71 @@
+module ActionController
+ class ParamsParser
+ ActionController::Base.param_parsers[Mime::XML] = :xml_simple
+ ActionController::Base.param_parsers[Mime::JSON] = :json
+
+ def initialize(app)
+ @app = app
+ end
+
+ def call(env)
+ if params = parse_formatted_parameters(env)
+ env["action_controller.request.request_parameters"] = params
+ end
+
+ @app.call(env)
+ end
+
+ private
+ def parse_formatted_parameters(env)
+ request = Request.new(env)
+
+ return false if request.content_length.zero?
+
+ mime_type = content_type_from_legacy_post_data_format_header(env) || request.content_type
+ strategy = ActionController::Base.param_parsers[mime_type]
+
+ return false unless strategy
+
+ case strategy
+ when Proc
+ strategy.call(request.raw_post)
+ when :xml_simple, :xml_node
+ body = request.raw_post
+ body.blank? ? {} : Hash.from_xml(body).with_indifferent_access
+ when :yaml
+ YAML.load(request.raw_post)
+ when :json
+ body = request.raw_post
+ if body.blank?
+ {}
+ else
+ data = ActiveSupport::JSON.decode(body)
+ data = {:_json => data} unless data.is_a?(Hash)
+ data.with_indifferent_access
+ end
+ else
+ false
+ end
+ rescue Exception => e # YAML, XML or Ruby code block errors
+ raise
+ { "body" => request.raw_post,
+ "content_type" => request.content_type,
+ "content_length" => request.content_length,
+ "exception" => "#{e.message} (#{e.class})",
+ "backtrace" => e.backtrace }
+ end
+
+ def content_type_from_legacy_post_data_format_header(env)
+ if x_post_format = env['HTTP_X_POST_DATA_FORMAT']
+ case x_post_format.to_s.downcase
+ when 'yaml'
+ return Mime::YAML
+ when 'xml'
+ return Mime::XML
+ end
+ end
+
+ nil
+ end
+ end
+end
@@ -1,22 +1,3 @@
-module Rack
- module Utils
- module Multipart
- class << self
- def parse_multipart_with_rewind(env)
- result = parse_multipart_without_rewind(env)
-
- begin
- env['rack.input'].rewind if env['rack.input'].respond_to?(:rewind)
- rescue Errno::ESPIPE
- # Handles exceptions raised by input streams that cannot be rewound
- # such as when using plain CGI under Apache
- end
-
- result
- end
-
- alias_method_chain :parse_multipart, :rewind
- end
- end
- end
-end
+require 'action_controller/rack_ext/lock'
+require 'action_controller/rack_ext/multipart'
+require 'action_controller/rack_ext/parse_query'
@@ -0,0 +1,21 @@
+module Rack
+ # Rack::Lock was commited to Rack core
+ # http://github.com/rack/rack/commit/7409b0c
+ # Remove this when Rack 1.0 is released
+ unless defined? Lock
+ class Lock
+ FLAG = 'rack.multithread'.freeze
+
+ def initialize(app, lock = Mutex.new)
+ @app, @lock = app, lock
+ end
+
+ def call(env)
+ old, env[FLAG] = env[FLAG], false
+ @lock.synchronize { @app.call(env) }
+ ensure
+ env[FLAG] = old
+ end
+ end
+ end
+end
@@ -0,0 +1,22 @@
+module Rack
+ module Utils
+ module Multipart
+ class << self
+ def parse_multipart_with_rewind(env)
+ result = parse_multipart_without_rewind(env)
+
+ begin
+ env['rack.input'].rewind if env['rack.input'].respond_to?(:rewind)
+ rescue Errno::ESPIPE
+ # Handles exceptions raised by input streams that cannot be rewound
+ # such as when using plain CGI under Apache
+ end
+
+ result
+ end
+
+ alias_method_chain :parse_multipart, :rewind
+ end
+ end
+ end
+end
@@ -0,0 +1,18 @@
+# Rack does not automatically cleanup Safari 2 AJAX POST body
+# This has not yet been commited to Rack, please +1 this ticket:
+# http://rack.lighthouseapp.com/projects/22435/tickets/19
+
+module Rack
+ module Utils
+ alias_method :parse_query_without_ajax_body_cleanup, :parse_query
+ module_function :parse_query_without_ajax_body_cleanup
+
+ def parse_query(qs, d = '&;')
+ qs = qs.dup
+ qs.chop! if qs[-1] == 0
+ qs.gsub!(/&_=$/, '')
+ parse_query_without_ajax_body_cleanup(qs, d)
+ end
+ module_function :parse_query
+ end
+end
Oops, something went wrong.

0 comments on commit f08a78a

Please sign in to comment.