mirror of
https://github.com/balzack/databag.git
synced 2025-02-11 19:19:16 +00:00
remove card-group from join table on group remove
This commit is contained in:
parent
8e903dc1c1
commit
d53399e306
@ -29,6 +29,9 @@ func RemoveGroup(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
err = store.DB.Transaction(func(tx *gorm.DB) error {
|
||||
if res := tx.Model(slot.Group).Association("Cards").Clear(); res != nil {
|
||||
return res
|
||||
}
|
||||
if res := tx.Delete(&slot.Group.GroupData).Error; res != nil {
|
||||
return res
|
||||
}
|
||||
|
@ -15,15 +15,15 @@ func TestUpdateContact(t *testing.T) {
|
||||
var cards []Card
|
||||
var detail int64
|
||||
var profile int64
|
||||
var cardProfile *CardProfile
|
||||
var cardDetail *CardDetail
|
||||
var cardProfile *CardProfile
|
||||
|
||||
// setup testing group
|
||||
set, err = AddTestGroup("addaccount")
|
||||
set, err = AddTestGroup("updatecontact")
|
||||
assert.NoError(t, err)
|
||||
|
||||
// setup testing group
|
||||
_, err = AddTestGroup("addaccount")
|
||||
_, err = AddTestGroup("updatecontact")
|
||||
assert.Error(t, err)
|
||||
|
||||
rev = GetTestRevision(set.B.Revisions)
|
||||
|
Loading…
Reference in New Issue
Block a user