summaryrefslogtreecommitdiffstats
path: root/app/post_test.go
diff options
context:
space:
mode:
authorGeorge Goldberg <george@gberg.me>2018-03-27 22:36:55 +0100
committerGeorge Goldberg <george@gberg.me>2018-03-27 22:36:55 +0100
commit71c9dff7662868770f66ab876ad66b354133c2c1 (patch)
treee2d5d8c5ad203b42af868ee18399c42a9ab08385 /app/post_test.go
parent2af4c7e6496d4c5192fedf5001817f6f1eb3664b (diff)
parente13e64711f7a7e8ceadb8cbc6af72c4022c95b36 (diff)
downloadchat-71c9dff7662868770f66ab876ad66b354133c2c1.tar.gz
chat-71c9dff7662868770f66ab876ad66b354133c2c1.tar.bz2
chat-71c9dff7662868770f66ab876ad66b354133c2c1.zip
Merge branch 'advanced-permissions-phase-1'
Diffstat (limited to 'app/post_test.go')
-rw-r--r--app/post_test.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/app/post_test.go b/app/post_test.go
index 8455656d7..10b957751 100644
--- a/app/post_test.go
+++ b/app/post_test.go
@@ -48,6 +48,43 @@ func TestUpdatePostEditAt(t *testing.T) {
}
}
+func TestUpdatePostTimeLimit(t *testing.T) {
+ th := Setup().InitBasic()
+ defer th.TearDown()
+
+ post := &model.Post{}
+ *post = *th.BasicPost
+
+ th.App.SetLicense(model.NewTestLicense())
+
+ 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.