fix test.

This commit is contained in:
KOUNOIKE Yuusuke
2017-03-14 07:18:16 +09:00
parent 1312276151
commit 8087531d64

View File

@@ -1,5 +1,6 @@
package gitbucket.core.view package gitbucket.core.view
import java.text.SimpleDateFormat
import java.util.Date import java.util.Date
import gitbucket.core.model.Account import gitbucket.core.model.Account
@@ -34,18 +35,22 @@ class AvatarImageProviderSpec extends FunSpec with MockitoSugar {
it("should show uploaded image even if gravatar integration is enabled") { it("should show uploaded image even if gravatar integration is enabled") {
implicit val context = Context(createSystemSettings(true), None, request) implicit val context = Context(createSystemSettings(true), None, request)
val provider = new AvatarImageProviderImpl(Some(createAccount(Some("icon.png")))) val account = createAccount((Some("icon.png")))
val date = new SimpleDateFormat("yyyyMMddHHmmss").format(account.updatedDate)
val provider = new AvatarImageProviderImpl(Some(account))
assert(provider.toHtml("user", 32).toString == assert(provider.toHtml("user", 32).toString ==
"<img src=\"/user/_avatar\" class=\"avatar\" style=\"width: 32px; height: 32px;\" />") s"""<img src="/user/_avatar?${date}" class="avatar" style="width: 32px; height: 32px;" />""")
} }
it("should show local image for no image account if gravatar integration is disabled") { it("should show local image for no image account if gravatar integration is disabled") {
implicit val context = Context(createSystemSettings(false), None, request) implicit val context = Context(createSystemSettings(false), None, request)
val provider = new AvatarImageProviderImpl(Some(createAccount(None))) val account = createAccount(None)
val date = new SimpleDateFormat("yyyyMMddHHmmss").format(account.updatedDate)
val provider = new AvatarImageProviderImpl(Some(account))
assert(provider.toHtml("user", 32).toString == assert(provider.toHtml("user", 32).toString ==
"<img src=\"/user/_avatar\" class=\"avatar\" style=\"width: 32px; height: 32px;\" />") s"""<img src="/user/_avatar?${date}" class="avatar" style="width: 32px; height: 32px;" />""")
} }
it("should show Gravatar image for specified mail address if gravatar integration is enabled") { it("should show Gravatar image for specified mail address if gravatar integration is enabled") {