mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-11 07:55:55 +01:00
Merge branch 'master' into feature-tasklist
Conflicts: src/main/scala/app/IssuesController.scala src/main/twirl/issues/create.scala.html
This commit is contained in:
22
src/test/scala/plugin/PluginSystemSpec.scala
Normal file
22
src/test/scala/plugin/PluginSystemSpec.scala
Normal file
@@ -0,0 +1,22 @@
|
||||
package plugin
|
||||
|
||||
import org.specs2.mutable._
|
||||
|
||||
class PluginSystemSpec extends Specification {
|
||||
|
||||
"isUpdatable" should {
|
||||
"return true for updattable plugin" in {
|
||||
PluginSystem.isUpdatable("1.0.0", "1.0.1") must beTrue
|
||||
PluginSystem.isUpdatable("1.0.0", "1.1.0") must beTrue
|
||||
PluginSystem.isUpdatable("1.1.1", "1.2.0") must beTrue
|
||||
PluginSystem.isUpdatable("1.2.1", "2.0.0") must beTrue
|
||||
}
|
||||
"return false for not updattable plugin" in {
|
||||
PluginSystem.isUpdatable("1.0.0", "1.0.0") must beFalse
|
||||
PluginSystem.isUpdatable("1.0.1", "1.0.0") must beFalse
|
||||
PluginSystem.isUpdatable("1.1.1", "1.1.0") must beFalse
|
||||
PluginSystem.isUpdatable("2.0.0", "1.2.1") must beFalse
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,25 +9,25 @@ class AccountServiceSpec extends Specification with ServiceSpecBase {
|
||||
"AccountService" should {
|
||||
val RootMailAddress = "root@localhost"
|
||||
|
||||
"getAllUsers" in { withTestDB{
|
||||
"getAllUsers" in { withTestDB { implicit session =>
|
||||
AccountService.getAllUsers() must be like{
|
||||
case List(model.Account("root", "root", RootMailAddress, _, true, _, _, _, None, None, false, false)) => ok
|
||||
}
|
||||
}}
|
||||
|
||||
"getAccountByUserName" in { withTestDB{
|
||||
AccountService.getAccountByUserName("root") must beSome.like{
|
||||
"getAccountByUserName" in { withTestDB { implicit session =>
|
||||
AccountService.getAccountByUserName("root") must beSome.like {
|
||||
case user => user.userName must_== "root"
|
||||
}
|
||||
|
||||
AccountService.getAccountByUserName("invalid user name") must beNone
|
||||
}}
|
||||
|
||||
"getAccountByMailAddress" in { withTestDB{
|
||||
"getAccountByMailAddress" in { withTestDB { implicit session =>
|
||||
AccountService.getAccountByMailAddress(RootMailAddress) must beSome
|
||||
}}
|
||||
|
||||
"updateLastLoginDate" in { withTestDB{
|
||||
"updateLastLoginDate" in { withTestDB { implicit session =>
|
||||
val root = "root"
|
||||
def user() =
|
||||
AccountService.getAccountByUserName(root).getOrElse(sys.error(s"user $root does not exists"))
|
||||
@@ -46,7 +46,7 @@ class AccountServiceSpec extends Specification with ServiceSpecBase {
|
||||
}
|
||||
}}
|
||||
|
||||
"updateAccount" in { withTestDB{
|
||||
"updateAccount" in { withTestDB { implicit session =>
|
||||
val root = "root"
|
||||
def user() =
|
||||
AccountService.getAccountByUserName(root).getOrElse(sys.error(s"user $root does not exists"))
|
||||
@@ -56,7 +56,7 @@ class AccountServiceSpec extends Specification with ServiceSpecBase {
|
||||
user().mailAddress must_== newAddress
|
||||
}}
|
||||
|
||||
"group" in { withTestDB {
|
||||
"group" in { withTestDB { implicit session =>
|
||||
val group1 = "group1"
|
||||
val user1 = "root"
|
||||
AccountService.createGroup(group1, None)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package service
|
||||
|
||||
import scala.slick.session.Database
|
||||
import model.Profile._
|
||||
import profile.simple._
|
||||
import util.ControlUtil._
|
||||
import java.sql.DriverManager
|
||||
import org.apache.commons.io.FileUtils
|
||||
@@ -9,15 +10,15 @@ import java.io.File
|
||||
|
||||
trait ServiceSpecBase {
|
||||
|
||||
def withTestDB[A](action: => A): A = {
|
||||
def withTestDB[A](action: (Session) => A): A = {
|
||||
util.FileUtil.withTmpDir(new File(FileUtils.getTempDirectory(), Random.alphanumeric.take(10).mkString)){ dir =>
|
||||
val (url, user, pass) = (s"jdbc:h2:${dir}", "sa", "sa")
|
||||
org.h2.Driver.load()
|
||||
using(DriverManager.getConnection(url, user, pass)){ conn =>
|
||||
servlet.AutoUpdate.versions.reverse.foreach(_.update(conn))
|
||||
}
|
||||
Database.forURL(url, user, pass).withSession {
|
||||
action
|
||||
Database.forURL(url, user, pass).withSession { session =>
|
||||
action(session)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.specs2.mock.Mockito
|
||||
import service.RequestCache
|
||||
import model.Account
|
||||
import service.SystemSettingsService.SystemSettings
|
||||
import twirl.api.Html
|
||||
import play.twirl.api.Html
|
||||
import javax.servlet.http.HttpServletRequest
|
||||
|
||||
class AvatarImageProviderSpec extends Specification with Mockito {
|
||||
|
||||
Reference in New Issue
Block a user