mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-07 22:15:51 +01:00
AccountService.updateGroup now handles group description
This commit is contained in:
@@ -334,7 +334,7 @@ trait AccountControllerBase extends AccountManagementControllerBase {
|
||||
}
|
||||
}.toList){ case (groupName, members) =>
|
||||
getAccountByUserName(groupName, true).map { account =>
|
||||
updateGroup(groupName, form.url, false)
|
||||
updateGroup(groupName, form.url, None, false)
|
||||
|
||||
// Update GROUP_MEMBER
|
||||
updateGroupMembers(form.groupName, members)
|
||||
|
||||
@@ -152,7 +152,7 @@ trait UserManagementControllerBase extends AccountManagementControllerBase {
|
||||
}
|
||||
}.toList){ case (groupName, members) =>
|
||||
getAccountByUserName(groupName, true).map { account =>
|
||||
updateGroup(groupName, form.url, form.isRemoved)
|
||||
updateGroup(groupName, form.url, None, form.isRemoved)
|
||||
|
||||
if(form.isRemoved){
|
||||
// Remove from GROUP_MEMBER
|
||||
|
||||
@@ -151,8 +151,12 @@ trait AccountService {
|
||||
isRemoved = false,
|
||||
groupDescription = description)
|
||||
|
||||
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)
|
||||
def updateGroup(groupName: String, url: Option[String],
|
||||
groupDescription: Option[String], removed: Boolean)
|
||||
(implicit s: Session): Unit =
|
||||
Accounts.filter(_.userName === groupName.bind)
|
||||
.map(t => (t.url.?, t.groupDescription.?, t.removed))
|
||||
.update(url, groupDescription, removed)
|
||||
|
||||
def updateGroupMembers(groupName: String, members: List[(String, Boolean)])(implicit s: Session): Unit = {
|
||||
GroupMembers.filter(_.groupName === groupName.bind).delete
|
||||
|
||||
@@ -85,5 +85,18 @@ class AccountServiceSpec extends Specification with ServiceSpecBase {
|
||||
}
|
||||
}
|
||||
}}
|
||||
|
||||
"updateGroup" should { withTestDB { implicit session =>
|
||||
"save description" in {
|
||||
AccountService.createGroup("a-group", None, None)
|
||||
|
||||
AccountService.updateGroup("a-group", None, Some("new description"), false)
|
||||
|
||||
val group = AccountService.getAccountByUserName("a-group")
|
||||
group must beSome.like {
|
||||
case account => account.groupDescription must beSome("new description")
|
||||
}
|
||||
}
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user