Permalink
Browse files

Merge remote branch 'rails/master'

  • Loading branch information...
2 parents e7e6ee3 + ab2877c commit 751f79a03351f1f0d21436b2b947352b97ded093 @fxn fxn committed Jun 8, 2010
Showing with 721 additions and 646 deletions.
  1. +3 −2 Gemfile
  2. +1 −1 RAILS_VERSION
  3. +1 −1 actionmailer/CHANGELOG
  4. +1 −1 actionmailer/actionmailer.gemspec
  5. +37 −2 actionmailer/lib/action_mailer/base.rb
  6. +5 −0 actionmailer/lib/action_mailer/mail_helper.rb
  7. +1 −1 actionmailer/lib/action_mailer/version.rb
  8. +17 −0 actionmailer/test/base_test.rb
  9. +5 −0 actionmailer/test/fixtures/base_mailer/inline_attachment.html.erb
  10. +4 −0 actionmailer/test/fixtures/base_mailer/inline_attachment.text.erb
  11. +3 −3 actionmailer/test/old_base/mail_service_test.rb
  12. +11 −1 actionpack/CHANGELOG
  13. +8 −0 actionpack/lib/action_controller/metal/url_for.rb
  14. +1 −0 actionpack/lib/action_controller/vendor/html-scanner/html/tokenizer.rb
  15. +2 −2 actionpack/lib/action_dispatch/middleware/show_exceptions.rb
  16. +98 −30 actionpack/lib/action_dispatch/routing/mapper.rb
  17. +4 −1 actionpack/lib/action_dispatch/routing/route_set.rb
  18. +0 −2 actionpack/lib/action_dispatch/testing/assertions/selector.rb
  19. +1 −1 actionpack/lib/action_pack/version.rb
  20. +5 −2 actionpack/lib/action_view/helpers/asset_tag_helper.rb
  21. +14 −14 actionpack/lib/action_view/helpers/cache_helper.rb
  22. +1 −1 actionpack/lib/action_view/helpers/tag_helper.rb
  23. +22 −16 actionpack/lib/action_view/helpers/text_helper.rb
  24. +1 −1 actionpack/lib/action_view/lookup_context.rb
  25. +0 −15 actionpack/test/controller/caching_test.rb
  26. +3 −0 actionpack/test/controller/new_base/render_rjs_test.rb
  27. +117 −6 actionpack/test/dispatch/routing_test.rb
  28. +1 −1 actionpack/test/dispatch/show_exceptions_test.rb
  29. +9 −0 actionpack/test/template/asset_tag_helper_test.rb
  30. +2 −0 actionpack/test/template/tag_helper_test.rb
  31. +164 −6 actionpack/test/template/text_helper_test.rb
  32. +1 −1 activemodel/CHANGELOG
  33. +6 −3 activemodel/lib/active_model/serializers/json.rb
  34. +1 −1 activemodel/lib/active_model/version.rb
  35. +21 −15 activemodel/test/cases/serializeration/json_serialization_test.rb
  36. +1 −3 activerecord/CHANGELOG
  37. +1 −1 activerecord/activerecord.gemspec
  38. +4 −3 activerecord/lib/active_record/associations.rb
  39. +0 −56 activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
  40. +4 −0 activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
  41. +5 −2 activerecord/lib/active_record/relation.rb
  42. +9 −109 activerecord/lib/active_record/transactions.rb
  43. +1 −1 activerecord/lib/active_record/version.rb
  44. +4 −13 activerecord/test/cases/adapter_test.rb
  45. +4 −0 activerecord/test/cases/associations/belongs_to_associations_test.rb
  46. +9 −1 activerecord/test/cases/associations/cascaded_eager_loading_test.rb
  47. +1 −1 activerecord/test/cases/associations/has_many_associations_test.rb
  48. +4 −3 activerecord/test/cases/base_test.rb
  49. +3 −1 activerecord/test/cases/date_time_test.rb
  50. +8 −11 activerecord/test/cases/json_serialization_test.rb
  51. +2 −2 activerecord/test/cases/log_subscriber_test.rb
  52. +16 −17 activerecord/test/cases/migration_test.rb
  53. +1 −1 activerecord/test/cases/relations_test.rb
  54. +0 −240 activerecord/test/cases/transaction_callbacks_test.rb
  55. +0 −33 activerecord/test/cases/transactions_test.rb
  56. +1 −1 activerecord/test/connections/native_oracle/connection.rb
  57. +6 −0 activerecord/test/models/topic.rb
  58. +1 −1 activeresource/CHANGELOG
  59. +1 −1 activeresource/lib/active_resource/version.rb
  60. +1 −1 activesupport/CHANGELOG
  61. +3 −3 activesupport/lib/active_support/core_ext/date_time/conversions.rb
  62. +1 −0 activesupport/lib/active_support/core_ext/file.rb
  63. +1 −0 activesupport/lib/active_support/core_ext/load_error.rb
  64. +1 −0 activesupport/lib/active_support/core_ext/string.rb
  65. +2 −0 activesupport/lib/active_support/multibyte/chars.rb
  66. +1 −1 activesupport/lib/active_support/version.rb
  67. +1 −1 activesupport/test/abstract_unit.rb
  68. +2 −2 activesupport/test/core_ext/date_time_ext_test.rb
  69. +1 −1 railties/CHANGELOG
  70. +1 −0 railties/guides/source/3_0_release_notes.textile
  71. +31 −0 railties/guides/source/action_mailer_basics.textile
  72. +4 −0 railties/lib/rails/configuration.rb
  73. +5 −1 railties/lib/rails/generators.rb
  74. +1 −1 railties/lib/rails/version.rb
  75. +6 −0 railties/test/application/middleware_test.rb
  76. +1 −3 railties/test/generators/app_generator_test.rb
  77. +1 −1 railties/test/isolation/abstract_unit.rb
