Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Mailer inner classes #1469

Closed
wants to merge 3 commits into from

3 participants

@japgolly

Allows any class extending trait Mailer to accept the same instances of From(), To(), Subject(), etc.
This in turn allows for easier testing & mocking of Mailer.

(Supersedes #1468 which was against the obsolete lift_26_dev branch instead of master.)

https://groups.google.com/forum/#!topic/liftweb/HtBCb1XmmU4

japgolly added some commits
@japgolly japgolly Moved Mailer's inner classes from trait to object.
Allows any class extending the Mailer trait to accept the same instances
of From(), To(), Subject(), etc.
a954b74
@japgolly japgolly Signed contributors.md b465b37
@farmdawgnation
Collaborator
[error] /Users/matt/Sites/framework/core/util/src/test/scala/net/liftweb/util/MailerSpec.scala:62: not found: value From
[error]           From("sender@nowhere.com"),
[error]           ^
[error] one error found
[error] (lift-util/test:compile) Compilation failed
[error] Total time: 21 s, completed Jul 2, 2013 6:06:00 PM

Looks like you need to check those specs. ;)

@japgolly

Sorry about that. I shouldn't cut corners. I've pushed a new commit to fix it.

I also mentally prepared some proper tests for this PR, sat down to fix this first, and realised that the existing MailerSpec covers it. There we have a custom Mailer trait instance (not object) using the now-canonical From(), To() etc classes without error. That's what I planned to do anyway so I think we're good. :)

@fmpwizard
Owner

rebased to master, thanks!

@fmpwizard fmpwizard closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 2, 2013
  1. @japgolly

    Moved Mailer's inner classes from trait to object.

    japgolly authored
    Allows any class extending the Mailer trait to accept the same instances
    of From(), To(), Subject(), etc.
  2. @japgolly

    Signed contributors.md

    japgolly authored
Commits on Jul 3, 2013
  1. @japgolly
This page is out of date. Refresh to see the latest.
View
6 contributors.md
@@ -168,3 +168,9 @@ Will Palmeri
### Email: ###
wpalmeri at gmail dot com
+### Name: ###
+David Barri
+
+### Email: ###
+japgolly @@ gmail .. com
+
View
22 core/util/src/main/scala/net/liftweb/util/Mailer.scala
@@ -24,19 +24,13 @@ import java.util.Properties
import common._
import actor._
import xml.{Text, Elem, Node, NodeSeq}
+import Mailer._
/**
* Utilities for sending email.
*/
-object Mailer extends Mailer
+object Mailer extends Mailer {
-/**
- * This trait implmenets the mail sending. You can create subclasses of this class/trait and
- * implement your own mailer functionality
- */
-trait Mailer extends SimpleInjector {
- private val logger = Logger(classOf[Mailer])
-
sealed abstract class MailTypes
/**
* Add message headers to outgoing messages
@@ -73,9 +67,17 @@ trait Mailer extends SimpleInjector {
final case class BCC(address: String, name: Box[String] = Empty) extends AddressType
final case class ReplyTo(address: String, name: Box[String] = Empty) extends AddressType
- implicit def xmlToMailBodyType(html: NodeSeq): MailBodyType = XHTMLMailBodyType(html)
-
final case class MessageInfo(from: From, subject: Subject, info: List[MailTypes])
+}
+
+/**
+ * This trait implmenets the mail sending. You can create subclasses of this class/trait and
+ * implement your own mailer functionality
+ */
+trait Mailer extends SimpleInjector {
+ private val logger = Logger(classOf[Mailer])
+
+ implicit def xmlToMailBodyType(html: NodeSeq): MailBodyType = XHTMLMailBodyType(html)
implicit def addressToAddress(in: AddressType): Address = {
val ret = new InternetAddress(in.address)
View
1  core/util/src/test/scala/net/liftweb/util/MailerSpec.scala
@@ -23,6 +23,7 @@ import org.specs2.mutable.Specification
import common._
+import Mailer._
/**
* Systems under specification for Lift Mailer.
Something went wrong with that request. Please try again.