Skip to content

Commit

Permalink
BDOG-237 Preserve current page when signing in
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-lamed committed Jul 12, 2019
1 parent 7883ee5 commit a41905e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/views/standard_layout.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
</ul>

}{
<a id="sign-in" href="@appRoutes.AuthController.showSignInPage().url" class="@if(active=="sign-in") {active}">Sign in</a>
<a id="sign-in" href="@appRoutes.AuthController.showSignInPage(targetUrl = Some(request.target.uriString)).url" class="@if(active=="sign-in") {active}">Sign in</a>
}
</li>
<li >
Expand Down
10 changes: 6 additions & 4 deletions test/view/StandardLayoutSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import org.jsoup.Jsoup
import org.scalatest.{Matchers, WordSpec}
import org.scalatestplus.play.guice.GuiceOneAppPerSuite
import play.api.test.FakeRequest
import play.api.test.Helpers._
import play.twirl.api.Html
import views.html.standard_layout

Expand All @@ -28,16 +29,17 @@ class StandardLayoutSpec extends WordSpec with Matchers with GuiceOneAppPerSuite
"standard layout" should {

"show Sign In link if user is not signed-in" in {
val document = Jsoup.parse(standard_layout()(Html("n/a"))(FakeRequest()).toString())
val request = FakeRequest(GET, "/currentPage")
val document = Jsoup.parse(standard_layout()(Html("n/a"))(request).toString())

val signInLink = document.select("nav ul.nav.navbar-nav.navbar-right > li > a#sign-in")
signInLink.attr("href") shouldBe "/sign-in"
signInLink.attr("href") shouldBe "/sign-in?targetUrl=%2FcurrentPage"
signInLink.text shouldBe "Sign in"
}

"show name of a user if they are signed-in" in {
val expectedDisplayName = "John Smith"
val request = FakeRequest().withSession("ump.displayName" -> expectedDisplayName)
val request = FakeRequest(GET, "/currentPage").withSession("ump.displayName" -> expectedDisplayName)

val document = Jsoup.parse(standard_layout()(Html("n/a"))(request).toString())

Expand All @@ -47,7 +49,7 @@ class StandardLayoutSpec extends WordSpec with Matchers with GuiceOneAppPerSuite

"show a link to sign-out if user is signed-in" in {
val expectedDisplayName = "John Smith"
val request = FakeRequest().withSession("ump.displayName" -> expectedDisplayName)
val request = FakeRequest(GET, "/currentPage").withSession("ump.displayName" -> expectedDisplayName)

val document = Jsoup.parse(standard_layout()(Html("n/a"))(request).toString())

Expand Down

0 comments on commit a41905e

Please sign in to comment.