Fix role unarchiving caused by updatng wrong vars

This commit is contained in:
Tomaž Jerman
2022-09-13 10:09:18 +02:00
parent 70d9bbb512
commit d65bd241b7
2 changed files with 8 additions and 3 deletions
+1 -1
View File
@@ -595,7 +595,7 @@ func (svc role) Unarchive(ctx context.Context, roleID uint64) (err error) {
return RoleErrNotAllowedToUndelete()
}
r.ArchivedAt = nil
upd.ArchivedAt = nil
if err = store.UpdateRole(ctx, svc.store, upd); err != nil {
return
}
+7 -2
View File
@@ -13,7 +13,7 @@ import (
"github.com/cortezaproject/corteza-server/system/service"
"github.com/cortezaproject/corteza-server/system/types"
"github.com/cortezaproject/corteza-server/tests/helpers"
"github.com/steinfletcher/apitest-jsonpath"
jsonpath "github.com/steinfletcher/apitest-jsonpath"
"github.com/stretchr/testify/require"
)
@@ -375,7 +375,12 @@ func TestRoleUnarchive(t *testing.T) {
h := newHelper(t)
helpers.AllowMe(h, types.RoleRbacResource(0), "delete")
res := h.repoMakeRole()
n := time.Now()
res := h.createRole(&types.Role{
Name: "test_role",
Handle: "test_role",
ArchivedAt: &n,
})
h.apiInit().
Post(fmt.Sprintf("/roles/%d/unarchive", res.ID)).