You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Manabu Nakamura edited this page May 11, 2013
·
1 revision
You can use FakeRequest with logged-in status.
packagetestimportorg.specs2.mutable._importplay.api.test._importplay.api.test.Helpers._importcontrollers.{AuthConfigImpl, Messages}
importjp.t2v.lab.play2.auth.test.Helpers._classApplicationSpecextendsSpecification {
objectconfigextendsAuthConfigImpl"Messages" should {
"return list when user is authorized" in newWithApplication {
valres=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 on FakeRequest
first argument: AuthConfigImpl instance.
second argument: user ID of the user who is logged-in at this request
It makes enable to test controllers with play2.auth