$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib') $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'nitro', 'lib') $:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'og', 'lib') $NITRO_NO_ENVIRONMENT = true require 'test/unit' require 'ostruct' require 'nitro' require 'glue/configuration' require 'glue/mailer' class TestCaseMail < Test::Unit::TestCase # :nodoc: all include Glue class DummyMailer < Mailer def initialize super @bcc = 'george.moschovitis@gmail.com' @template_root = 'test/public/dummy_mailer' end def registration(to, username, token) @to = to @from = 'system@nitroproject.org' @subject = 'Nitro.com registration' @cc = 'george.moschovitis@gmail.com' @body.username = username @body.token = token end def greek(to) @to = to @from = 'system@nitroproject.org' @subject = 'Ελληνικός Τίτλος' @cc = 'george.moschovitis@gmail.com' @body = 'Τί έγινε ρε παιδιά;' end end =begin class DummyController < Controller # mailer DummyMailer def register token = 999 deliver_registration('gmosx@nitroproject.org', 'gmosx', token) end end =end def test_mail m = Glue::Mail.new 'gmosx@nitroproject.org', 'drak@nitroproject.org', 'A simple test', 'This is the body of the message' expected = %{From: gmosx@nitroproject.org To: drak@nitroproject.org Subject: A simple test This is the body of the message} assert_equal expected, m.encoded m.to = %w{ renos@nitroproject.org stella@nitroproject.org } expected = %{From: gmosx@nitroproject.org To: renos@nitroproject.org, stella@nitroproject.org Subject: A simple test This is the body of the message} assert_equal expected, m.encoded end =begin def test_mailer assert_equal 0, DummyMailer.deliveries.size Mailer.server[:address] = 'mail.nitroproject.org' # assert_equal 'mail.nitroproject.org', DummyMailer.server[:address] Mailer.delivery_method = :test Mailer.template_root = File.join(File.dirname(__FILE__), '..', 'root', 'dummy_mailer') token = 999 DummyMailer.deliver_registration('george.moschovitis@gmail.com', 'gmosx', token) assert_equal 1, DummyMailer.deliveries.size expected = %{From: system@nitroproject.org To: george.moschovitis@gmail.com Cc: george.moschovitis@gmail.com Bcc: george.moschovitis@gmail.com Subject: =?utf-8?Q?Nitro=2ecom_registration?= Hello gmosx how do you feel? Here is your Token: 999 } assert_equal expected, DummyMailer.deliveries[0].encoded DummyMailer.deliver_greek('george.moschovitis@gmail.com') assert_equal 2, DummyMailer.deliveries.size end =end end