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


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to