summaryrefslogtreecommitdiffstats
path: root/app/command_invite_people_test.go
diff options
context:
space:
mode:
authorcpanato <ctadeu@gmail.com>2018-07-10 19:27:14 +0200
committercpanato <ctadeu@gmail.com>2018-07-10 19:27:14 +0200
commitc042ffa460296587579aff54b157a5109e022f7e (patch)
tree9e7f77fbc83b6d06204db099066be8999dbb22d9 /app/command_invite_people_test.go
parent9470564d355c201155f6fcb123152b8ac954f812 (diff)
parentdccd95bc67779a5b83a2660aec0cf4622cd56550 (diff)
downloadchat-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_invite_people_test.go')
-rw-r--r--app/command_invite_people_test.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/app/command_invite_people_test.go b/app/command_invite_people_test.go
new file mode 100644
index 000000000..5cf7aa412
--- /dev/null
+++ b/app/command_invite_people_test.go
@@ -0,0 +1,42 @@
+// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package app
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/mattermost/mattermost-server/model"
+)
+
+func TestInvitePeopleProvider(t *testing.T) {
+ th := Setup().InitBasic()
+ defer th.TearDown()
+
+ enableEmailInvitations := *th.App.Config().ServiceSettings.EnableEmailInvitations
+ defer func() {
+ th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableEmailInvitations = &enableEmailInvitations })
+ }()
+ th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableEmailInvitations = true })
+
+ cmd := InvitePeopleProvider{}
+
+ // Test without required permissions
+ args := &model.CommandArgs{
+ T: func(s string, args ...interface{}) string { return s },
+ ChannelId: th.BasicChannel.Id,
+ TeamId: th.BasicTeam.Id,
+ UserId: th.BasicUser.Id,
+ Session: model.Session{UserId: th.BasicUser.Id, TeamMembers: []*model.TeamMember{{TeamId: th.BasicTeam.Id, Roles: ""}}},
+ }
+
+ actual := cmd.DoCommand(th.App, args, model.NewId()+"@simulator.amazonses.com")
+ assert.Equal(t, "api.command_invite_people.permission.app_error", actual.Text)
+
+ // Test with required permissions.
+ args.Session.TeamMembers[0].Roles = model.TEAM_USER_ROLE_ID
+ actual = cmd.DoCommand(th.App, args, model.NewId()+"@simulator.amazonses.com")
+ assert.Equal(t, "api.command.invite_people.sent", actual.Text)
+}