From 9f7190187cd755345557009a0b0ca9eec679b415 Mon Sep 17 00:00:00 2001
From: Joshua Peek <josh@joshpeek.com>
Date: Tue, 26 Jan 2010 09:27:21 -0600
Subject: Failing AM test for nested layouts

---
 .../test/fixtures/nested/layouts/spam.html.erb        |  1 +
 .../fixtures/nested_layout_mailer/signup.html.erb     |  1 +
 actionmailer/test/old_base/mail_layout_test.rb        | 19 +++++++++++++++++--
 3 files changed, 19 insertions(+), 2 deletions(-)
 create mode 100644 actionmailer/test/fixtures/nested/layouts/spam.html.erb
 create mode 100644 actionmailer/test/fixtures/nested_layout_mailer/signup.html.erb

(limited to 'actionmailer')

diff --git a/actionmailer/test/fixtures/nested/layouts/spam.html.erb b/actionmailer/test/fixtures/nested/layouts/spam.html.erb
new file mode 100644
index 0000000000..7a24b19b7f
--- /dev/null
+++ b/actionmailer/test/fixtures/nested/layouts/spam.html.erb
@@ -0,0 +1 @@
+Nested Spammer layout <%= yield %>
\ No newline at end of file
diff --git a/actionmailer/test/fixtures/nested_layout_mailer/signup.html.erb b/actionmailer/test/fixtures/nested_layout_mailer/signup.html.erb
new file mode 100644
index 0000000000..4789e888c6
--- /dev/null
+++ b/actionmailer/test/fixtures/nested_layout_mailer/signup.html.erb
@@ -0,0 +1 @@
+We do not spam
\ No newline at end of file
diff --git a/actionmailer/test/old_base/mail_layout_test.rb b/actionmailer/test/old_base/mail_layout_test.rb
index 4038fbf339..2abd3ece92 100644
--- a/actionmailer/test/old_base/mail_layout_test.rb
+++ b/actionmailer/test/old_base/mail_layout_test.rb
@@ -1,7 +1,7 @@
 require 'abstract_unit'
 
 class AutoLayoutMailer < ActionMailer::Base
-  
+
   def hello
     recipients 'test@localhost'
     subject    "You have a mail"
@@ -51,6 +51,16 @@ class ExplicitLayoutMailer < ActionMailer::Base
   end
 end
 
+class NestedLayoutMailer < ActionMailer::Base
+  layout 'nested/layouts/spam'
+
+  def signup
+    recipients 'test@localhost'
+    subject    "You have a mail"
+    from       "tester@example.com"
+  end
+end
+
 class LayoutMailerTest < Test::Unit::TestCase
   def setup
     set_delivery_method :test
@@ -77,7 +87,7 @@ class LayoutMailerTest < Test::Unit::TestCase
     # CHANGED: content_type returns an object
     # assert_equal 'text/plain', mail.parts.first.content_type
     assert_equal 'text/plain', mail.parts.first.mime_type
-    
+
     # CHANGED: body returns an object
     # assert_equal "text/plain layout - text/plain multipart", mail.parts.first.body
     assert_equal "text/plain layout - text/plain multipart", mail.parts.first.body.to_s
@@ -145,4 +155,9 @@ class LayoutMailerTest < Test::Unit::TestCase
     mail = ExplicitLayoutMailer.logout
     assert_equal "You logged out", mail.body.to_s.strip
   end
+
+  def test_nested_class_layout
+    mail = NestedLayoutMailer.signup
+    assert_equal "Nested Spammer layout We do not spam", mail.body.to_s.strip
+  end
 end
-- 
cgit v1.2.3


From 31b538df6457ba723668afc62e85056e3bca9413 Mon Sep 17 00:00:00 2001
From: Joshua Peek <josh@joshpeek.com>
Date: Tue, 26 Jan 2010 09:37:20 -0600
Subject: Failing AM test for legacy multipart alternative rendering

---
 .../test_mailer/multipart_alternative.html.erb     |  1 +
 .../test_mailer/multipart_alternative.plain.erb    |  1 +
 actionmailer/test/old_base/mail_render_test.rb     | 37 ++++++++++++++++++++++
 3 files changed, 39 insertions(+)
 create mode 100644 actionmailer/test/fixtures/test_mailer/multipart_alternative.html.erb
 create mode 100644 actionmailer/test/fixtures/test_mailer/multipart_alternative.plain.erb

(limited to 'actionmailer')

diff --git a/actionmailer/test/fixtures/test_mailer/multipart_alternative.html.erb b/actionmailer/test/fixtures/test_mailer/multipart_alternative.html.erb
new file mode 100644
index 0000000000..73ea14f82f
--- /dev/null
+++ b/actionmailer/test/fixtures/test_mailer/multipart_alternative.html.erb
@@ -0,0 +1 @@
+<strong>foo</strong> <%= @foo %>
\ No newline at end of file
diff --git a/actionmailer/test/fixtures/test_mailer/multipart_alternative.plain.erb b/actionmailer/test/fixtures/test_mailer/multipart_alternative.plain.erb
new file mode 100644
index 0000000000..779fe4c1ea
--- /dev/null
+++ b/actionmailer/test/fixtures/test_mailer/multipart_alternative.plain.erb
@@ -0,0 +1 @@
+foo: <%= @foo %>
\ No newline at end of file
diff --git a/actionmailer/test/old_base/mail_render_test.rb b/actionmailer/test/old_base/mail_render_test.rb
index 804200fd36..7ba55b1bd2 100644
--- a/actionmailer/test/old_base/mail_render_test.rb
+++ b/actionmailer/test/old_base/mail_render_test.rb
@@ -62,6 +62,33 @@ class RenderMailer < ActionMailer::Base
     super
     mailer_name "test_mailer"
   end
+
+  def multipart_alternative
+    recipients 'test@localhost'
+    subject    'multipart/alternative'
+    from       'tester@example.com'
+
+    build_multipart_message(:foo => "bar")
+  end
+
+  private
+    def build_multipart_message(assigns = {})
+      content_type "multipart/alternative"
+
+      part "text/plain" do |p|
+        p.body = build_body_part('plain', assigns, :layout => false)
+      end
+
+      part "text/html" do |p|
+        p.body = build_body_part('html', assigns)
+        p.transfer_encoding = "base64"
+      end
+    end
+
+    def build_body_part(content_type, assigns, options = {})
+      render "#{template}.#{content_type}", :body => assigns
+      # render options.merge(:file => "#{template}.#{content_type}", :body => assigns)
+    end
 end
 
 class FirstMailer < ActionMailer::Base
@@ -129,6 +156,16 @@ class RenderHelperTest < Test::Unit::TestCase
     mail = RenderMailer.no_instance_variable.deliver
     assert_equal "Look, subject.nil? is true!", mail.body.to_s.strip
   end
+
+  def test_legacy_multipart_alternative
+    mail = RenderMailer.multipart_alternative.deliver
+    assert_equal(2, email.parts.size)
+    assert_equal("multipart/alternative", email.mime_type)
+    assert_equal("text/plain", email.parts[0].mime_type)
+    assert_equal("foo: bar", email.parts[0].body.encoded)
+    assert_equal("text/html", email.parts[1].mime_type)
+    assert_equal("<strong>foo</strong> bar", email.parts[1].body.encoded)
+  end
 end
 
 class FirstSecondHelperTest < Test::Unit::TestCase
-- 
cgit v1.2.3