mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-08 22:45:51 +01:00
AccountService.createGroup now handles group description
This commit is contained in:
@@ -296,7 +296,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
post("/groups/new", newGroupForm)(usersOnly { form =>
|
post("/groups/new", newGroupForm)(usersOnly { form =>
|
||||||
createGroup(form.groupName, form.url)
|
createGroup(form.groupName, form.url, None)
|
||||||
updateGroupMembers(form.groupName, form.members.split(",").map {
|
updateGroupMembers(form.groupName, form.members.split(",").map {
|
||||||
_.split(":") match {
|
_.split(":") match {
|
||||||
case Array(userName, isManager) => (userName, isManager.toBoolean)
|
case Array(userName, isManager) => (userName, isManager.toBoolean)
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ trait UserManagementControllerBase extends AccountManagementControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
post("/admin/users/_newgroup", newGroupForm)(adminOnly { form =>
|
post("/admin/users/_newgroup", newGroupForm)(adminOnly { form =>
|
||||||
createGroup(form.groupName, form.url)
|
createGroup(form.groupName, form.url, None)
|
||||||
updateGroupMembers(form.groupName, form.members.split(",").map {
|
updateGroupMembers(form.groupName, form.members.split(",").map {
|
||||||
_.split(":") match {
|
_.split(":") match {
|
||||||
case Array(userName, isManager) => (userName, isManager.toBoolean)
|
case Array(userName, isManager) => (userName, isManager.toBoolean)
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ trait AccountService {
|
|||||||
def updateLastLoginDate(userName: String)(implicit s: Session): Unit =
|
def updateLastLoginDate(userName: String)(implicit s: Session): Unit =
|
||||||
Accounts.filter(_.userName === userName.bind).map(_.lastLoginDate).update(currentDate)
|
Accounts.filter(_.userName === userName.bind).map(_.lastLoginDate).update(currentDate)
|
||||||
|
|
||||||
def createGroup(groupName: String, url: Option[String])(implicit s: Session): Unit =
|
def createGroup(groupName: String, url: Option[String], description: Option[String])(implicit s: Session): Unit =
|
||||||
Accounts insert Account(
|
Accounts insert Account(
|
||||||
userName = groupName,
|
userName = groupName,
|
||||||
password = "",
|
password = "",
|
||||||
@@ -149,7 +149,7 @@ trait AccountService {
|
|||||||
image = None,
|
image = None,
|
||||||
isGroupAccount = true,
|
isGroupAccount = true,
|
||||||
isRemoved = false,
|
isRemoved = false,
|
||||||
groupDescription = None)
|
groupDescription = description)
|
||||||
|
|
||||||
def updateGroup(groupName: String, url: Option[String], removed: Boolean)(implicit s: Session): Unit =
|
def updateGroup(groupName: String, url: Option[String], removed: Boolean)(implicit s: Session): Unit =
|
||||||
Accounts.filter(_.userName === groupName.bind).map(t => t.url.? -> t.removed).update(url, removed)
|
Accounts.filter(_.userName === groupName.bind).map(t => t.url.? -> t.removed).update(url, removed)
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class AccountServiceSpec extends Specification with ServiceSpecBase {
|
|||||||
"group" in { withTestDB { implicit session =>
|
"group" in { withTestDB { implicit session =>
|
||||||
val group1 = "group1"
|
val group1 = "group1"
|
||||||
val user1 = "root"
|
val user1 = "root"
|
||||||
AccountService.createGroup(group1, None)
|
AccountService.createGroup(group1, None, None)
|
||||||
|
|
||||||
AccountService.getGroupMembers(group1) must_== Nil
|
AccountService.getGroupMembers(group1) must_== Nil
|
||||||
AccountService.getGroupsByUserName(user1) must_== Nil
|
AccountService.getGroupsByUserName(user1) must_== Nil
|
||||||
@@ -74,6 +74,16 @@ class AccountServiceSpec extends Specification with ServiceSpecBase {
|
|||||||
AccountService.getGroupMembers(group1) must_== Nil
|
AccountService.getGroupMembers(group1) must_== Nil
|
||||||
AccountService.getGroupsByUserName(user1) must_== Nil
|
AccountService.getGroupsByUserName(user1) must_== Nil
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
"createGroup" should { withTestDB { implicit session =>
|
||||||
|
"save description" in {
|
||||||
|
AccountService.createGroup("some-group", None, Some("some clever description"))
|
||||||
|
val maybeGroup = AccountService.getAccountByUserName("some-group")
|
||||||
|
|
||||||
|
maybeGroup must beSome.like {
|
||||||
|
case account => account.groupDescription must beSome("some clever description")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user