diff options
Diffstat (limited to 'actionmailer/test')
-rw-r--r-- | actionmailer/test/base_test.rb | 13 | ||||
-rw-r--r-- | actionmailer/test/caching_test.rb | 4 | ||||
-rw-r--r-- | actionmailer/test/mailers/proc_mailer.rb | 9 |
3 files changed, 21 insertions, 5 deletions
diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index 977e0e201e..4124aa00bd 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -506,8 +506,8 @@ class BaseTest < ActiveSupport::TestCase test "should respond to action methods" do assert_respond_to BaseMailer, :welcome assert_respond_to BaseMailer, :implicit_multipart - assert !BaseMailer.respond_to?(:mail) - assert !BaseMailer.respond_to?(:headers) + assert_not_respond_to BaseMailer, :mail + assert_not_respond_to BaseMailer, :headers end test "calling just the action should return the generated mail object" do @@ -725,6 +725,15 @@ class BaseTest < ActiveSupport::TestCase assert(ProcMailer.welcome["x-has-to-proc"].to_s == "symbol") end + test "proc default values can have arity of 1 where arg is a mailer instance" do + assert_equal(ProcMailer.welcome["X-Lambda-Arity-1-arg"].to_s, "complex_value") + assert_equal(ProcMailer.welcome["X-Lambda-Arity-1-self"].to_s, "complex_value") + end + + test "proc default values with fixed arity of 0 can be called" do + assert_equal("0", ProcMailer.welcome["X-Lambda-Arity-0"].to_s) + end + test "we can call other defined methods on the class as needed" do mail = ProcMailer.welcome assert_equal("Thanks for signing up this afternoon", mail.subject) diff --git a/actionmailer/test/caching_test.rb b/actionmailer/test/caching_test.rb index ae4e7bf57e..574840c30e 100644 --- a/actionmailer/test/caching_test.rb +++ b/actionmailer/test/caching_test.rb @@ -105,7 +105,7 @@ class FragmentCachingTest < BaseCachingTest html_safe = @mailer.read_fragment("name") assert_equal content, html_safe - assert html_safe.html_safe? + assert_predicate html_safe, :html_safe? end end @@ -262,7 +262,7 @@ class ViewCacheDependencyTest < BaseCachingTest end def test_view_cache_dependencies_are_empty_by_default - assert NoDependenciesMailer.new.view_cache_dependencies.empty? + assert_empty NoDependenciesMailer.new.view_cache_dependencies end def test_view_cache_dependencies_are_listed_in_declaration_order diff --git a/actionmailer/test/mailers/proc_mailer.rb b/actionmailer/test/mailers/proc_mailer.rb index b7cf53eb4a..76e730bb79 100644 --- a/actionmailer/test/mailers/proc_mailer.rb +++ b/actionmailer/test/mailers/proc_mailer.rb @@ -4,12 +4,19 @@ 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 }, - "x-has-to-proc" => :symbol + "x-has-to-proc" => :symbol, + "X-Lambda-Arity-0" => ->() { "0" }, + "X-Lambda-Arity-1-arg" => ->(arg) { arg.computed_value }, + "X-Lambda-Arity-1-self" => ->(_) { self.computed_value } def welcome mail end + def computed_value + "complex_value" + end + private def give_a_greeting |