From 7e075e62479a0eccad6eaf7a7c20f45347860c83 Mon Sep 17 00:00:00 2001 From: Benjamin Quorning Date: Fri, 9 Jul 2010 15:58:58 +0200 Subject: Fixed many references to the old config/environment.rb and Rails::Initializer --- actionmailer/lib/action_mailer/base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionmailer') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index ed4bea0c77..7f2ed5ba64 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -129,7 +129,7 @@ module ActionMailer #:nodoc: # # ActionMailer::Base.default_url_options[:host] = "example.com" # - # This can also be set as a configuration option in config/environment.rb: + # This can also be set as a configuration option in config/application.rb: # # config.action_mailer.default_url_options = { :host => "example.com" } # -- cgit v1.2.3 From fcb230144b041a95c8e743921e22f8df56949993 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Thu, 15 Jul 2010 16:37:12 -0300 Subject: Bump up nokogiri, memcache-client, sqlite3-ruby, fcgi, mail and tzinfo --- actionmailer/actionmailer.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionmailer') diff --git a/actionmailer/actionmailer.gemspec b/actionmailer/actionmailer.gemspec index 2b7c21b3f2..fa0ee778c9 100644 --- a/actionmailer/actionmailer.gemspec +++ b/actionmailer/actionmailer.gemspec @@ -20,5 +20,5 @@ Gem::Specification.new do |s| s.has_rdoc = true s.add_dependency('actionpack', version) - s.add_dependency('mail', '~> 2.2.3') + s.add_dependency('mail', '~> 2.2.5') end -- cgit v1.2.3 From f1082bd51eb575f22f86b78f347ab75a4b2bff1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 21 Jul 2010 11:56:28 +0200 Subject: Remove old install.rb files. --- actionmailer/README | 22 +++------------------- actionmailer/install.rb | 30 ------------------------------ 2 files changed, 3 insertions(+), 49 deletions(-) delete mode 100644 actionmailer/install.rb (limited to 'actionmailer') diff --git a/actionmailer/README b/actionmailer/README index 2a4d507d8a..3dd56a6fd8 100644 --- a/actionmailer/README +++ b/actionmailer/README @@ -126,36 +126,20 @@ or is accessible as a GEM. Additionally, Action Mailer requires the Mail gem, http://github.com/mikel/mail -== Bundled software - -* Text::Format 0.63 by Austin Ziegler released under OpenSource - Read more on http://www.halostatue.ca/ruby/Text__Format.html - == Download -The latest version of Action Mailer can be found at +The latest version of Action Mailer can be installed with Rubygems: -* http://rubyforge.org/project/showfiles.php?group_id=361 +* gem install actionmailer Documentation can be found at -* http://actionmailer.rubyonrails.org - - -== Installation - -You can install Action Mailer with the following command. - - % [sudo] ruby install.rb - -from its distribution directory. - +* http://api.rubyonrails.org == License Action Mailer is released under the MIT license. - == Support The Action Mailer homepage is http://www.rubyonrails.org. You can find diff --git a/actionmailer/install.rb b/actionmailer/install.rb deleted file mode 100644 index 8d7c140c3b..0000000000 --- a/actionmailer/install.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'rbconfig' -require 'find' -require 'ftools' - -include Config - -# this was adapted from rdoc's install.rb by way of Log4r - -$sitedir = CONFIG["sitelibdir"] -unless $sitedir - version = CONFIG["MAJOR"] + "." + CONFIG["MINOR"] - $libdir = File.join(CONFIG["libdir"], "ruby", version) - $sitedir = $:.find {|x| x =~ /site_ruby/ } - if !$sitedir - $sitedir = File.join($libdir, "site_ruby") - elsif $sitedir !~ Regexp.quote(version) - $sitedir = File.join($sitedir, version) - end -end - -# the actual gruntwork -Dir.chdir("lib") - -Find.find("action_mailer", "action_mailer.rb") { |f| - if f[-3..-1] == ".rb" - File::install(f, File.join($sitedir, *f.split(/\//)), 0644, true) - else - File::makedirs(File.join($sitedir, *f.split(/\//))) - end -} -- cgit v1.2.3 From 508fba9e070e09f0a321f2dd7acf7938967468f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 21 Jul 2010 12:51:14 +0200 Subject: Add .rdoc extension to README files. --- actionmailer/README | 151 ----------------------------------------------- actionmailer/README.rdoc | 151 +++++++++++++++++++++++++++++++++++++++++++++++ actionmailer/Rakefile | 2 +- 3 files changed, 152 insertions(+), 152 deletions(-) delete mode 100644 actionmailer/README create mode 100644 actionmailer/README.rdoc (limited to 'actionmailer') diff --git a/actionmailer/README b/actionmailer/README deleted file mode 100644 index 3dd56a6fd8..0000000000 --- a/actionmailer/README +++ /dev/null @@ -1,151 +0,0 @@ -= Action Mailer -- Easy email delivery and testing - -Action Mailer is a framework for designing email-service layers. These layers -are used to consolidate code for sending out forgotten passwords, welcome -wishes on signup, invoices for billing, and any other use case that requires -a written notification to either a person or another system. - -Action Mailer is in essence a wrapper around Action Controller and the -Mail gem. It provides a way to make emails using templates in the same -way that Action Controller renders views using templates. - -Additionally, an Action Mailer class can be used to process incoming email, -such as allowing a weblog to accept new posts from an email (which could even -have been sent from a phone). - -== Sending emails - -The framework works by initializing any instance variables you want to be -available in the email template, followed by a call to +mail+ to deliver -the email. - -This can be as simple as: - - class Notifier < ActionMailer::Base - delivers_from 'system@loudthinking.com' - - def welcome(recipient) - @recipient = recipient - mail(:to => recipient, - :subject => "[Signed up] Welcome #{recipient}") - end - end - -The body of the email is created by using an Action View template (regular -ERb) that has the instance variables that are declared in the mailer action. - -So the corresponding body template for the method above could look like this: - - Hello there, - - Mr. <%= @recipient %> - - Thank you for signing up! - -And if the recipient was given as "david@loudthinking.com", the email -generated would look like this: - - Date: Mon, 25 Jan 2010 22:48:09 +1100 - From: system@loudthinking.com - To: david@loudthinking.com - Message-ID: <4b5d84f9dd6a5_7380800b81ac29578@void.loudthinking.com.mail> - Subject: [Signed up] Welcome david@loudthinking.com - Mime-Version: 1.0 - Content-Type: text/plain; - charset="US-ASCII"; - Content-Transfer-Encoding: 7bit - - Hello there, - - Mr. david@loudthinking.com - -In previous version of rails you would call create_method_name and -deliver_method_name. Rails 3.0 has a much simpler interface, you -simply call the method and optionally call +deliver+ on the return value. - -Calling the method returns a Mail Message object: - - message = Notifier.welcome #=> Returns a Mail::Message object - message.deliver #=> delivers the email - -Or you can just chain the methods together like: - - Notifier.welcome.deliver # Creates the email and sends it immediately - -== Receiving emails - -To receive emails, you need to implement a public instance method called receive that takes a -tmail object as its single parameter. The Action Mailer framework has a corresponding class method, -which is also called receive, that accepts a raw, unprocessed email as a string, which it then turns -into the tmail object and calls the receive instance method. - -Example: - - class Mailman < ActionMailer::Base - def receive(email) - page = Page.find_by_address(email.to.first) - page.emails.create( - :subject => email.subject, :body => email.body - ) - - if email.has_attachments? - for attachment in email.attachments - page.attachments.create({ - :file => attachment, :description => email.subject - }) - end - end - end - end - -This Mailman can be the target for Postfix or other MTAs. In Rails, you would use the runner in the -trivial case like this: - - rails runner 'Mailman.receive(STDIN.read)' - -However, invoking Rails in the runner for each mail to be received is very resource intensive. A single -instance of Rails should be run within a daemon if it is going to be utilized to process more than just -a limited number of email. - -== Configuration - -The Base class has the full list of configuration options. Here's an example: - - ActionMailer::Base.smtp_settings = { - :address => 'smtp.yourserver.com', # default: localhost - :port => '25', # default: 25 - :user_name => 'user', - :password => 'pass', - :authentication => :plain # :plain, :login or :cram_md5 - } - -== Dependencies - -Action Mailer requires that the Action Pack is either available to be required immediately -or is accessible as a GEM. - -Additionally, Action Mailer requires the Mail gem, http://github.com/mikel/mail - -== Download - -The latest version of Action Mailer can be installed with Rubygems: - -* gem install actionmailer - -Documentation can be found at - -* http://api.rubyonrails.org - -== License - -Action Mailer is released under the MIT license. - -== Support - -The Action Mailer homepage is http://www.rubyonrails.org. You can find -the Action Mailer RubyForge page at http://rubyforge.org/projects/actionmailer. -And as Jim from Rake says: - - Feel free to submit commits or feature requests. If you send a patch, - remember to update the corresponding unit tests. If fact, I prefer - new feature to be submitted in the form of new unit tests. diff --git a/actionmailer/README.rdoc b/actionmailer/README.rdoc new file mode 100644 index 0000000000..3dd56a6fd8 --- /dev/null +++ b/actionmailer/README.rdoc @@ -0,0 +1,151 @@ += Action Mailer -- Easy email delivery and testing + +Action Mailer is a framework for designing email-service layers. These layers +are used to consolidate code for sending out forgotten passwords, welcome +wishes on signup, invoices for billing, and any other use case that requires +a written notification to either a person or another system. + +Action Mailer is in essence a wrapper around Action Controller and the +Mail gem. It provides a way to make emails using templates in the same +way that Action Controller renders views using templates. + +Additionally, an Action Mailer class can be used to process incoming email, +such as allowing a weblog to accept new posts from an email (which could even +have been sent from a phone). + +== Sending emails + +The framework works by initializing any instance variables you want to be +available in the email template, followed by a call to +mail+ to deliver +the email. + +This can be as simple as: + + class Notifier < ActionMailer::Base + delivers_from 'system@loudthinking.com' + + def welcome(recipient) + @recipient = recipient + mail(:to => recipient, + :subject => "[Signed up] Welcome #{recipient}") + end + end + +The body of the email is created by using an Action View template (regular +ERb) that has the instance variables that are declared in the mailer action. + +So the corresponding body template for the method above could look like this: + + Hello there, + + Mr. <%= @recipient %> + + Thank you for signing up! + +And if the recipient was given as "david@loudthinking.com", the email +generated would look like this: + + Date: Mon, 25 Jan 2010 22:48:09 +1100 + From: system@loudthinking.com + To: david@loudthinking.com + Message-ID: <4b5d84f9dd6a5_7380800b81ac29578@void.loudthinking.com.mail> + Subject: [Signed up] Welcome david@loudthinking.com + Mime-Version: 1.0 + Content-Type: text/plain; + charset="US-ASCII"; + Content-Transfer-Encoding: 7bit + + Hello there, + + Mr. david@loudthinking.com + +In previous version of rails you would call create_method_name and +deliver_method_name. Rails 3.0 has a much simpler interface, you +simply call the method and optionally call +deliver+ on the return value. + +Calling the method returns a Mail Message object: + + message = Notifier.welcome #=> Returns a Mail::Message object + message.deliver #=> delivers the email + +Or you can just chain the methods together like: + + Notifier.welcome.deliver # Creates the email and sends it immediately + +== Receiving emails + +To receive emails, you need to implement a public instance method called receive that takes a +tmail object as its single parameter. The Action Mailer framework has a corresponding class method, +which is also called receive, that accepts a raw, unprocessed email as a string, which it then turns +into the tmail object and calls the receive instance method. + +Example: + + class Mailman < ActionMailer::Base + def receive(email) + page = Page.find_by_address(email.to.first) + page.emails.create( + :subject => email.subject, :body => email.body + ) + + if email.has_attachments? + for attachment in email.attachments + page.attachments.create({ + :file => attachment, :description => email.subject + }) + end + end + end + end + +This Mailman can be the target for Postfix or other MTAs. In Rails, you would use the runner in the +trivial case like this: + + rails runner 'Mailman.receive(STDIN.read)' + +However, invoking Rails in the runner for each mail to be received is very resource intensive. A single +instance of Rails should be run within a daemon if it is going to be utilized to process more than just +a limited number of email. + +== Configuration + +The Base class has the full list of configuration options. Here's an example: + + ActionMailer::Base.smtp_settings = { + :address => 'smtp.yourserver.com', # default: localhost + :port => '25', # default: 25 + :user_name => 'user', + :password => 'pass', + :authentication => :plain # :plain, :login or :cram_md5 + } + +== Dependencies + +Action Mailer requires that the Action Pack is either available to be required immediately +or is accessible as a GEM. + +Additionally, Action Mailer requires the Mail gem, http://github.com/mikel/mail + +== Download + +The latest version of Action Mailer can be installed with Rubygems: + +* gem install actionmailer + +Documentation can be found at + +* http://api.rubyonrails.org + +== License + +Action Mailer is released under the MIT license. + +== Support + +The Action Mailer homepage is http://www.rubyonrails.org. You can find +the Action Mailer RubyForge page at http://rubyforge.org/projects/actionmailer. +And as Jim from Rake says: + + Feel free to submit commits or feature requests. If you send a patch, + remember to update the corresponding unit tests. If fact, I prefer + new feature to be submitted in the form of new unit tests. diff --git a/actionmailer/Rakefile b/actionmailer/Rakefile index f20e7ea928..98aeae9818 100644 --- a/actionmailer/Rakefile +++ b/actionmailer/Rakefile @@ -32,7 +32,7 @@ Rake::RDocTask.new { |rdoc| rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object' rdoc.options << '--charset' << 'utf-8' rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : '../doc/template/horo' - rdoc.rdoc_files.include('README', 'CHANGELOG') + rdoc.rdoc_files.include('README.rdoc', 'CHANGELOG') rdoc.rdoc_files.include('lib/action_mailer.rb') rdoc.rdoc_files.include('lib/action_mailer/*.rb') rdoc.rdoc_files.include('lib/action_mailer/delivery_method/*.rb') -- cgit v1.2.3 From d16c5cc99b4ac5a5517b643aabb3b31bf0f0f1b6 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Thu, 22 Jul 2010 01:00:01 +0800 Subject: Change some missing README -> README.rdoc --- actionmailer/actionmailer.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionmailer') diff --git a/actionmailer/actionmailer.gemspec b/actionmailer/actionmailer.gemspec index fa0ee778c9..daf30e434a 100644 --- a/actionmailer/actionmailer.gemspec +++ b/actionmailer/actionmailer.gemspec @@ -13,7 +13,7 @@ Gem::Specification.new do |s| s.homepage = 'http://www.rubyonrails.org' s.rubyforge_project = 'actionmailer' - s.files = Dir['CHANGELOG', 'README', 'MIT-LICENSE', 'lib/**/*'] + s.files = Dir['CHANGELOG', 'README.rdoc', 'MIT-LICENSE', 'lib/**/*'] s.require_path = 'lib' s.requirements << 'none' -- cgit v1.2.3 From ab62aa1c4309b670c5e3bdce2cf35113e1aa874b Mon Sep 17 00:00:00 2001 From: Jeroen van Dijk Date: Wed, 21 Jul 2010 17:10:24 +0200 Subject: Mention that ActionMailer::Base.default_url_options is now deprecated --- actionmailer/lib/action_mailer/base.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'actionmailer') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 7f2ed5ba64..7bbde53306 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -125,14 +125,13 @@ module ActionMailer #:nodoc: # make sense to generate relative URLs in email messages. # # It is also possible to set a default host that will be used in all mailers by setting the :host - # option in the ActionMailer::Base.default_url_options hash as follows: - # - # ActionMailer::Base.default_url_options[:host] = "example.com" - # - # This can also be set as a configuration option in config/application.rb: + # option as a configuration option in config/application.rb: # # config.action_mailer.default_url_options = { :host => "example.com" } # + # Setting ActionMailer::Base.default_url_options directly is now deprecated, use the configuration + # option mentioned above to set the default host. + # # If you do decide to set a default :host for your mailers you will want to use the # :only_path => false option when using url_for. This will ensure that absolute URLs are # generated because the url_for view helper will, by default, generate relative URLs when a -- cgit v1.2.3 From 89b5e79632c4f0b18099faa846e45741b7c5e700 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Sun, 18 Jul 2010 14:58:40 +0200 Subject: revise download/installation/support sections in READMEs - don't reference ancient gem versions - don't link to old API doc subdomains - point to GitHub instead of RubyForge - point to Lighthouse account for support --- actionmailer/README.rdoc | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'actionmailer') diff --git a/actionmailer/README.rdoc b/actionmailer/README.rdoc index 3dd56a6fd8..1b9cb8a570 100644 --- a/actionmailer/README.rdoc +++ b/actionmailer/README.rdoc @@ -121,31 +121,38 @@ The Base class has the full list of configuration options. Here's an example: == Dependencies -Action Mailer requires that the Action Pack is either available to be required immediately -or is accessible as a GEM. +Action Mailer depends on Action Pack. -Additionally, Action Mailer requires the Mail gem, http://github.com/mikel/mail +Additionally, Action Mailer requires the {Mail gem}[http://github.com/mikel/mail]. -== Download +== Bundled software + +* Text::Format 0.63 by Austin Ziegler released under OpenSource + Read more on http://www.halostatue.ca/ruby/Text__Format.html + + +== Download and installation The latest version of Action Mailer can be installed with Rubygems: -* gem install actionmailer + % [sudo] gem install actionmailer + +Source code can be downloaded as part of the Rails project on GitHub -Documentation can be found at +* http://github.com/rails/rails/tree/master/actionmailer/ -* http://api.rubyonrails.org == License Action Mailer is released under the MIT license. + == Support -The Action Mailer homepage is http://www.rubyonrails.org. You can find -the Action Mailer RubyForge page at http://rubyforge.org/projects/actionmailer. -And as Jim from Rake says: +API documentation is at + +* http://api.rubyonrails.com + +Bug reports and feature requests can be filed with the rest for the Ruby on Rails project here: - Feel free to submit commits or feature requests. If you send a patch, - remember to update the corresponding unit tests. If fact, I prefer - new feature to be submitted in the form of new unit tests. +* https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets -- cgit v1.2.3 From 6b11d0bf68ecb1960f6a6dc5b11bb8cc904df5a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Thu, 22 Jul 2010 09:23:22 +0200 Subject: remove unneeded "Dependencies" section from Action Mailer README Other READMEs don't have dependencies indicated, and installing a gem takes care of dependencies automatically. For developers, dependencies are indicated in the Gemfile. --- actionmailer/README.rdoc | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'actionmailer') diff --git a/actionmailer/README.rdoc b/actionmailer/README.rdoc index 1b9cb8a570..64b0333c0a 100644 --- a/actionmailer/README.rdoc +++ b/actionmailer/README.rdoc @@ -119,17 +119,6 @@ The Base class has the full list of configuration options. Here's an example: :authentication => :plain # :plain, :login or :cram_md5 } -== Dependencies - -Action Mailer depends on Action Pack. - -Additionally, Action Mailer requires the {Mail gem}[http://github.com/mikel/mail]. - -== Bundled software - -* Text::Format 0.63 by Austin Ziegler released under OpenSource - Read more on http://www.halostatue.ca/ruby/Text__Format.html - == Download and installation -- cgit v1.2.3 From b378b19430a4d2ee54cbe7f1935fbd4f8b3b331b Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Thu, 22 Jul 2010 18:56:00 -0300 Subject: Makes Rakefile activate rdoc >= 2.5.9 Signed-off-by: Xavier Noria --- actionmailer/Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionmailer') diff --git a/actionmailer/Rakefile b/actionmailer/Rakefile index 98aeae9818..7dede3bf4f 100644 --- a/actionmailer/Rakefile +++ b/actionmailer/Rakefile @@ -1,4 +1,4 @@ -gem 'rdoc', '= 2.2' +gem 'rdoc', '>= 2.5.9' require 'rdoc' require 'rake' require 'rake/testtask' -- cgit v1.2.3 From b50635a59f7d2fab2cdba348c4169536fbbb77f4 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 23 Jul 2010 21:11:29 +0200 Subject: update Rakefiles for RDoc 2.5 --- actionmailer/Rakefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'actionmailer') diff --git a/actionmailer/Rakefile b/actionmailer/Rakefile index 7dede3bf4f..ce5f7a36d9 100644 --- a/actionmailer/Rakefile +++ b/actionmailer/Rakefile @@ -2,7 +2,7 @@ gem 'rdoc', '>= 2.5.9' require 'rdoc' require 'rake' require 'rake/testtask' -require 'rake/rdoctask' +require 'rdoc/task' require 'rake/packagetask' require 'rake/gempackagetask' @@ -26,12 +26,12 @@ namespace :test do end # Generate the RDoc documentation -Rake::RDocTask.new { |rdoc| +RDoc::Task.new { |rdoc| rdoc.rdoc_dir = 'doc' rdoc.title = "Action Mailer -- Easy email delivery and testing" - rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object' rdoc.options << '--charset' << 'utf-8' - rdoc.template = ENV['template'] ? "#{ENV['template']}.rb" : '../doc/template/horo' + rdoc.options << '-f' << 'horo' + rdoc.options << '--main' << 'README.rdoc' rdoc.rdoc_files.include('README.rdoc', 'CHANGELOG') rdoc.rdoc_files.include('lib/action_mailer.rb') rdoc.rdoc_files.include('lib/action_mailer/*.rb') -- cgit v1.2.3 From affeb51569d291ef7304189fd77b32c6e269af57 Mon Sep 17 00:00:00 2001 From: Jeroen van Dijk and Josh Kalderimis Date: Fri, 23 Jul 2010 14:42:21 +0200 Subject: Move config_accessor :asset_host from ActionController::Base to AbstractController which fixes issues with asset_host in ActionMailer Including: - Moved mailer objects in separate directory - Added two tests for asset_host configuration option --- actionmailer/test/base_test.rb | 156 ++++----------------- .../test/fixtures/asset_mailer/welcome.html.erb | 1 + actionmailer/test/mailers/asset_mailer.rb | 7 + actionmailer/test/mailers/base_mailer.rb | 114 +++++++++++++++ actionmailer/test/mailers/proc_mailer.rb | 16 +++ 5 files changed, 165 insertions(+), 129 deletions(-) create mode 100644 actionmailer/test/fixtures/asset_mailer/welcome.html.erb create mode 100644 actionmailer/test/mailers/asset_mailer.rb create mode 100644 actionmailer/test/mailers/base_mailer.rb create mode 100644 actionmailer/test/mailers/proc_mailer.rb (limited to 'actionmailer') diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index 5bc0491cff..e2b9df5d02 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -2,139 +2,17 @@ require 'abstract_unit' require 'active_support/time' +require 'mailers/base_mailer' +require 'mailers/proc_mailer' +require 'mailers/asset_mailer' + class BaseTest < ActiveSupport::TestCase # TODO Add some tests for implicity layout render and url helpers # so we can get rid of old base tests altogether with old base. - class BaseMailer < ActionMailer::Base - self.mailer_name = "base_mailer" - - default :to => 'system@test.lindsaar.net', - :from => 'jose@test.plataformatec.com', - :reply_to => 'mikel@test.lindsaar.net' - - def welcome(hash = {}) - headers['X-SPAM'] = "Not SPAM" - mail({:subject => "The first email on new API!"}.merge!(hash)) - end - - def welcome_with_headers(hash = {}) - headers hash - mail - end - - def welcome_from_another_path(path) - mail(:template_name => "welcome", :template_path => path) - end - - def html_only(hash = {}) - mail(hash) - end - - def plain_text_only(hash = {}) - mail(hash) - end - - def inline_attachment - attachments.inline['logo.png'] = "\312\213\254\232" - mail - end - - def attachment_with_content(hash = {}) - attachments['invoice.pdf'] = 'This is test File content' - mail(hash) - end - - def attachment_with_hash - attachments['invoice.jpg'] = { :data => "\312\213\254\232)b", - :mime_type => "image/x-jpg", - :transfer_encoding => "base64" } - mail - end - - def attachment_with_hash_default_encoding - attachments['invoice.jpg'] = { :data => "\312\213\254\232)b", - :mime_type => "image/x-jpg" } - mail - end - - def implicit_multipart(hash = {}) - attachments['invoice.pdf'] = 'This is test File content' if hash.delete(:attachments) - mail(hash) - end - - def implicit_with_locale(hash = {}) - mail(hash) - end - - def explicit_multipart(hash = {}) - attachments['invoice.pdf'] = 'This is test File content' if hash.delete(:attachments) - mail(hash) do |format| - format.text { render :text => "TEXT Explicit Multipart" } - format.html { render :text => "HTML Explicit Multipart" } - end - end - - def explicit_multipart_templates(hash = {}) - mail(hash) do |format| - format.html - format.text - end - end - def explicit_multipart_with_any(hash = {}) - mail(hash) do |format| - format.any(:text, :html){ render :text => "Format with any!" } - end - end - - def explicit_multipart_with_options(include_html = false) - mail do |format| - format.text(:content_transfer_encoding => "base64"){ render "welcome" } - format.html{ render "welcome" } if include_html - end - end - - def explicit_multipart_with_one_template(hash = {}) - mail(hash) do |format| - format.html - format.text - end - end - - def implicit_different_template(template_name='') - mail(:template_name => template_name) - end - - def explicit_different_template(template_name='') - mail do |format| - format.text { render :template => "#{mailer_name}/#{template_name}" } - format.html { render :template => "#{mailer_name}/#{template_name}" } - end - end - - def different_layout(layout_name='') - mail do |format| - format.text { render :layout => layout_name } - format.html { render :layout => layout_name } - end - end - end - - class ProcMailer < ActionMailer::Base - default :to => 'system@test.lindsaar.net', - 'X-Proc-Method' => Proc.new { Time.now.to_i.to_s }, - :subject => Proc.new { give_a_greeting } - - def welcome - mail - end - - private - - def give_a_greeting - "Thanks for signing up this afternoon" - end - + def teardown + ActionMailer::Base.asset_host = nil + ActionMailer::Base.assets_dir = nil end test "method call to mail does not raise error" do @@ -570,6 +448,26 @@ class BaseTest < ActiveSupport::TestCase assert_equal("Welcome from another path", mail.body.encoded) end + test "assets tags should use ActionMailer's asset_host settings" do + ActionMailer::Base.config.asset_host = "http://global.com" + ActionMailer::Base.config.assets_dir = "global/" + + mail = AssetMailer.welcome + + assert_equal(%{Dummy}, mail.body.to_s.strip) + end + + test "assets tags should use a Mailer's asset_host settings when available" do + ActionMailer::Base.config.asset_host = "global.com" + ActionMailer::Base.config.assets_dir = "global/" + + AssetMailer.asset_host = "http://local.com" + + mail = AssetMailer.welcome + + assert_equal(%{Dummy}, mail.body.to_s.strip) + end + # Before and After hooks class MyObserver diff --git a/actionmailer/test/fixtures/asset_mailer/welcome.html.erb b/actionmailer/test/fixtures/asset_mailer/welcome.html.erb new file mode 100644 index 0000000000..90d26130d9 --- /dev/null +++ b/actionmailer/test/fixtures/asset_mailer/welcome.html.erb @@ -0,0 +1 @@ +<%= image_tag "dummy.png" %> \ No newline at end of file diff --git a/actionmailer/test/mailers/asset_mailer.rb b/actionmailer/test/mailers/asset_mailer.rb new file mode 100644 index 0000000000..f54a50d00d --- /dev/null +++ b/actionmailer/test/mailers/asset_mailer.rb @@ -0,0 +1,7 @@ +class AssetMailer < ActionMailer::Base + self.mailer_name = "asset_mailer" + + def welcome + mail + end +end diff --git a/actionmailer/test/mailers/base_mailer.rb b/actionmailer/test/mailers/base_mailer.rb new file mode 100644 index 0000000000..2c6de36ccf --- /dev/null +++ b/actionmailer/test/mailers/base_mailer.rb @@ -0,0 +1,114 @@ +class BaseMailer < ActionMailer::Base + self.mailer_name = "base_mailer" + + default :to => 'system@test.lindsaar.net', + :from => 'jose@test.plataformatec.com', + :reply_to => 'mikel@test.lindsaar.net' + + def welcome(hash = {}) + headers['X-SPAM'] = "Not SPAM" + mail({:subject => "The first email on new API!"}.merge!(hash)) + end + + def welcome_with_headers(hash = {}) + headers hash + mail + end + + def welcome_from_another_path(path) + mail(:template_name => "welcome", :template_path => path) + end + + def html_only(hash = {}) + mail(hash) + end + + def plain_text_only(hash = {}) + mail(hash) + end + + def inline_attachment + attachments.inline['logo.png'] = "\312\213\254\232" + mail + end + + def attachment_with_content(hash = {}) + attachments['invoice.pdf'] = 'This is test File content' + mail(hash) + end + + def attachment_with_hash + attachments['invoice.jpg'] = { :data => "\312\213\254\232)b", + :mime_type => "image/x-jpg", + :transfer_encoding => "base64" } + mail + end + + def attachment_with_hash_default_encoding + attachments['invoice.jpg'] = { :data => "\312\213\254\232)b", + :mime_type => "image/x-jpg" } + mail + end + + def implicit_multipart(hash = {}) + attachments['invoice.pdf'] = 'This is test File content' if hash.delete(:attachments) + mail(hash) + end + + def implicit_with_locale(hash = {}) + mail(hash) + end + + def explicit_multipart(hash = {}) + attachments['invoice.pdf'] = 'This is test File content' if hash.delete(:attachments) + mail(hash) do |format| + format.text { render :text => "TEXT Explicit Multipart" } + format.html { render :text => "HTML Explicit Multipart" } + end + end + + def explicit_multipart_templates(hash = {}) + mail(hash) do |format| + format.html + format.text + end + end + + def explicit_multipart_with_any(hash = {}) + mail(hash) do |format| + format.any(:text, :html){ render :text => "Format with any!" } + end + end + + def explicit_multipart_with_options(include_html = false) + mail do |format| + format.text(:content_transfer_encoding => "base64"){ render "welcome" } + format.html{ render "welcome" } if include_html + end + end + + def explicit_multipart_with_one_template(hash = {}) + mail(hash) do |format| + format.html + format.text + end + end + + def implicit_different_template(template_name='') + mail(:template_name => template_name) + end + + def explicit_different_template(template_name='') + mail do |format| + format.text { render :template => "#{mailer_name}/#{template_name}" } + format.html { render :template => "#{mailer_name}/#{template_name}" } + end + end + + def different_layout(layout_name='') + mail do |format| + format.text { render :layout => layout_name } + format.html { render :layout => layout_name } + end + end +end diff --git a/actionmailer/test/mailers/proc_mailer.rb b/actionmailer/test/mailers/proc_mailer.rb new file mode 100644 index 0000000000..6a79cd71fc --- /dev/null +++ b/actionmailer/test/mailers/proc_mailer.rb @@ -0,0 +1,16 @@ +class ProcMailer < ActionMailer::Base + default :to => 'system@test.lindsaar.net', + 'X-Proc-Method' => Proc.new { Time.now.to_i.to_s }, + :subject => Proc.new { give_a_greeting } + + def welcome + mail + end + + private + + def give_a_greeting + "Thanks for signing up this afternoon" + end + +end -- cgit v1.2.3 From 76b6136b00a9d0a74f99ca4f1ae347230bde94e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sat, 24 Jul 2010 00:48:12 +0200 Subject: Clean up AM and AC railties. --- actionmailer/lib/action_mailer/railtie.rb | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'actionmailer') diff --git a/actionmailer/lib/action_mailer/railtie.rb b/actionmailer/lib/action_mailer/railtie.rb index d7b09b2dc6..ce6d8cc5b5 100644 --- a/actionmailer/lib/action_mailer/railtie.rb +++ b/actionmailer/lib/action_mailer/railtie.rb @@ -10,21 +10,16 @@ module ActionMailer end initializer "action_mailer.set_configs" do |app| - paths = app.config.paths - am = app.config.action_mailer + paths = app.config.paths + options = app.config.action_mailer - am.assets_dir ||= paths.public.to_a.first - am.javascripts_dir ||= paths.public.javascripts.to_a.first - am.stylesheets_dir ||= paths.public.stylesheets.to_a.first + 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 ActiveSupport.on_load(:action_mailer) do - self.config.merge!(am) - include app.routes.url_helpers - - app.config.action_mailer.each do |k,v| - send "#{k}=", v - end + options.each { |k,v| send("#{k}=", v) } end end end -- cgit v1.2.3 From e1d4e78b15141cf940be7a84ca856425484a98be Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Fri, 23 Jul 2010 00:36:34 -0300 Subject: Removes unused vars MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- actionmailer/lib/action_mailer/test_case.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionmailer') diff --git a/actionmailer/lib/action_mailer/test_case.rb b/actionmailer/lib/action_mailer/test_case.rb index b91eed592a..f4d1bb59f1 100644 --- a/actionmailer/lib/action_mailer/test_case.rb +++ b/actionmailer/lib/action_mailer/test_case.rb @@ -28,7 +28,7 @@ module ActionMailer def determine_default_mailer(name) name.sub(/Test$/, '').constantize - rescue NameError => e + rescue NameError raise NonInferrableMailerError.new(name) end end -- cgit v1.2.3 From dcb7832ed51b2aeb2ea7386e2f07fcb5d7eb0c6d Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 26 Jul 2010 00:01:23 +0200 Subject: APIs for individual components are no longer published --- actionmailer/Rakefile | 6 ------ 1 file changed, 6 deletions(-) (limited to 'actionmailer') diff --git a/actionmailer/Rakefile b/actionmailer/Rakefile index ce5f7a36d9..a47426bd07 100644 --- a/actionmailer/Rakefile +++ b/actionmailer/Rakefile @@ -50,9 +50,3 @@ task :release => :package do Rake::Gemcutter::Tasks.new(spec).define Rake::Task['gem:push'].invoke end - -desc "Publish the API documentation" -task :pdoc => [:rdoc] do - require 'rake/contrib/sshpublisher' - Rake::SshDirPublisher.new("rails@api.rubyonrails.org", "public_html/am", "doc").upload -end -- cgit v1.2.3 From 856fc4bbc379b330d11702adbc2b26850dca6206 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 26 Jul 2010 12:52:34 -0500 Subject: Prep for RC --- actionmailer/CHANGELOG | 5 +++++ actionmailer/lib/action_mailer/version.rb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'actionmailer') diff --git a/actionmailer/CHANGELOG b/actionmailer/CHANGELOG index f0b9368874..76eab935e5 100644 --- a/actionmailer/CHANGELOG +++ b/actionmailer/CHANGELOG @@ -1,3 +1,8 @@ +*Rails 3.0.0 [release candidate] (July 26th, 2010)* + +* No material changes + + *Rails 3.0.0 [beta 4] (June 8th, 2010)* * subject is automatically looked up on I18n using mailer_name and action_name as scope as in t(".subject") [JK] diff --git a/actionmailer/lib/action_mailer/version.rb b/actionmailer/lib/action_mailer/version.rb index 8c19082f61..805c89be1d 100644 --- a/actionmailer/lib/action_mailer/version.rb +++ b/actionmailer/lib/action_mailer/version.rb @@ -3,7 +3,7 @@ module ActionMailer MAJOR = 3 MINOR = 0 TINY = 0 - BUILD = "beta4" + BUILD = "rc" STRING = [MAJOR, MINOR, TINY, BUILD].join('.') end -- cgit v1.2.3 From 2df365529bf82c76512c6462b19bf196ad932c73 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Wed, 28 Jul 2010 21:50:24 -0400 Subject: putting receive method under tt --- actionmailer/README.rdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actionmailer') diff --git a/actionmailer/README.rdoc b/actionmailer/README.rdoc index 64b0333c0a..b52c993f56 100644 --- a/actionmailer/README.rdoc +++ b/actionmailer/README.rdoc @@ -74,9 +74,9 @@ Or you can just chain the methods together like: == Receiving emails -To receive emails, you need to implement a public instance method called receive that takes a +To receive emails, you need to implement a public instance method called receive that takes a tmail object as its single parameter. The Action Mailer framework has a corresponding class method, -which is also called receive, that accepts a raw, unprocessed email as a string, which it then turns +which is also called receive, that accepts a raw, unprocessed email as a string, which it then turns into the tmail object and calls the receive instance method. Example: -- cgit v1.2.3 From daad4454eb4eeeb76749735490e1b355fcf9e827 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Wed, 28 Jul 2010 22:22:50 -0400 Subject: itsy bitsy changes to ActionMailer documentation --- actionmailer/lib/action_mailer/base.rb | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'actionmailer') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 7bbde53306..1ac8f9da1d 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -41,16 +41,16 @@ module ActionMailer #:nodoc: # in the same manner as attachments[]= # # * headers[]= - Allows you to specify any header field in your email such - # as headers['X-No-Spam'] = 'True'. Note, while most fields (like To: + # as headers['X-No-Spam'] = 'True'. Note, while most fields like To: # From: can only appear once in an email header, other fields like X-Anything # can appear multiple times. If you want to change a field that can appear multiple times, - # you need to set it to nil first so that Mail knows you are replacing it, not adding - # another field of the same name.) + # you need to set it to nil first so that Mail knows you are replacing it and not adding + # another field of the same name. # # * headers(hash) - Allows you to specify multiple headers in your email such # as headers({'X-No-Spam' => 'True', 'In-Reply-To' => '1234@message.id'}) # - # * mail - Allows you to specify your email to send. + # * mail - Allows you to specify email to be sent. # # The hash passed to the mail method allows you to specify any header that a Mail::Message # will accept (any valid Email header including optional fields). @@ -66,7 +66,7 @@ module ActionMailer #:nodoc: # format.html # end # - # The block syntax is useful if also need to specify information specific to a part: + # The block syntax is also useful in providing information specific to a part: # # mail(:to => user.email) do |format| # format.text(:content_transfer_encoding => "base64") @@ -121,7 +121,7 @@ module ActionMailer #:nodoc: # # <%= users_url(:host => "example.com") %> # - # You will want to avoid using the name_of_route_path form of named routes because it doesn't + # You want to avoid using the name_of_route_path form of named routes because it doesn't # make sense to generate relative URLs in email messages. # # It is also possible to set a default host that will be used in all mailers by setting the :host @@ -132,7 +132,7 @@ module ActionMailer #:nodoc: # Setting ActionMailer::Base.default_url_options directly is now deprecated, use the configuration # option mentioned above to set the default host. # - # If you do decide to set a default :host for your mailers you will want to use the + # If you do decide to set a default :host for your mailers you want to use the # :only_path => false option when using url_for. This will ensure that absolute URLs are # generated because the url_for view helper will, by default, generate relative URLs when a # :host option isn't explicitly provided. @@ -154,7 +154,7 @@ module ActionMailer #:nodoc: # detect and use multipart templates, where each template is named after the name of the action, followed # by the content type. Each such detected template will be added as separate part to the message. # - # For example, if the following templates existed: + # For example, if the following templates exist: # * signup_notification.text.plain.erb # * signup_notification.text.html.erb # * signup_notification.text.xml.builder @@ -171,8 +171,7 @@ module ActionMailer #:nodoc: # # = Attachments # - # You can see above how to make a multipart HTML / Text email, to send attachments is just - # as easy: + # Sending attachment in emails is easy: # # class ApplicationMailer < ActionMailer::Base # def welcome(recipient) @@ -189,10 +188,8 @@ module ActionMailer #:nodoc: # # = Inline Attachments # - # You can also specify that a file should be displayed inline with other HTML. For example a - # corporate logo or a photo or the like. - # - # To do this is simple, in the Mailer: + # 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) -- cgit v1.2.3 From 755af497555fde16db86f7e51f6462b0aca79b49 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Fri, 30 Jul 2010 02:30:04 +0200 Subject: edit pass to apply API guideline wrt the use of "# =>" in example code --- actionmailer/lib/action_mailer/base.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actionmailer') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 7bbde53306..64d3b29513 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -496,10 +496,10 @@ module ActionMailer #:nodoc: # You can also search for specific attachments: # # # By Filename - # mail.attachments['filename.jpg'] #=> Mail::Part object or nil + # mail.attachments['filename.jpg'] # => Mail::Part object or nil # # # or by index - # mail.attachments[0] #=> Mail::Part (first attachment) + # mail.attachments[0] # => Mail::Part (first attachment) # def attachments @_message.attachments -- cgit v1.2.3 From 84f0a0bc30df58e1edfd09fdde2de891e4577321 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 4 Aug 2010 18:58:18 +0200 Subject: Reload action_methods in AbstractController after defining new method. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- actionmailer/test/base_test.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'actionmailer') diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index e2b9df5d02..fec0ecf477 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -507,6 +507,18 @@ class BaseTest < ActiveSupport::TestCase assert_equal("Thanks for signing up this afternoon", mail.subject) end + test "action methods should be refreshed after defining new method" do + class FooMailer < ActionMailer::Base + # this triggers action_methods + self.respond_to?(:foo) + + def notify + end + end + + assert_equal ["notify"], FooMailer.action_methods + end + protected # Execute the block setting the given values and restoring old values after -- cgit v1.2.3 From 4f7565c4de1f877547a6b901a8416b18c613acc9 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 9 Aug 2010 15:14:00 +0200 Subject: adds missing requires for Object#try --- actionmailer/lib/action_mailer/deprecated_api.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'actionmailer') diff --git a/actionmailer/lib/action_mailer/deprecated_api.rb b/actionmailer/lib/action_mailer/deprecated_api.rb index 0070d8e016..7d57feba04 100644 --- a/actionmailer/lib/action_mailer/deprecated_api.rb +++ b/actionmailer/lib/action_mailer/deprecated_api.rb @@ -1,3 +1,5 @@ +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. -- cgit v1.2.3