summaryrefslogtreecommitdiffstats
path: root/app/webhook_test.go
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-08-03 18:25:47 -0500
committerChristopher Speller <crspeller@gmail.com>2017-08-03 16:25:47 -0700
commitdf1ff4ec977b76587dfc50885874f08fd9748071 (patch)
tree3481e612ca9b885509f8332ac1f84ee46d1e9756 /app/webhook_test.go
parentdc884983e625fb7a9309361de26b7dcbc0fd736a (diff)
downloadchat-df1ff4ec977b76587dfc50885874f08fd9748071.tar.gz
chat-df1ff4ec977b76587dfc50885874f08fd9748071.tar.bz2
chat-df1ff4ec977b76587dfc50885874f08fd9748071.zip
PLT-7212: fix missing webhook post attachments (#7011)
* fix missing webhook post attachments * make ProcessSlackAttachments return a new slice instead of modifying it
Diffstat (limited to 'app/webhook_test.go')
-rw-r--r--app/webhook_test.go47
1 files changed, 47 insertions, 0 deletions
diff --git a/app/webhook_test.go b/app/webhook_test.go
new file mode 100644
index 000000000..ae97454a6
--- /dev/null
+++ b/app/webhook_test.go
@@ -0,0 +1,47 @@
+// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package app
+
+import (
+ "testing"
+
+ "github.com/mattermost/platform/model"
+ "github.com/mattermost/platform/utils"
+)
+
+func TestCreateWebhookPost(t *testing.T) {
+ th := Setup().InitBasic()
+ defer TearDown()
+
+ enableIncomingHooks := utils.Cfg.ServiceSettings.EnableIncomingWebhooks
+ defer func() {
+ utils.Cfg.ServiceSettings.EnableIncomingWebhooks = enableIncomingHooks
+ utils.SetDefaultRolesBasedOnConfig()
+ }()
+ utils.Cfg.ServiceSettings.EnableIncomingWebhooks = true
+ utils.SetDefaultRolesBasedOnConfig()
+
+ hook, err := CreateIncomingWebhookForChannel(th.BasicUser.Id, th.BasicChannel, &model.IncomingWebhook{ChannelId: th.BasicChannel.Id})
+ if err != nil {
+ t.Fatal(err.Error())
+ }
+ defer DeleteIncomingWebhook(hook.Id)
+
+ post, err := CreateWebhookPost(hook.UserId, hook.TeamId, th.BasicChannel.Id, "foo", "user", "http://iconurl", model.StringInterface{
+ "attachments": []*model.SlackAttachment{
+ &model.SlackAttachment{
+ Text: "text",
+ },
+ },
+ }, model.POST_SLACK_ATTACHMENT)
+ if err != nil {
+ t.Fatal(err.Error())
+ }
+
+ for _, k := range []string{"from_webhook", "attachments"} {
+ if _, ok := post.Props[k]; !ok {
+ t.Fatal(k)
+ }
+ }
+}