AllowEditPost and PostEditTimeLimit migration (#8208)
* AllowEditPost and PostEditTimeLimit migration * Not set EDIT_POST permission to sysadmin_role if ALLOW_EDIT_POST is configured to NEVER * Remove a bit of code duplication
Этот коммит содержится в:
коммит произвёл
Martin Kraft
родитель
96ffde43dc
Коммит
0aa7ecd5e8
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
"github.com/mattermost/mattermost-server/utils"
|
||||
)
|
||||
|
||||
func TestUpdatePostEditAt(t *testing.T) {
|
||||
@@ -43,6 +44,51 @@ func TestUpdatePostEditAt(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpdatePostTimeLimit(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
post := &model.Post{}
|
||||
*post = *th.BasicPost
|
||||
|
||||
isLicensed := utils.IsLicensed()
|
||||
license := utils.License()
|
||||
defer func() {
|
||||
utils.SetIsLicensed(isLicensed)
|
||||
utils.SetLicense(license)
|
||||
}()
|
||||
utils.SetIsLicensed(true)
|
||||
utils.SetLicense(&model.License{Features: &model.Features{}})
|
||||
utils.License().Features.SetDefaults()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.PostEditTimeLimit = -1
|
||||
})
|
||||
if _, err := th.App.UpdatePost(post, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.PostEditTimeLimit = 1000000000
|
||||
})
|
||||
post.Message = model.NewId()
|
||||
if _, err := th.App.UpdatePost(post, true); err != nil {
|
||||
t.Fatal("should allow you to edit the post")
|
||||
}
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.PostEditTimeLimit = 1
|
||||
})
|
||||
post.Message = model.NewId()
|
||||
if _, err := th.App.UpdatePost(post, true); err == nil {
|
||||
t.Fatal("should fail on update old post")
|
||||
}
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.PostEditTimeLimit = -1
|
||||
})
|
||||
}
|
||||
|
||||
func TestPostReplyToPostWhereRootPosterLeftChannel(t *testing.T) {
|
||||
// This test ensures that when replying to a root post made by a user who has since left the channel, the reply
|
||||
// post completes successfully. This is a regression test for PLT-6523.
|
||||
|
||||
Ссылка в новой задаче
Block a user