diff options
author | José Valim and Mikel Lindsaar <pair@programming.com> | 2010-01-25 00:20:38 +0100 |
---|---|---|
committer | José Valim and Mikel Lindsaar <pair@programming.com> | 2010-01-25 00:20:38 +0100 |
commit | 48faf53be19c569e85f43a4dbfa63fe81618b09f (patch) | |
tree | 9a9c7dbb9efd62fad3cae0ff3c21f72b18ab6528 /actionmailer | |
parent | 90e9e46576c0a8d57887484cd4f3f51b3b6cce3a (diff) | |
download | rails-48faf53be19c569e85f43a4dbfa63fe81618b09f.tar.gz rails-48faf53be19c569e85f43a4dbfa63fe81618b09f.tar.bz2 rails-48faf53be19c569e85f43a4dbfa63fe81618b09f.zip |
Add some view paths tests.
Diffstat (limited to 'actionmailer')
-rw-r--r-- | actionmailer/test/base_test.rb | 65 | ||||
-rw-r--r-- | actionmailer/test/fixtures/another.path/base_mailer/welcome.erb | 1 |
2 files changed, 43 insertions, 23 deletions
diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index 71845d4c42..b8d21132de 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -238,6 +238,48 @@ class BaseTest < ActiveSupport::TestCase end end + test "implicit multipart with default locale" do + email = BaseMailer.implicit_with_locale.deliver + assert_equal(2, email.parts.size) + assert_equal("multipart/alternate", email.mime_type) + assert_equal("text/plain", email.parts[0].mime_type) + assert_equal("Implicit with locale TEXT", email.parts[0].body.encoded) + assert_equal("text/html", email.parts[1].mime_type) + assert_equal("Implicit with locale EN HTML", email.parts[1].body.encoded) + end + + test "implicit multipart with other locale" do + swap I18n, :locale => :pl do + email = BaseMailer.implicit_with_locale.deliver + assert_equal(2, email.parts.size) + assert_equal("multipart/alternate", email.mime_type) + assert_equal("text/plain", email.parts[0].mime_type) + assert_equal("Implicit with locale PL TEXT", email.parts[0].body.encoded) + assert_equal("text/html", email.parts[1].mime_type) + assert_equal("Implicit with locale HTML", email.parts[1].body.encoded) + end + end + + test "implicit multipart with several view paths uses the first one with template" do + begin + BaseMailer.view_paths.unshift(File.join(FIXTURE_LOAD_PATH, "another.path")) + email = BaseMailer.welcome.deliver + assert_equal("Welcome from another path", email.body.encoded) + ensure + BaseMailer.view_paths.shift + end + end + + test "implicit multipart with inexistent templates uses the next view path" do + begin + BaseMailer.view_paths.unshift(File.join(FIXTURE_LOAD_PATH, "unknown")) + email = BaseMailer.welcome.deliver + assert_equal("Welcome", email.body.encoded) + ensure + BaseMailer.view_paths.shift + end + end + # Explicit multipart test "explicit multipart" do email = BaseMailer.explicit_multipart.deliver @@ -314,29 +356,6 @@ class BaseTest < ActiveSupport::TestCase assert_equal(1, BaseMailer.deliveries.length) end - test "implicit multipart with default locale" do - email = BaseMailer.implicit_with_locale.deliver - assert_equal(2, email.parts.size) - assert_equal("multipart/alternate", email.mime_type) - assert_equal("text/plain", email.parts[0].mime_type) - assert_equal("Implicit with locale TEXT", email.parts[0].body.encoded) - assert_equal("text/html", email.parts[1].mime_type) - assert_equal("Implicit with locale EN HTML", email.parts[1].body.encoded) - end - - test "implicit multipart with other locale" do - swap I18n, :locale => :pl do - email = BaseMailer.implicit_with_locale.deliver - assert_equal(2, email.parts.size) - assert_equal("multipart/alternate", email.mime_type) - assert_equal("text/plain", email.parts[0].mime_type) - assert_equal("Implicit with locale PL TEXT", email.parts[0].body.encoded) - assert_equal("text/html", email.parts[1].mime_type) - assert_equal("Implicit with locale HTML", email.parts[1].body.encoded) - end - end - - protected # Execute the block setting the given values and restoring old values after diff --git a/actionmailer/test/fixtures/another.path/base_mailer/welcome.erb b/actionmailer/test/fixtures/another.path/base_mailer/welcome.erb new file mode 100644 index 0000000000..ef451298e2 --- /dev/null +++ b/actionmailer/test/fixtures/another.path/base_mailer/welcome.erb @@ -0,0 +1 @@ +Welcome from another path
\ No newline at end of file |