From 296007744525638b142501efee57faf6ac4be20f Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Fri, 29 Jan 2010 13:00:12 +0100 Subject: [PATCH] Add a failing test case for render :layout 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 | 15 +++++++++++++++ .../base_mailer/different_layout.html.erb | 1 + .../base_mailer/different_layout.text.erb | 1 + .../base_mailer/email_custom_layout.text.html.erb | 1 + .../fixtures/layouts/different_layout.html.erb | 1 + .../fixtures/layouts/different_layout.text.erb | 1 + 6 files changed, 20 insertions(+) create mode 100644 actionmailer/test/fixtures/base_mailer/different_layout.html.erb create mode 100644 actionmailer/test/fixtures/base_mailer/different_layout.text.erb create mode 100644 actionmailer/test/fixtures/base_mailer/email_custom_layout.text.html.erb create mode 100644 actionmailer/test/fixtures/layouts/different_layout.html.erb create mode 100644 actionmailer/test/fixtures/layouts/different_layout.text.erb diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index b7a8bc73de8..2d3f8ac13ad 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -86,6 +86,15 @@ class BaseTest < ActiveSupport::TestCase 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 test "method call to mail does not raise error" do @@ -469,6 +478,12 @@ class BaseTest < ActiveSupport::TestCase assert_equal("TEXT Explicit Multipart Templates", mail.text_part.body.decoded) end + test "that you can specify a different layout" do + mail = BaseMailer.different_layout('different_layout') + assert_equal("HTML -- HTML", mail.html_part.body.decoded) + assert_equal("PLAIN -- PLAIN", mail.text_part.body.decoded) + end + protected # Execute the block setting the given values and restoring old values after diff --git a/actionmailer/test/fixtures/base_mailer/different_layout.html.erb b/actionmailer/test/fixtures/base_mailer/different_layout.html.erb new file mode 100644 index 00000000000..3225efc49a9 --- /dev/null +++ b/actionmailer/test/fixtures/base_mailer/different_layout.html.erb @@ -0,0 +1 @@ +HTML \ No newline at end of file diff --git a/actionmailer/test/fixtures/base_mailer/different_layout.text.erb b/actionmailer/test/fixtures/base_mailer/different_layout.text.erb new file mode 100644 index 00000000000..b547f4a3323 --- /dev/null +++ b/actionmailer/test/fixtures/base_mailer/different_layout.text.erb @@ -0,0 +1 @@ +PLAIN \ No newline at end of file diff --git a/actionmailer/test/fixtures/base_mailer/email_custom_layout.text.html.erb b/actionmailer/test/fixtures/base_mailer/email_custom_layout.text.html.erb new file mode 100644 index 00000000000..a2187308b6d --- /dev/null +++ b/actionmailer/test/fixtures/base_mailer/email_custom_layout.text.html.erb @@ -0,0 +1 @@ +body_text \ No newline at end of file diff --git a/actionmailer/test/fixtures/layouts/different_layout.html.erb b/actionmailer/test/fixtures/layouts/different_layout.html.erb new file mode 100644 index 00000000000..99eb026ae1e --- /dev/null +++ b/actionmailer/test/fixtures/layouts/different_layout.html.erb @@ -0,0 +1 @@ +HTML -- <%= yield %> \ No newline at end of file diff --git a/actionmailer/test/fixtures/layouts/different_layout.text.erb b/actionmailer/test/fixtures/layouts/different_layout.text.erb new file mode 100644 index 00000000000..b93467b7ae1 --- /dev/null +++ b/actionmailer/test/fixtures/layouts/different_layout.text.erb @@ -0,0 +1 @@ +PLAIN -- <%= yield %> \ No newline at end of file