diff options
Diffstat (limited to 'actionmailer/lib/action_mailer')
-rw-r--r-- | actionmailer/lib/action_mailer/adv_attr_accessor.rb | 36 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/base.rb | 92 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/delivery_methods.rb | 4 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/deprecated_api.rb | 141 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/mail_helper.rb | 39 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/old_api.rb | 72 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/railtie.rb | 23 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/test_case.rb | 7 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/tmail_compat.rb | 27 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/version.rb | 6 |
10 files changed, 156 insertions, 291 deletions
diff --git a/actionmailer/lib/action_mailer/adv_attr_accessor.rb b/actionmailer/lib/action_mailer/adv_attr_accessor.rb index be6b1feca9..c1aa8021ce 100644 --- a/actionmailer/lib/action_mailer/adv_attr_accessor.rb +++ b/actionmailer/lib/action_mailer/adv_attr_accessor.rb @@ -1,26 +1,28 @@ module ActionMailer module AdvAttrAccessor #:nodoc: - def adv_attr_accessor(*names) - names.each do |name| - ivar = "@#{name}" + def adv_attr_accessor(name, deprecation=nil) + ivar = "@#{name}" + deprecation ||= "Please pass :#{name} as hash key to mail() instead" - class_eval <<-ACCESSORS, __FILE__, __LINE__ + 1 - def #{name}=(value) - #{ivar} = value - end + class_eval <<-ACCESSORS, __FILE__, __LINE__ + 1 + def #{name}=(value) + ActiveSupport::Deprecation.warn "#{name}= is deprecated. #{deprecation}" + #{ivar} = value + end - def #{name}(*args) - raise ArgumentError, "expected 0 or 1 parameters" unless args.length <= 1 - if args.empty? - #{ivar} if instance_variable_names.include?(#{ivar.inspect}) - else - #{ivar} = args.first - end + def #{name}(*args) + raise ArgumentError, "expected 0 or 1 parameters" unless args.length <= 1 + if args.empty? + ActiveSupport::Deprecation.warn "#{name}() is deprecated and will be removed in future versions." + #{ivar} if instance_variable_names.include?(#{ivar.inspect}) + else + ActiveSupport::Deprecation.warn "#{name}(value) is deprecated. #{deprecation}" + #{ivar} = args.first end - ACCESSORS + end + ACCESSORS - self.protected_instance_variables << ivar if self.respond_to?(:protected_instance_variables) - end + self.protected_instance_variables << ivar if self.respond_to?(:protected_instance_variables) end end end diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index f742f982f2..16fcf112b7 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -187,31 +187,31 @@ module ActionMailer #:nodoc: # with the filename +free_book.pdf+. # # = Inline Attachments - # - # You can also specify that a file should be displayed inline with other HTML. This is useful + # + # You can also specify that a file should be displayed inline with other HTML. This is useful # if you want to display a corporate logo or a photo. - # + # # class ApplicationMailer < ActionMailer::Base # def welcome(recipient) # attachments.inline['photo.png'] = File.read('path/to/photo.png') # mail(:to => recipient, :subject => "Here is what we look like") # end # end - # + # # And then to reference the image in the view, you create a <tt>welcome.html.erb</tt> file and - # make a call to +image_tag+ passing in the attachment you want to display and then call + # make a call to +image_tag+ passing in the attachment you want to display and then call # +url+ on the attachment to get the relative content id path for the image source: - # + # # <h1>Please Don't Cringe</h1> - # + # # <%= image_tag attachments['photo.png'].url -%> - # + # # As we are using Action View's +image_tag+ method, you can pass in any other options you want: - # + # # <h1>Please Don't Cringe</h1> - # + # # <%= image_tag attachments['photo.png'].url, :alt => 'Our Photo', :class => 'photo' -%> - # + # # = Observing and Intercepting Mails # # Action Mailer provides hooks into the Mail observer and interceptor methods. These allow you to @@ -222,7 +222,7 @@ module ActionMailer #:nodoc: # # An interceptor object must implement the <tt>:delivering_email(message)</tt> method which will be # called before the email is sent, allowing you to make modifications to the email before it hits - # the delivery agents. Your object should make and needed modifications directly to the passed + # the delivery agents. Your object should make any needed modifications directly to the passed # in Mail::Message instance. # # = Default Hash @@ -234,8 +234,8 @@ module ActionMailer #:nodoc: # default :sender => 'system@example.com' # end # - # You can pass in any header value that a <tt>Mail::Message</tt>, out of the box, <tt>ActionMailer::Base</tt> - # sets the following: + # You can pass in any header value that a <tt>Mail::Message</tt> accepts. Out of the box, + # <tt>ActionMailer::Base</tt> sets the following: # # * <tt>:mime_version => "1.0"</tt> # * <tt>:charset => "UTF-8",</tt> @@ -246,7 +246,7 @@ module ActionMailer #:nodoc: # but Action Mailer translates them appropriately and sets the correct values. # # As you can pass in any header, you need to either quote the header as a string, or pass it in as - # an underscorised symbol, so the following will work: + # an underscored symbol, so the following will work: # # class Notifier < ActionMailer::Base # default 'Content-Transfer-Encoding' => '7bit', @@ -273,7 +273,7 @@ module ActionMailer #:nodoc: # = Configuration options # # These options are specified on the class level, like - # <tt>ActionMailer::Base.template_root = "/my/templates"</tt> + # <tt>ActionMailer::Base.raise_delivery_errors = true</tt> # # * <tt>default</tt> - You can pass this in at a class level as well as within the class itself as # per the above section. @@ -290,13 +290,15 @@ 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>. + # This is a symbol and one of <tt>:plain</tt> (will send the password in the clear), <tt>:login</tt> (will + # send password Base64 encoded) or <tt>:cram_md5</tt> (combines a Challenge/Response mechanism to exchange + # information and a cryptographic Message Digest 5 algorithm to hash important information) # * <tt>:enable_starttls_auto</tt> - When set to true, detects if STARTTLS is enabled in your SMTP server # and starts to use it. # # * <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>. - # * <tt>:arguments</tt> - The command line arguments. Defaults to <tt>-i -t</tt> with <tt>-f sender@addres</tt> + # * <tt>:arguments</tt> - The command line arguments. Defaults to <tt>-i -t</tt> with <tt>-f sender@address</tt> # added automatically before the message is sent. # # * <tt>file_settings</tt> - Allows you to override options for the <tt>:file</tt> delivery method. @@ -341,10 +343,11 @@ module ActionMailer #:nodoc: include AbstractController::Translation include AbstractController::AssetPaths - helper ActionMailer::MailHelper + cattr_reader :protected_instance_variables + @@protected_instance_variables = [] + helper ActionMailer::MailHelper include ActionMailer::OldApi - include ActionMailer::DeprecatedApi delegate :register_observer, :to => Mail delegate :register_interceptor, :to => Mail @@ -360,7 +363,6 @@ module ActionMailer #:nodoc: }.freeze class << self - def mailer_name @mailer_name ||= name.underscore end @@ -402,14 +404,14 @@ module ActionMailer #:nodoc: end end - def respond_to?(method, *args) #:nodoc: + def respond_to?(method, include_private = false) #:nodoc: super || action_methods.include?(method.to_s) end protected def set_payload_for_mail(payload, mail) #:nodoc: - payload[:mailer] = self.name + payload[:mailer] = name payload[:message_id] = mail.message_id payload[:subject] = mail.subject payload[:to] = mail.to @@ -421,11 +423,8 @@ module ActionMailer #:nodoc: end def method_missing(method, *args) #:nodoc: - if action_methods.include?(method.to_s) - new(method, *args).message - else - super - end + return super unless respond_to?(method) + new(method, *args).message end end @@ -446,6 +445,10 @@ module ActionMailer #:nodoc: super end + def mailer_name + self.class.mailer_name + end + # Allows you to pass random and unusual headers to the new +Mail::Message+ object # which will add them to itself. # @@ -690,15 +693,8 @@ module ActionMailer #:nodoc: end def each_template(paths, name, &block) #:nodoc: - Array.wrap(paths).each do |path| - templates = lookup_context.find_all(name, path) - templates = templates.uniq_by { |t| t.formats } - - unless templates.empty? - templates.each(&block) - return - end - end + templates = lookup_context.find_all(name, Array.wrap(paths)) + templates.uniq_by { |t| t.formats }.each(&block) end def create_parts_from_responses(m, responses) #:nodoc: @@ -720,28 +716,6 @@ module ActionMailer #:nodoc: container.add_part(part) end - module DeprecatedUrlOptions - def default_url_options - deprecated_url_options - end - - def default_url_options=(val) - deprecated_url_options - end - - def deprecated_url_options - raise "You can no longer call ActionMailer::Base.default_url_options " \ - "directly. You need to set config.action_mailer.default_url_options. " \ - "If you are using ActionMailer standalone, you need to include the " \ - "routing url_helpers directly." - end - end - - # This module will complain if the user tries to set default_url_options - # directly instead of through the config object. In Action Mailer's Railtie, - # we include the router's url_helpers, which will override this module. - extend DeprecatedUrlOptions - ActiveSupport.run_load_hooks(:action_mailer, self) end end diff --git a/actionmailer/lib/action_mailer/delivery_methods.rb b/actionmailer/lib/action_mailer/delivery_methods.rb index 043794bb12..b324ba790d 100644 --- a/actionmailer/lib/action_mailer/delivery_methods.rb +++ b/actionmailer/lib/action_mailer/delivery_methods.rb @@ -46,11 +46,11 @@ module ActionMailer # as alias and the default options supplied: # # Example: - # + # # add_delivery_method :sendmail, Mail::Sendmail, # :location => '/usr/sbin/sendmail', # :arguments => '-i -t' - # + # def add_delivery_method(symbol, klass, default_options={}) class_attribute(:"#{symbol}_settings") unless respond_to?(:"#{symbol}_settings") send(:"#{symbol}_settings=", default_options) diff --git a/actionmailer/lib/action_mailer/deprecated_api.rb b/actionmailer/lib/action_mailer/deprecated_api.rb deleted file mode 100644 index 7d57feba04..0000000000 --- a/actionmailer/lib/action_mailer/deprecated_api.rb +++ /dev/null @@ -1,141 +0,0 @@ -require 'active_support/core_ext/object/try' - -module ActionMailer - # This is the API which is deprecated and is going to be removed on Rails 3.1 release. - # Part of the old API will be deprecated after 3.1, for a smoother deprecation process. - # Check those in OldApi instead. - module DeprecatedApi #:nodoc: - extend ActiveSupport::Concern - - included do - [:charset, :content_type, :mime_version, :implicit_parts_order].each do |method| - class_eval <<-FILE, __FILE__, __LINE__ + 1 - def self.default_#{method} - @@default_#{method} - end - - def self.default_#{method}=(value) - ActiveSupport::Deprecation.warn "ActionMailer::Base.default_#{method}=value is deprecated, " << - "use default :#{method} => value instead" - @@default_#{method} = value - end - - @@default_#{method} = nil - FILE - end - end - - module ClassMethods - # Deliver the given mail object directly. This can be used to deliver - # a preconstructed mail object, like: - # - # email = MyMailer.create_some_mail(parameters) - # email.set_some_obscure_header "frobnicate" - # MyMailer.deliver(email) - def deliver(mail, show_warning=true) - if show_warning - ActiveSupport::Deprecation.warn "#{self}.deliver is deprecated, call " << - "deliver in the mailer instance instead", caller[0,2] - end - - raise "no mail object available for delivery!" unless mail - wrap_delivery_behavior(mail) - mail.deliver - mail - end - - def template_root - self.view_paths && self.view_paths.first - end - - def template_root=(root) - ActiveSupport::Deprecation.warn "template_root= is deprecated, use prepend_view_path instead", caller[0,2] - self.view_paths = ActionView::Base.process_view_paths(root) - end - - def respond_to?(method_symbol, include_private = false) - matches_dynamic_method?(method_symbol) || super - end - - def method_missing(method_symbol, *parameters) - if match = matches_dynamic_method?(method_symbol) - case match[1] - when 'create' - ActiveSupport::Deprecation.warn "#{self}.create_#{match[2]} is deprecated, " << - "use #{self}.#{match[2]} instead", caller[0,2] - new(match[2], *parameters).message - when 'deliver' - ActiveSupport::Deprecation.warn "#{self}.deliver_#{match[2]} is deprecated, " << - "use #{self}.#{match[2]}.deliver instead", caller[0,2] - new(match[2], *parameters).message.deliver - else super - end - else - super - end - end - - private - - def matches_dynamic_method?(method_name) - method_name = method_name.to_s - /^(create|deliver)_([_a-z]\w*)/.match(method_name) || /^(new)$/.match(method_name) - end - end - - # Delivers a Mail object. By default, it delivers the cached mail - # object (from the <tt>create!</tt> method). If no cached mail object exists, and - # no alternate has been given as the parameter, this will fail. - def deliver!(mail = @_message) - ActiveSupport::Deprecation.warn "Calling deliver in the AM::Base object is deprecated, " << - "please call deliver in the Mail instance", caller[0,2] - self.class.deliver(mail, false) - end - alias :deliver :deliver! - - def render(*args) - options = args.last.is_a?(Hash) ? args.last : {} - - if options[:body].is_a?(Hash) - ActiveSupport::Deprecation.warn(':body in render deprecated. Please use instance ' << - 'variables as assigns instead', caller[0,1]) - - options[:body].each { |k,v| instance_variable_set(:"@#{k}", v) } - end - super - end - - # Render a message but does not set it as mail body. Useful for rendering - # data for part and attachments. - # - # Examples: - # - # render_message "special_message" - # render_message :template => "special_message" - # render_message :inline => "<%= 'Hi!' %>" - # - def render_message(*args) - ActiveSupport::Deprecation.warn "render_message is deprecated, use render instead", caller[0,2] - render(*args) - end - - private - - def initialize_defaults(*) - @charset ||= self.class.default_charset.try(:dup) - @content_type ||= self.class.default_content_type.try(:dup) - @implicit_parts_order ||= self.class.default_implicit_parts_order.try(:dup) - @mime_version ||= self.class.default_mime_version.try(:dup) - super - end - - def create_parts - if @body.is_a?(Hash) && !@body.empty? - ActiveSupport::Deprecation.warn "Giving a hash to body is deprecated, please use instance variables instead", caller[0,2] - @body.each { |k, v| instance_variable_set(:"@#{k}", v) } - end - super - end - - end -end diff --git a/actionmailer/lib/action_mailer/mail_helper.rb b/actionmailer/lib/action_mailer/mail_helper.rb index b708881edf..6f22adc479 100644 --- a/actionmailer/lib/action_mailer/mail_helper.rb +++ b/actionmailer/lib/action_mailer/mail_helper.rb @@ -3,23 +3,14 @@ module ActionMailer # Uses Text::Format to take the text and format it, indented two spaces for # each line, and wrapped at 72 columns. def block_format(text) - begin - require 'text/format' - rescue LoadError => e - $stderr.puts "You don't have text-format installed in your application. Please add it to your Gemfile and run bundle install" - raise e - end unless defined?(Text::Format) - formatted = text.split(/\n\r\n/).collect { |paragraph| - Text::Format.new( - :columns => 72, :first_indent => 2, :body_indent => 2, :text => paragraph - ).format + format_paragraph(paragraph) }.join("\n") - + # Make list points stand on their own line formatted.gsub!(/[ ]*([*]+) ([^*]*)/) { |s| " #{$1} #{$2.strip}\n" } formatted.gsub!(/[ ]*([#]+) ([^#]*)/) { |s| " #{$1} #{$2.strip}\n" } - + formatted end @@ -37,5 +28,29 @@ module ActionMailer def attachments @_message.attachments end + + # Returns +text+ wrapped at +len+ columns and indented +indent+ spaces. + # + # === Examples + # + # my_text = "Here is a sample text with more than 40 characters" + # + # format_paragraph(my_text, 25, 4) + # # => " Here is a sample text with\n more than 40 characters" + def format_paragraph(text, len = 72, indent = 2) + sentences = [[]] + + text.split.each do |word| + if (sentences.last + [word]).join(' ').length > len + sentences << [word] + else + sentences.last << word + end + end + + sentences.map { |sentence| + "#{" " * indent}#{sentence.join(' ')}" + }.join "\n" + end end end diff --git a/actionmailer/lib/action_mailer/old_api.rb b/actionmailer/lib/action_mailer/old_api.rb index 79d024a350..04728cafb0 100644 --- a/actionmailer/lib/action_mailer/old_api.rb +++ b/actionmailer/lib/action_mailer/old_api.rb @@ -8,9 +8,7 @@ module ActionMailer included do extend ActionMailer::AdvAttrAccessor - - @@protected_instance_variables = %w(@parts) - cattr_reader :protected_instance_variables + self.protected_instance_variables.concat %w(@parts @mail_was_called) # Specify the BCC addresses for the message adv_attr_accessor :bcc @@ -42,11 +40,11 @@ module ActionMailer # The recipient addresses for the message, either as a string (for a single # address) or an array (for multiple addresses). - adv_attr_accessor :recipients + adv_attr_accessor :recipients, "Please pass :to as hash key to mail() instead" # The date on which the message was sent. If not set (the default), the # header will be set by the delivery agent. - adv_attr_accessor :sent_on + adv_attr_accessor :sent_on, "Please pass :date as hash key to mail() instead" # Specify the subject of the message. adv_attr_accessor :subject @@ -54,20 +52,12 @@ module ActionMailer # Specify the template name to use for current message. This is the "base" # template name, without the extension or directory, and may be used to # have multiple mailer methods share the same template. - adv_attr_accessor :template - - # 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. - adv_attr_accessor :mailer_name + adv_attr_accessor :template, "Please pass :template_name or :template_path as hash key to mail() instead" # Define the body of the message. This is either a Hash (in which case it # specifies the variables to pass to the template when it is rendered), # or a string, in which case it specifies the actual text of the message. adv_attr_accessor :body - - # Alias controller_path to mailer_name so render :partial in views work. - alias :controller_path :mailer_name end def process(method_name, *args) @@ -84,6 +74,8 @@ module ActionMailer # part itself is yielded to the block so that other properties (charset, # body, headers, etc.) can be set on it. def part(params) + ActiveSupport::Deprecation.warn "part() is deprecated and will be removed in future versions. " << + "Please pass a block to mail() instead." params = {:content_type => params} if String === params if custom_headers = params.delete(:headers) @@ -99,6 +91,8 @@ module ActionMailer # Add an attachment to a multipart message. This is simply a part with the # content-disposition set to "attachment". def attachment(params, &block) + ActiveSupport::Deprecation.warn "attachment() is deprecated and will be removed in future versions. " << + "Please use the attachments[] API instead." params = { :content_type => params } if String === params params[:content] ||= params.delete(:data) || params.delete(:body) @@ -116,43 +110,43 @@ module ActionMailer def normalize_nonfile_hash(params) content_disposition = "attachment;" - + mime_type = params.delete(:mime_type) - + if content_type = params.delete(:content_type) content_type = "#{mime_type || content_type};" end params[:body] = params.delete(:data) if params[:data] - + { :content_type => content_type, :content_disposition => content_disposition }.merge(params) end - + def normalize_file_hash(params) filename = File.basename(params.delete(:filename)) content_disposition = "attachment; filename=\"#{File.basename(filename)}\"" - + mime_type = params.delete(:mime_type) - + if (content_type = params.delete(:content_type)) && (content_type !~ /filename=/) content_type = "#{mime_type || content_type}; filename=\"#{filename}\"" end - + params[:body] = params.delete(:data) if params[:data] - + { :content_type => content_type, :content_disposition => content_disposition }.merge(params) end - def create_mail + def create_mail m = @_message - set_fields!({:subject => subject, :to => recipients, :from => from, - :bcc => bcc, :cc => cc, :reply_to => reply_to}, charset) + set_fields!({:subject => @subject, :to => @recipients, :from => @from, + :bcc => @bcc, :cc => @cc, :reply_to => @reply_to}, @charset) - m.mime_version = mime_version unless mime_version.nil? - m.date = sent_on.to_time rescue sent_on if sent_on + m.mime_version = @mime_version if @mime_version + m.date = @sent_on.to_time rescue @sent_on if @sent_on @headers.each { |k, v| m[k] = v } @@ -178,19 +172,21 @@ module ActionMailer wrap_delivery_behavior! m.content_transfer_encoding = '8bit' unless m.body.only_us_ascii? - + @_message end - + # Set up the default values for the various instance variables of this # mailer. Subclasses may override this method to provide different # defaults. - def initialize_defaults(method_name) + def initialize_defaults(method_name) @charset ||= self.class.default[:charset].try(:dup) @content_type ||= self.class.default[:content_type].try(:dup) @implicit_parts_order ||= self.class.default[:parts_order].try(:dup) @mime_version ||= self.class.default[:mime_version].try(:dup) + @cc, @bcc, @reply_to, @subject, @from, @recipients = nil, nil, nil, nil, nil, nil + @mailer_name ||= self.class.mailer_name.dup @template ||= method_name @mail_was_called = false @@ -201,11 +197,11 @@ module ActionMailer @body ||= {} end - def create_parts + def create_parts if String === @body @parts.unshift create_inline_part(@body) elsif @parts.empty? || @parts.all? { |p| p.content_disposition =~ /^attachment/ } - lookup_context.find_all(@template, @mailer_name).each do |template| + lookup_context.find_all(@template, [@mailer_name]).each do |template| self.formats = template.formats @parts << create_inline_part(render(:template => template), template.mime_type) end @@ -216,11 +212,11 @@ module ActionMailer # If this is a multipart e-mail add the mime_version if it is not # already set. - @mime_version ||= "1.0" if !@parts.empty? + @mime_version ||= "1.0" unless @parts.empty? end end - def create_inline_part(body, mime_type=nil) + def create_inline_part(body, mime_type=nil) ct = mime_type || "text/plain" main_type, sub_type = split_content_type(ct.to_s) @@ -242,17 +238,17 @@ module ActionMailer m.reply_to ||= headers.delete(:reply_to) if headers[:reply_to] end - def split_content_type(ct) + def split_content_type(ct) ct.to_s.split("/") end - def parse_content_type(defaults=nil) + def parse_content_type if @content_type.blank? [ nil, {} ] else ctype, *attrs = @content_type.split(/;\s*/) - attrs = attrs.inject({}) { |h,s| k,v = s.split(/\=/, 2); h[k] = v; h } - [ctype, {"charset" => @charset}.merge(attrs)] + attrs = Hash[attrs.map { |attr| attr.split(/=/, 2) }] + [ctype, {"charset" => @charset}.merge!(attrs)] end end end diff --git a/actionmailer/lib/action_mailer/railtie.rb b/actionmailer/lib/action_mailer/railtie.rb index ce6d8cc5b5..4ec478067f 100644 --- a/actionmailer/lib/action_mailer/railtie.rb +++ b/actionmailer/lib/action_mailer/railtie.rb @@ -1,5 +1,6 @@ require "action_mailer" require "rails" +require "abstract_controller/railties/routes_helpers" module ActionMailer class Railtie < Rails::Railtie @@ -13,14 +14,26 @@ module ActionMailer paths = app.config.paths options = app.config.action_mailer - options.assets_dir ||= paths.public.to_a.first - options.javascripts_dir ||= paths.public.javascripts.to_a.first - options.stylesheets_dir ||= paths.public.stylesheets.to_a.first + options.assets_dir ||= paths["public"].first + options.javascripts_dir ||= paths["public/javascripts"].first + options.stylesheets_dir ||= paths["public/stylesheets"].first + + # make sure readers methods get compiled + options.asset_path ||= app.config.asset_path + options.asset_host ||= app.config.asset_host ActiveSupport.on_load(:action_mailer) do - include app.routes.url_helpers + include AbstractController::UrlFor + extend ::AbstractController::Railties::RoutesHelpers.with(app.routes) + include app.routes.mounted_helpers options.each { |k,v| send("#{k}=", v) } end end + + initializer "action_mailer.compile_config_methods" do + ActiveSupport.on_load(:action_mailer) do + config.compile_methods! if config.respond_to?(:compile_methods!) + end + end end -end
\ No newline at end of file +end diff --git a/actionmailer/lib/action_mailer/test_case.rb b/actionmailer/lib/action_mailer/test_case.rb index f4d1bb59f1..63e18147f6 100644 --- a/actionmailer/lib/action_mailer/test_case.rb +++ b/actionmailer/lib/action_mailer/test_case.rb @@ -1,3 +1,5 @@ +require 'active_support/core_ext/class/attribute' + module ActionMailer class NonInferrableMailerError < ::StandardError def initialize(name) @@ -15,11 +17,11 @@ module ActionMailer module ClassMethods def tests(mailer) - write_inheritable_attribute(:mailer_class, mailer) + self._mailer_class = mailer end def mailer_class - if mailer = read_inheritable_attribute(:mailer_class) + if mailer = self._mailer_class mailer else tests determine_default_mailer(name) @@ -65,6 +67,7 @@ module ActionMailer end included do + class_attribute :_mailer_class setup :initialize_test_deliveries setup :set_expected_mail end diff --git a/actionmailer/lib/action_mailer/tmail_compat.rb b/actionmailer/lib/action_mailer/tmail_compat.rb index 26962f972f..1b2cdcfb27 100644 --- a/actionmailer/lib/action_mailer/tmail_compat.rb +++ b/actionmailer/lib/action_mailer/tmail_compat.rb @@ -1,17 +1,19 @@ module Mail class Message - + def set_content_type(*args) - ActiveSupport::Deprecation.warn('Message#set_content_type is deprecated, please just call ' << - 'Message#content_type with the same arguments', caller[0,2]) + message = 'Message#set_content_type is deprecated, please just call ' << + 'Message#content_type with the same arguments' + ActiveSupport::Deprecation.warn(message, caller[0,2]) content_type(*args) end - + alias :old_transfer_encoding :transfer_encoding def transfer_encoding(value = nil) if value - ActiveSupport::Deprecation.warn('Message#transfer_encoding is deprecated, please call ' << - 'Message#content_transfer_encoding with the same arguments', caller[0,2]) + message = 'Message#transfer_encoding is deprecated, ' << + 'please call Message#content_transfer_encoding with the same arguments' + ActiveSupport::Deprecation.warn(message, caller[0,2]) content_transfer_encoding(value) else old_transfer_encoding @@ -19,16 +21,17 @@ module Mail end def transfer_encoding=(value) - ActiveSupport::Deprecation.warn('Message#transfer_encoding= is deprecated, please call ' << - 'Message#content_transfer_encoding= with the same arguments', caller[0,2]) + message = 'Message#transfer_encoding= is deprecated, ' << + 'please call Message#content_transfer_encoding= with the same arguments' + ActiveSupport::Deprecation.warn(message, caller[0,2]) self.content_transfer_encoding = value end def original_filename - ActiveSupport::Deprecation.warn('Message#original_filename is deprecated, ' << - 'please call Message#filename', caller[0,2]) + message = 'Message#original_filename is deprecated, please call Message#filename' + ActiveSupport::Deprecation.warn(message, caller[0,2]) filename end - + end -end
\ No newline at end of file +end diff --git a/actionmailer/lib/action_mailer/version.rb b/actionmailer/lib/action_mailer/version.rb index 805c89be1d..27eb6c2b9b 100644 --- a/actionmailer/lib/action_mailer/version.rb +++ b/actionmailer/lib/action_mailer/version.rb @@ -1,10 +1,10 @@ module ActionMailer module VERSION #:nodoc: MAJOR = 3 - MINOR = 0 + MINOR = 1 TINY = 0 - BUILD = "rc" + PRE = "beta" - STRING = [MAJOR, MINOR, TINY, BUILD].join('.') + STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.') end end |