PageRenderTime 62ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/test/unit/group_mailer_test.rb

https://github.com/newrooky/lftwb
Ruby | 42 lines | 33 code | 9 blank | 0 comment | 0 complexity | 3da46f6f45d16d61c647de2043b4ea14 MD5 | raw file
Possible License(s): MIT
  1. require File.dirname(__FILE__) + '/../test_helper'
  2. require 'group_mailer'
  3. class GroupMailerTest < Test::Unit::TestCase
  4. FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures'
  5. fixtures :users, :groups
  6. include ActionMailer::Quoting
  7. def setup
  8. ActionMailer::Base.delivery_method = :test
  9. ActionMailer::Base.perform_deliveries = true
  10. ActionMailer::Base.deliveries = []
  11. @expected = TMail::Mail.new
  12. @expected.set_content_type "text", "plain", { "charset" => 'utf-8' }
  13. end
  14. should "send invite email" do
  15. user = User.find(users(:quentin))
  16. group = Group.find(groups(:africa))
  17. email = 'asdf@example.com'
  18. name = 'asdf'
  19. subject = "Invitation"
  20. message = "Come join our group"
  21. response = GroupMailer.create_invite(user, group, email, name, subject, message)
  22. assert_match subject, response.subject
  23. assert_match "#{user.first_name}", response.body
  24. assert_equal email, response.to[0]
  25. end
  26. private
  27. def read_fixture(action)
  28. IO.readlines("#{FIXTURES_PATH}/group_mailer/#{action}")
  29. end
  30. def encode(subject)
  31. quoted_printable(subject, 'utf-8')
  32. end
  33. end