mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-10 07:25:50 +01:00
Merge remote-tracking branch 'origin/master' into api-support
Conflicts: src/main/scala/ScalatraBootstrap.scala src/main/scala/gitbucket/core/controller/AccountController.scala src/main/scala/gitbucket/core/controller/ControllerBase.scala src/main/scala/gitbucket/core/controller/IssuesController.scala src/main/scala/gitbucket/core/controller/PullRequestsController.scala src/main/scala/gitbucket/core/controller/RepositorySettingsController.scala src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala src/main/scala/gitbucket/core/model/Profile.scala src/main/scala/gitbucket/core/service/PullRequestService.scala src/main/scala/gitbucket/core/service/WebHookService.scala src/main/scala/gitbucket/core/servlet/InitializeListener.scala src/main/scala/gitbucket/core/view/helpers.scala src/main/twirl/gitbucket/core/pulls/conversation.scala.html src/main/twirl/gitbucket/core/pulls/mergeguide.scala.html src/main/twirl/issues/listparts.scala.html
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
package service
|
||||
package gitbucket.core.service
|
||||
|
||||
import gitbucket.core.model.{Account, GroupMember}
|
||||
import org.specs2.mutable.Specification
|
||||
import java.util.Date
|
||||
import model.GroupMember
|
||||
|
||||
class AccountServiceSpec extends Specification with ServiceSpecBase {
|
||||
|
||||
@@ -11,7 +11,7 @@ class AccountServiceSpec extends Specification with ServiceSpecBase {
|
||||
|
||||
"getAllUsers" in { withTestDB { implicit session =>
|
||||
AccountService.getAllUsers() must be like{
|
||||
case List(model.Account("root", "root", RootMailAddress, _, true, _, _, _, None, None, false, false)) => ok
|
||||
case List(Account("root", "root", RootMailAddress, _, true, _, _, _, None, None, false, false)) => ok
|
||||
}
|
||||
}}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package service
|
||||
package gitbucket.core.service
|
||||
|
||||
import model.Profile._
|
||||
import gitbucket.core.servlet.AutoUpdate
|
||||
import gitbucket.core.util.{ControlUtil, DatabaseConfig, FileUtil}
|
||||
import gitbucket.core.model.Profile._
|
||||
import profile.simple._
|
||||
import util.ControlUtil._
|
||||
import util.DatabaseConfig
|
||||
import ControlUtil._
|
||||
import java.sql.DriverManager
|
||||
import org.apache.commons.io.FileUtils
|
||||
import scala.util.Random
|
||||
@@ -13,11 +14,11 @@ import model._
|
||||
trait ServiceSpecBase {
|
||||
|
||||
def withTestDB[A](action: (Session) => A): A = {
|
||||
util.FileUtil.withTmpDir(new File(FileUtils.getTempDirectory(), Random.alphanumeric.take(10).mkString)){ dir =>
|
||||
FileUtil.withTmpDir(new File(FileUtils.getTempDirectory(), Random.alphanumeric.take(10).mkString)){ dir =>
|
||||
val (url, user, pass) = (DatabaseConfig.url(Some(dir.toString)), DatabaseConfig.user, DatabaseConfig.password)
|
||||
org.h2.Driver.load()
|
||||
using(DriverManager.getConnection(url, user, pass)){ conn =>
|
||||
servlet.AutoUpdate.versions.reverse.foreach(_.update(conn, Thread.currentThread.getContextClassLoader))
|
||||
AutoUpdate.versions.reverse.foreach(_.update(conn, Thread.currentThread.getContextClassLoader))
|
||||
}
|
||||
Database.forURL(url, user, pass).withSession { session =>
|
||||
action(session)
|
||||
@@ -1,4 +1,4 @@
|
||||
package ssh
|
||||
package gitbucket.core.ssh
|
||||
|
||||
import org.specs2.mutable._
|
||||
import org.specs2.mock.Mockito
|
||||
@@ -1,4 +1,4 @@
|
||||
package util
|
||||
package gitbucket.core.util
|
||||
|
||||
import org.specs2.mutable._
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package util
|
||||
package gitbucket.core.util
|
||||
|
||||
import org.specs2.mutable._
|
||||
import org.scalatra.i18n.Messages
|
||||
@@ -1,14 +1,15 @@
|
||||
package view
|
||||
package gitbucket.core.view
|
||||
|
||||
import java.util.Date
|
||||
|
||||
import gitbucket.core.model.Account
|
||||
import gitbucket.core.service.{SystemSettingsService, RequestCache}
|
||||
import gitbucket.core.controller.Context
|
||||
import org.specs2.mutable._
|
||||
import org.specs2.mock.Mockito
|
||||
import service.RequestCache
|
||||
import model.Account
|
||||
import service.SystemSettingsService.SystemSettings
|
||||
import play.twirl.api.Html
|
||||
import SystemSettingsService.SystemSettings
|
||||
import javax.servlet.http.HttpServletRequest
|
||||
import play.twirl.api.Html
|
||||
|
||||
class AvatarImageProviderSpec extends Specification with Mockito {
|
||||
|
||||
@@ -19,7 +20,7 @@ class AvatarImageProviderSpec extends Specification with Mockito {
|
||||
|
||||
"getAvatarImageHtml" should {
|
||||
"show Gravatar image for no image account if gravatar integration is enabled" in {
|
||||
implicit val context = app.Context(createSystemSettings(true), None, request)
|
||||
implicit val context = Context(createSystemSettings(true), None, request)
|
||||
val provider = new AvatarImageProviderImpl(Some(createAccount(None)))
|
||||
|
||||
provider.toHtml("user", 32).toString mustEqual
|
||||
@@ -27,7 +28,7 @@ class AvatarImageProviderSpec extends Specification with Mockito {
|
||||
}
|
||||
|
||||
"show uploaded image even if gravatar integration is enabled" in {
|
||||
implicit val context = app.Context(createSystemSettings(true), None, request)
|
||||
implicit val context = Context(createSystemSettings(true), None, request)
|
||||
val provider = new AvatarImageProviderImpl(Some(createAccount(Some("icon.png"))))
|
||||
|
||||
provider.toHtml("user", 32).toString mustEqual
|
||||
@@ -35,7 +36,7 @@ class AvatarImageProviderSpec extends Specification with Mockito {
|
||||
}
|
||||
|
||||
"show local image for no image account if gravatar integration is disabled" in {
|
||||
implicit val context = app.Context(createSystemSettings(false), None, request)
|
||||
implicit val context = Context(createSystemSettings(false), None, request)
|
||||
val provider = new AvatarImageProviderImpl(Some(createAccount(None)))
|
||||
|
||||
provider.toHtml("user", 32).toString mustEqual
|
||||
@@ -43,7 +44,7 @@ class AvatarImageProviderSpec extends Specification with Mockito {
|
||||
}
|
||||
|
||||
"show Gravatar image for specified mail address if gravatar integration is enabled" in {
|
||||
implicit val context = app.Context(createSystemSettings(true), None, request)
|
||||
implicit val context = Context(createSystemSettings(true), None, request)
|
||||
val provider = new AvatarImageProviderImpl(None)
|
||||
|
||||
provider.toHtml("user", 20, "hoge@hoge.com").toString mustEqual
|
||||
@@ -51,7 +52,7 @@ class AvatarImageProviderSpec extends Specification with Mockito {
|
||||
}
|
||||
|
||||
"show unknown image for unknown user if gravatar integration is enabled" in {
|
||||
implicit val context = app.Context(createSystemSettings(true), None, request)
|
||||
implicit val context = Context(createSystemSettings(true), None, request)
|
||||
val provider = new AvatarImageProviderImpl(None)
|
||||
|
||||
provider.toHtml("user", 20).toString mustEqual
|
||||
@@ -59,7 +60,7 @@ class AvatarImageProviderSpec extends Specification with Mockito {
|
||||
}
|
||||
|
||||
"show unknown image for specified mail address if gravatar integration is disabled" in {
|
||||
implicit val context = app.Context(createSystemSettings(false), None, request)
|
||||
implicit val context = Context(createSystemSettings(false), None, request)
|
||||
val provider = new AvatarImageProviderImpl(None)
|
||||
|
||||
provider.toHtml("user", 20, "hoge@hoge.com").toString mustEqual
|
||||
@@ -67,7 +68,7 @@ class AvatarImageProviderSpec extends Specification with Mockito {
|
||||
}
|
||||
|
||||
"add tooltip if it's enabled" in {
|
||||
implicit val context = app.Context(createSystemSettings(false), None, request)
|
||||
implicit val context = Context(createSystemSettings(false), None, request)
|
||||
val provider = new AvatarImageProviderImpl(None)
|
||||
|
||||
provider.toHtml("user", 20, "hoge@hoge.com", true).toString mustEqual
|
||||
@@ -111,10 +112,10 @@ class AvatarImageProviderSpec extends Specification with Mockito {
|
||||
class AvatarImageProviderImpl(account: Option[Account]) extends AvatarImageProvider with RequestCache {
|
||||
|
||||
def toHtml(userName: String, size: Int, mailAddress: String = "", tooltip: Boolean = false)
|
||||
(implicit context: app.Context): Html = getAvatarImageHtml(userName, size, mailAddress, tooltip)
|
||||
(implicit context: Context): Html = getAvatarImageHtml(userName, size, mailAddress, tooltip)
|
||||
|
||||
override def getAccountByMailAddress(mailAddress: String)(implicit context: app.Context): Option[Account] = account
|
||||
override def getAccountByUserName(userName: String)(implicit context: app.Context): Option[Account] = account
|
||||
override def getAccountByMailAddress(mailAddress: String)(implicit context: Context): Option[Account] = account
|
||||
override def getAccountByUserName(userName: String)(implicit context: Context): Option[Account] = account
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package view
|
||||
package gitbucket.core.view
|
||||
|
||||
import org.specs2.mutable._
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package view
|
||||
package gitbucket.core.view
|
||||
|
||||
import gitbucket.core.util.ControlUtil
|
||||
import org.specs2.mutable._
|
||||
import util.ControlUtil._
|
||||
import ControlUtil._
|
||||
|
||||
class PaginationSpec extends Specification {
|
||||
|
||||
Reference in New Issue
Block a user