forked from t2v/play2-auth
-
Notifications
You must be signed in to change notification settings - Fork 0
Test
Manabu Nakamura edited this page May 11, 2013
·
1 revision
You can use FakeRequest
with logged-in status.
package test
import org.specs2.mutable._
import play.api.test._
import play.api.test.Helpers._
import controllers.{AuthConfigImpl, Messages}
import jp.t2v.lab.play2.auth.test.Helpers._
class ApplicationSpec extends Specification {
object config extends AuthConfigImpl
"Messages" should {
"return list when user is authorized" in new WithApplication {
val res = Messages.list(FakeRequest().withLoggedIn(config)(1))
contentType(res) must equalTo("text/html")
}
}
}
-
Import
jp.t2v.lab.play2.auth.test.Helpers._
-
Define instance what is mixed-in
AuthConfigImpl
object config extends AuthConfigImpl
-
Call
withLoggedIn
method onFakeRequest
- first argument:
AuthConfigImpl
instance. - second argument: user ID of the user who is logged-in at this request
- first argument:
It makes enable to test controllers with play2.auth