summaryrefslogtreecommitdiffstats
path: root/app/post_test.go
diff options
context:
space:
mode:
authorJesús Espino <jespinog@gmail.com>2018-02-09 16:31:01 +0100
committerMartin Kraft <mkraft@users.noreply.github.com>2018-02-09 10:31:01 -0500
commit0aa7ecd5e89f054ae927b246f2aec4bd6348d42b (patch)
tree1944001594c05731acfb998fc3840d2de456e511 /app/post_test.go
parent96ffde43dc5dccef7af106dc8200566ff16ba1dc (diff)
downloadchat-0aa7ecd5e89f054ae927b246f2aec4bd6348d42b.tar.gz
chat-0aa7ecd5e89f054ae927b246f2aec4bd6348d42b.tar.bz2
chat-0aa7ecd5e89f054ae927b246f2aec4bd6348d42b.zip
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
Diffstat (limited to 'app/post_test.go')
-rw-r--r--app/post_test.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/app/post_test.go b/app/post_test.go
index 3f3783265..049d3ff92 100644
--- a/app/post_test.go
+++ b/app/post_test.go
@@ -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.