Permalink
Browse files

Merge remote branch 'mainstream/master'

Conflicts:
	actionpack/lib/action_controller/metal/flash.rb
  • Loading branch information...
2 parents 867829b + 6e3bee6 commit b04230e3bbf912d60601e9e7b797c4cd43581d51 @lifo lifo committed Jan 16, 2010
Showing 316 changed files with 6,041 additions and 5,554 deletions.
View
@@ -1,4 +1,3 @@
-.DS_Store
debug.log
doc/rdoc
activemodel/doc
@@ -17,10 +16,6 @@ railties/doc/guides/html/images
railties/doc/guides/html/stylesheets
benches
railties/guides/output
-*.rbc
-*.swp
-*.swo
-*.tmproj
bin
vendor/gems/
railties/tmp
View
@@ -1,6 +1,3 @@
[submodule "arel"]
path = arel
url = git://github.com/rails/arel.git
-[submodule "rack"]
- path = rack
- url = git://github.com/rails/rack.git
View
@@ -7,9 +7,6 @@ gem "rails", "3.0.pre", :path => "railties"
gem lib, '3.0.pre', :path => lib
end
-# AS
-gem "i18n", ">= 0.3.0"
-
# AR
gem "arel", "0.2.pre", :git => "git://github.com/rails/arel.git"
gem "sqlite3-ruby", ">= 1.2.5"
@@ -20,7 +17,6 @@ only :test do
end
# AP
-gem "rack", "1.1.0", :git => "git://github.com/rack/rack.git"
gem "rack-test", "0.5.3"
gem "RedCloth", ">= 4.2.2"
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
s.homepage = "http://www.rubyonrails.org"
s.add_dependency('actionpack', '= 3.0.pre')
- s.add_dependency('mail', '~> 1.5.0')
+ s.add_dependency('mail', '~> 1.6.0')
s.files = Dir['CHANGELOG', 'README', 'MIT-LICENSE', 'lib/**/*']
s.has_rdoc = true
@@ -259,10 +259,9 @@ class Base < AbstractController::Base
include AbstractController::LocalizedCache
include AbstractController::Layouts
include AbstractController::Helpers
+ include AbstractController::UrlFor
helper ActionMailer::MailHelper
-
- include ActionController::UrlWriter
include ActionMailer::DeprecatedBody
private_class_method :new #:nodoc:
@@ -399,10 +398,12 @@ def method_missing(method_symbol, *parameters) #:nodoc:
# ...
# end
# end
- def receive(raw_email)
- logger.info "Received mail:\n #{raw_email}" unless logger.nil?
- mail = Mail.new(raw_email)
- new.receive(mail)
+ def receive(raw_mail)
+ ActiveSupport::Notifications.instrument("action_mailer.receive") do |payload|
+ mail = Mail.new(raw_mail)
+ set_payload_for_mail(payload, mail)
+ new.receive(mail)
+ end
end
# Deliver the given mail object directly. This can be used to deliver
@@ -424,7 +425,19 @@ def template_root=(root)
self.view_paths = ActionView::Base.process_view_paths(root)
end
+ def set_payload_for_mail(payload, mail) #:nodoc:
+ payload[:message_id] = mail.message_id
+ payload[:subject] = mail.subject
+ payload[:to] = mail.to
+ payload[:from] = mail.from
+ payload[:bcc] = mail.bcc if mail.bcc.present?
+ payload[:cc] = mail.cc if mail.cc.present?
+ payload[:date] = mail.date
+ payload[:mail] = mail.encoded
+ end
+
private
+
def matches_dynamic_method?(method_name) #:nodoc:
method_name = method_name.to_s
/^(create|deliver)_([_a-z]\w*)/.match(method_name) || /^(new)$/.match(method_name)
@@ -495,17 +508,14 @@ def process(method_name, *args)
def deliver!(mail = @mail)
raise "no mail object available for delivery!" unless mail
- if logger
- logger.info "Sent mail to #{Array(recipients).join(', ')}"
- logger.debug "\n#{mail.encoded}"
- end
-
- ActiveSupport::Notifications.instrument(:deliver_mail, :mail => mail) do
- begin
+ begin
+ ActiveSupport::Notifications.instrument("action_mailer.deliver",
+ :template => template, :mailer => self.class.name) do |payload|
+ self.class.set_payload_for_mail(payload, mail)
self.delivery_method.perform_delivery(mail) if perform_deliveries
- rescue Exception => e # Net::SMTP errors or sendmail pipe errors
- raise e if raise_delivery_errors
end
+ rescue Exception => e # Net::SMTP errors or sendmail pipe errors
+ raise e if raise_delivery_errors
end
mail
@@ -5,6 +5,9 @@ module ActionMailer
class Railtie < Rails::Railtie
plugin_name :action_mailer
+ require "action_mailer/railties/subscriber"
+ subscriber ActionMailer::Railties::Subscriber.new
+
initializer "action_mailer.set_configs" do |app|
app.config.action_mailer.each do |k,v|
ActionMailer::Base.send "#{k}=", v
@@ -0,0 +1,20 @@
+module ActionMailer
+ module Railties
+ class Subscriber < Rails::Subscriber
+ def deliver(event)
+ recipients = Array(event.payload[:to]).join(', ')
+ info("Sent mail to #{recipients} (%1.fms)" % event.duration)
+ debug("\n#{event.payload[:mail]}")
+ end
+
+ def receive(event)
+ info("Received mail (%.1fms)" % event.duration)
+ debug("\n#{event.payload[:mail]}")
+ end
+
+ def logger
+ ActionMailer::Base.logger
+ end
+ end
+ end
+end
@@ -1,6 +1,3 @@
-require 'active_support/test_case'
-require 'action_mailer/base'
-
module ActionMailer
class NonInferrableMailerError < ::StandardError
def initialize(name)
@@ -10,7 +10,6 @@
require 'test/unit'
require 'action_mailer'
-require 'action_mailer/test_case'
# Show backtraces for deprecated behavior for quicker cleanup.
ActiveSupport::Deprecation.debug = true
@@ -688,40 +688,6 @@ def test_performs_delivery_via_sendmail
TestMailer.deliver_signed_up(@recipient)
end
- class FakeLogger
- attr_reader :info_contents, :debug_contents
-
- def initialize
- @info_contents, @debug_contents = "", ""
- end
-
- def info(str = nil, &blk)
- @info_contents << str if str
- @info_contents << blk.call if block_given?
- end
-
- def debug(str = nil, &blk)
- @debug_contents << str if str
- @debug_contents << blk.call if block_given?
- end
- end
-
- def test_delivery_logs_sent_mail
- mail = TestMailer.create_signed_up(@recipient)
- # logger = mock()
- # logger.expects(:info).with("Sent mail to #{@recipient}")
- # logger.expects(:debug).with("\n#{mail.encoded}")
- TestMailer.logger = FakeLogger.new
- TestMailer.deliver_signed_up(@recipient)
- assert(TestMailer.logger.info_contents =~ /Sent mail to #{@recipient}/)
- expected = TestMailer.logger.debug_contents
- actual = "\n#{mail.encoded}"
- expected.gsub!(/Message-ID:.*\r\n/, "Message-ID: <123@456>\r\n")
- actual.gsub!(/Message-ID:.*\r\n/, "Message-ID: <123@456>\r\n")
-
- assert_equal(expected, actual)
- end
-
def test_unquote_quoted_printable_subject
msg = <<EOF
From: me@example.com
@@ -1110,10 +1076,15 @@ def test_return_path_with_create
assert_equal "another@somewhere.test", mail['return-path'].to_s
end
+ def test_return_path_with_create
+ mail = TestMailer.create_return_path
+ assert_equal "another@somewhere.test", mail.return_path
+ end
+
def test_return_path_with_deliver
ActionMailer::Base.delivery_method = :smtp
TestMailer.deliver_return_path
- assert_match %r{^Return-Path: another@somewhere.test}, MockSMTP.deliveries[0][0]
+ assert_match %r{^Return-Path: <another@somewhere.test>}, MockSMTP.deliveries[0][0]
assert_equal "another@somewhere.test", MockSMTP.deliveries[0][1].to_s
end
@@ -0,0 +1,53 @@
+require "abstract_unit"
+require "rails/subscriber/test_helper"
+require "action_mailer/railties/subscriber"
+
+module SubscriberTest
+ Rails::Subscriber.add(:action_mailer, ActionMailer::Railties::Subscriber.new)
+
+ class TestMailer < ActionMailer::Base
+ def basic
+ recipients "somewhere@example.com"
+ subject "basic"
+ from "basic@example.com"
+ render :text => "Hello world"
+ end
+
+ def receive(mail)
+ # Do nothing
+ end
+ end
+
+ def set_logger(logger)
+ ActionMailer::Base.logger = logger
+ end
+
+ def test_deliver_is_notified
+ TestMailer.deliver_basic
+ wait
+ assert_equal 1, @logger.logged(:info).size
+ assert_match /Sent mail to somewhere@example.com/, @logger.logged(:info).first
+ assert_equal 1, @logger.logged(:debug).size
+ assert_match /Hello world/, @logger.logged(:debug).first
+ end
+
+ def test_receive_is_notified
+ fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email")
+ TestMailer.receive(fixture)
+ wait
+ assert_equal 1, @logger.logged(:info).size
+ assert_match /Received mail/, @logger.logged(:info).first
+ assert_equal 1, @logger.logged(:debug).size
+ assert_match /Jamis/, @logger.logged(:debug).first
+ end
+
+ class SyncSubscriberTest < ActionMailer::TestCase
+ include Rails::Subscriber::SyncTestHelper
+ include SubscriberTest
+ end
+
+ class AsyncSubscriberTest < ActionMailer::TestCase
+ include Rails::Subscriber::AsyncTestHelper
+ include SubscriberTest
+ end
+end
View
@@ -1,5 +1,13 @@
*Edge*
+* Fixed that PrototypeHelper#update_page should return html_safe [DHH]
+
+* Fixed that much of DateHelper wouldn't return html_safe? strings [DHH]
+
+* Fixed that fragment caching should return a cache hit as html_safe (or it would all just get escaped) [DHH]
+
+* Added that ActionController::Base now does helper :all instead of relying on the default ApplicationController in Rails to do it [DHH]
+
* Added ActionDispatch::Request#authorization to access the http authentication header regardless of its proxy hiding [DHH]
* Added :alert, :notice, and :flash as options to ActionController::Base#redirect_to that'll automatically set the proper flash before the redirection [DHH]. Examples:
@@ -15,4 +15,5 @@ module AbstractController
autoload :LocalizedCache
autoload :Logger
autoload :Rendering
+ autoload :UrlFor
end
@@ -86,6 +86,11 @@ def controller_path
abstract!
+ # Initialize controller with nil formats.
+ def initialize #:nodoc:
+ @_formats = nil
+ end
+
# Calls the action going through the entire action dispatch stack.
#
# The actual method that is called is determined by calling
@@ -17,12 +17,6 @@ module Rendering
self._view_paths ||= ActionView::PathSet.new
end
- # Initialize controller with nil formats.
- def initialize(*) #:nodoc:
- @_formats = nil
- super
- end
-
# An instance of a view class. The default view class is ActionView::Base
#
# The view class must have the following methods:
Oops, something went wrong.

0 comments on commit b04230e

Please sign in to comment.