diff options
author | cpanato <ctadeu@gmail.com> | 2018-07-10 19:27:14 +0200 |
---|---|---|
committer | cpanato <ctadeu@gmail.com> | 2018-07-10 19:27:14 +0200 |
commit | c042ffa460296587579aff54b157a5109e022f7e (patch) | |
tree | 9e7f77fbc83b6d06204db099066be8999dbb22d9 /app/command_msg_test.go | |
parent | 9470564d355c201155f6fcb123152b8ac954f812 (diff) | |
parent | dccd95bc67779a5b83a2660aec0cf4622cd56550 (diff) | |
download | chat-c042ffa460296587579aff54b157a5109e022f7e.tar.gz chat-c042ffa460296587579aff54b157a5109e022f7e.tar.bz2 chat-c042ffa460296587579aff54b157a5109e022f7e.zip |
Merge remote-tracking branch 'upstream/release-5.1' into release-5.1-daily-merge-20180710
Diffstat (limited to 'app/command_msg_test.go')
-rw-r--r-- | app/command_msg_test.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/app/command_msg_test.go b/app/command_msg_test.go index 22c4d07cf..9a8ca8eb0 100644 --- a/app/command_msg_test.go +++ b/app/command_msg_test.go @@ -19,13 +19,47 @@ func TestMsgProvider(t *testing.T) { team := th.CreateTeam() th.LinkUserToTeam(th.BasicUser, team) cmd := &msgProvider{} + + // Check without permission to create a DM channel. resp := cmd.DoCommand(th.App, &model.CommandArgs{ T: i18n.IdentityTfunc(), SiteURL: "http://test.url", TeamId: team.Id, UserId: th.BasicUser.Id, + Session: model.Session{ + Roles: "", + }, }, "@"+th.BasicUser2.Username+" hello") + channelName := model.GetDMNameFromIds(th.BasicUser.Id, th.BasicUser2.Id) + assert.Equal(t, "api.command_msg.permission.app_error", resp.Text) + assert.Equal(t, "", resp.GotoLocation) + + // Check with permission to create a DM channel. + resp = cmd.DoCommand(th.App, &model.CommandArgs{ + T: i18n.IdentityTfunc(), + SiteURL: "http://test.url", + TeamId: team.Id, + UserId: th.BasicUser.Id, + Session: model.Session{ + Roles: model.SYSTEM_USER_ROLE_ID, + }, + }, "@"+th.BasicUser2.Username+" hello") + + assert.Equal(t, "", resp.Text) + assert.Equal(t, "http://test.url/"+team.Name+"/channels/"+channelName, resp.GotoLocation) + + // Check without permission to post to an existing DM channel. + resp = cmd.DoCommand(th.App, &model.CommandArgs{ + T: i18n.IdentityTfunc(), + SiteURL: "http://test.url", + TeamId: team.Id, + UserId: th.BasicUser.Id, + Session: model.Session{ + Roles: "", + }, + }, "@"+th.BasicUser2.Username+" hello") + assert.Equal(t, "", resp.Text) assert.Equal(t, "http://test.url/"+team.Name+"/channels/"+channelName, resp.GotoLocation) } |