Consider the following test:
- create a trivial mail with one attachment
- #attachments returns nil (see test method #test_out below)
- however if I access the mail e.g. with #to_s then #attachments
returns the created attachment correctly
(see test method #test_out_with_side_effect below)
---------------------bla_test.rb---------------
class BlaMailer < ActionMailer::Base
def out
attachment :content_type => "text/plain",
:body => "attachment text",
:filename => "bla.txt"
end
end
---------------------bla_mailer_test.rb---------------
require File.dirname(__FILE__) + '/../test_helper'
class BlaMailerTest < Test::Unit::TestCase
def test_out
m= BlaMailer.create_out
puts "attachments=#{m.attachments}"
assert_not_nil m.attachments
end
def test_out_with_side_effect
m= BlaMailer.create_out
m.to_s
puts "with side effect: attachments=#{m.attachments}"
assert_not_nil m.attachments
end
end