View
@@ -29,10 +29,10 @@ gem "text-format", "~> 1.0.0"
# AR
if mri || RUBY_ENGINE == "rbx"
- gem "sqlite3-ruby", "= 1.3.0.beta.2", :require => 'sqlite3'
+ gem "sqlite3-ruby", "~> 1.3.0", :require => 'sqlite3'
group :db do
- gem "pg", ">= 0.9.0"
+ # gem "pg", ">= 0.9.0"
gem "mysql", ">= 2.8.1"
end
elsif RUBY_ENGINE == "jruby"
@@ -46,6 +46,7 @@ end
# AP
gem "RedCloth", ">= 4.2.2"
+gem "bluecloth", ">= 2.0.7"
group :documentation do
gem 'rdoc', '2.1'
View
@@ -1 +1 @@
-3.0.0.beta3
+3.0.0.beta4
View
@@ -1,4 +1,4 @@
-*Rails 3.0.0 [beta 4/release candidate] (unreleased)*
+*Rails 3.0.0 [beta 4] (June 8th, 2010)*
* Changed encoding behaviour of mail, so updated tests in actionmailer and bumped mail version to 2.2.1 [ML]
@@ -20,5 +20,5 @@ Gem::Specification.new do |s|
s.has_rdoc = true
s.add_dependency('actionpack', version)
- s.add_dependency('mail', '~> 2.2.1')
+ s.add_dependency('mail', '~> 2.2.3')
end
@@ -36,6 +36,9 @@ module ActionMailer #:nodoc:
# * <tt>attachments[]=</tt> - Allows you to add attachments to your email in an intuitive
# manner; <tt>attachments['filename.png'] = File.read('path/to/filename.png')</tt>
#
+ # * <tt>attachments.inline[]=</tt> - Allows you to add an inline attachment to your email
+ # in the same manner as <tt>attachments[]=</tt>
+ #
# * <tt>headers[]=</tt> - Allows you to specify any header field in your email such
# as <tt>headers['X-No-Spam'] = 'True'</tt>. Note, while most fields (like <tt>To:</tt>
# <tt>From:</tt> can only appear once in an email header, other fields like <tt>X-Anything</tt>
@@ -173,7 +176,7 @@ module ActionMailer #:nodoc:
#
# class ApplicationMailer < ActionMailer::Base
# def welcome(recipient)
- # attachments['free_book.pdf'] = { :data => File.read('path/to/file.pdf') }
+ # attachments['free_book.pdf'] = File.read('path/to/file.pdf')
# mail(:to => recipient, :subject => "New account information")
# end
# end
@@ -184,6 +187,34 @@ module ActionMailer #:nodoc:
# and the second being a <tt>application/pdf</tt> with a Base64 encoded copy of the file.pdf book
# with the filename +free_book.pdf+.
#
+ # = 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:
+ #
+ # 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
+ # +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 ActionView'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
@@ -612,7 +643,11 @@ def set_content_type(m, user_content_type, class_default)
when user_content_type.present?
user_content_type
when m.has_attachments?
- ["multipart", "mixed", params]
+ if m.attachments.detect { |a| a.inline? }
+ ["multipart", "related", params]
+ else
+ ["multipart", "mixed", params]
+ end
when m.multipart?
["multipart", "alternative", params]
else
@@ -32,5 +32,10 @@ def mailer
def message
@_message
end
+
+ # Access the message attachments list.
+ def attachments
+ @_message.attachments
+ end
end
end
@@ -3,7 +3,7 @@ module VERSION #:nodoc:
MAJOR = 3
MINOR = 0
TINY = 0
- BUILD = "beta3"
+ BUILD = "beta4"
STRING = [MAJOR, MINOR, TINY, BUILD].join('.')
end
@@ -33,6 +33,11 @@ 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)
@@ -264,6 +269,18 @@ def give_a_greeting
assert_equal("application/pdf", email.parts[1].mime_type)
assert_equal("VGhpcyBpcyB0ZXN0IEZpbGUgY29udGVudA==\r\n", email.parts[1].body.encoded)
end
+
+ test "can embed an inline attachment" do
+ email = BaseMailer.inline_attachment
+ # Need to call #encoded to force the JIT sort on parts
+ email.encoded
+ assert_equal(2, email.parts.length)
+ assert_equal("multipart/related", email.mime_type)
+ assert_equal("multipart/alternative", email.parts[0].mime_type)
+ assert_equal("text/plain", email.parts[0].parts[0].mime_type)
+ assert_equal("text/html", email.parts[0].parts[1].mime_type)
+ assert_equal("logo.png", email.parts[1].filename)
+ end
# Defaults values
test "uses default charset from class" do
@@ -0,0 +1,5 @@
+<h1>Inline Image</h1>
+
+<%= image_tag attachments['logo.png'].url %>
+
+<p>This is an image that is inline</p>
@@ -0,0 +1,4 @@
+Inline Image
+
+No image for you
+
@@ -674,7 +674,7 @@ def test_unquote_quoted_printable_subject
EOF
mail = Mail.new(msg)
assert_equal "testing testing \326\244", mail.subject
- assert_equal "Subject: =?UTF-8?Q?testing_testing_=D6=A4?=\r\n", mail[:subject].encoded
+ assert_equal "Subject: testing testing =?UTF-8?Q?_=D6=A4=?=\r\n", mail[:subject].encoded
end
def test_unquote_7bit_subject
@@ -863,15 +863,15 @@ def test_multipart_with_mime_version
def test_multipart_with_utf8_subject
mail = TestMailer.multipart_with_utf8_subject(@recipient)
- regex = Regexp.escape('Subject: =?UTF-8?Q?Foo_=C3=A1=C3=AB=C3=B4_=C3=AE=C3=BC?=')
+ regex = Regexp.escape('Subject: Foo =?UTF-8?Q?=C3=A1=C3=AB=C3=B4=?= =?UTF-8?Q?_=C3=AE=C3=BC=?=')
assert_match(/#{regex}/, mail.encoded)
string = "Foo áëô îü"
assert_match(string, mail.subject)
end
def test_implicitly_multipart_with_utf8
mail = TestMailer.implicitly_multipart_with_utf8
- regex = Regexp.escape('Subject: =?UTF-8?Q?Foo_=C3=A1=C3=AB=C3=B4_=C3=AE=C3=BC?=')
+ regex = Regexp.escape('Subject: Foo =?UTF-8?Q?=C3=A1=C3=AB=C3=B4=?= =?UTF-8?Q?_=C3=AE=C3=BC=?=')
assert_match(/#{regex}/, mail.encoded)
string = "Foo áëô îü"
assert_match(string, mail.subject)
View
@@ -1,4 +1,14 @@
-*Rails 3.0.0 [beta 4/release candidate] (unreleased)*
+*Rails 3.0.0 [beta 4] (June 8th, 2010)*
+
+* Add shallow routes back to the new router [Diego Carrion]
+
+ resources :posts do
+ shallow do
+ resources :comments
+ end
+ end
+
+ You can now use comment_path for /comments/1 instead of post_comment_path for /posts/1/comments/1.
* Remove middleware laziness [José Valim]
@@ -16,5 +16,13 @@ def _router
raise "In order to use #url_for, you must include the helpers of a particular " \
"router. For instance, `include Rails.application.routes.url_helpers"
end
+
+ module ClassMethods
+ def action_methods
+ @action_methods ||= begin
+ super - _router.named_routes.helper_names
+ end
+ end
+ end
end
end
@@ -23,6 +23,7 @@ class Tokenizer #:nodoc:
# Create a new Tokenizer for the given text.
def initialize(text)
+ text.encode! if text.encoding_aware?
@scanner = StringScanner.new(text)
@position = 0
@line = 0
@@ -6,7 +6,7 @@ module ActionDispatch
# This middleware rescues any exception returned by the application and renders
# nice exception pages if it's being rescued locally.
class ShowExceptions
- LOCALHOST = ['127.0.0.1', '::1'].freeze
+ LOCALHOST = [/^127\.0\.0\.\d{1,3}$/, "::1", /^0:0:0:0:0:0:0:1(%.*)?$/].freeze
RESCUES_TEMPLATE_PATH = File.join(File.dirname(__FILE__), 'templates')
@@ -114,7 +114,7 @@ def rescue_action_in_public(exception)
# True if the request came from localhost, 127.0.0.1.
def local_request?(request)
- LOCALHOST.any?{ |local_ip| request.remote_addr == local_ip && request.remote_ip == local_ip }
+ LOCALHOST.any? { |local_ip| local_ip === request.remote_addr && local_ip === request.remote_ip }
end
def status_code(exception)
Oops, something went wrong.

0 comments on commit 751f79a

Please sign in to comment.