summaryrefslogtreecommitdiffstats
path: root/api4/channel_test.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-03-31 09:55:37 -0400
committerChristopher Speller <crspeller@gmail.com>2017-03-31 09:55:37 -0400
commit4e224c299697e570e98c388bf23a42ffa1e6af0d (patch)
tree5bc192c008347cce8d9b1f34888f2dbb694c8d51 /api4/channel_test.go
parentea17e8d004ca6a9501cb540c0009bb531eb9d0f2 (diff)
downloadchat-4e224c299697e570e98c388bf23a42ffa1e6af0d.tar.gz
chat-4e224c299697e570e98c388bf23a42ffa1e6af0d.tar.bz2
chat-4e224c299697e570e98c388bf23a42ffa1e6af0d.zip
Implement PUT /channels/{channel_id}/members/{user_id}/notify_props for APIv4 (#5901)
Diffstat (limited to 'api4/channel_test.go')
-rw-r--r--api4/channel_test.go50
1 files changed, 50 insertions, 0 deletions
diff --git a/api4/channel_test.go b/api4/channel_test.go
index 3cc1cb64f..1875f2c44 100644
--- a/api4/channel_test.go
+++ b/api4/channel_test.go
@@ -1440,6 +1440,56 @@ func TestUpdateChannelRoles(t *testing.T) {
CheckForbiddenStatus(t, resp)
}
+func TestUpdateChannelNotifyProps(t *testing.T) {
+ th := Setup().InitBasic().InitSystemAdmin()
+ defer TearDown()
+ Client := th.Client
+
+ props := map[string]string{}
+ props[model.DESKTOP_NOTIFY_PROP] = model.CHANNEL_NOTIFY_MENTION
+ props[model.MARK_UNREAD_NOTIFY_PROP] = model.CHANNEL_MARK_UNREAD_MENTION
+
+ pass, resp := Client.UpdateChannelNotifyProps(th.BasicChannel.Id, th.BasicUser.Id, props)
+ CheckNoError(t, resp)
+
+ if !pass {
+ t.Fatal("should have passed")
+ }
+
+ member, err := app.GetChannelMember(th.BasicChannel.Id, th.BasicUser.Id)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if member.NotifyProps[model.DESKTOP_NOTIFY_PROP] != model.CHANNEL_NOTIFY_MENTION {
+ t.Fatal("bad update")
+ } else if member.NotifyProps[model.MARK_UNREAD_NOTIFY_PROP] != model.CHANNEL_MARK_UNREAD_MENTION {
+ t.Fatal("bad update")
+ }
+
+ _, resp = Client.UpdateChannelNotifyProps("junk", th.BasicUser.Id, props)
+ CheckBadRequestStatus(t, resp)
+
+ _, resp = Client.UpdateChannelNotifyProps(th.BasicChannel.Id, "junk", props)
+ CheckBadRequestStatus(t, resp)
+
+ _, resp = Client.UpdateChannelNotifyProps(model.NewId(), th.BasicUser.Id, props)
+ CheckNotFoundStatus(t, resp)
+
+ _, resp = Client.UpdateChannelNotifyProps(th.BasicChannel.Id, model.NewId(), props)
+ CheckForbiddenStatus(t, resp)
+
+ _, resp = Client.UpdateChannelNotifyProps(th.BasicChannel.Id, th.BasicUser.Id, map[string]string{})
+ CheckNoError(t, resp)
+
+ Client.Logout()
+ _, resp = Client.UpdateChannelNotifyProps(th.BasicChannel.Id, th.BasicUser.Id, props)
+ CheckUnauthorizedStatus(t, resp)
+
+ _, resp = th.SystemAdminClient.UpdateChannelNotifyProps(th.BasicChannel.Id, th.BasicUser.Id, props)
+ CheckNoError(t, resp)
+}
+
func TestAddChannelMember(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
defer TearDown()