From 2e34d8843e14093880f62a8c3e1075cb0f0bfc8e Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Thu, 20 Oct 2016 10:27:18 -0400 Subject: [PATCH] PLT-4138 Fix /join command for non-admin accounts (#4265) * Fix /join command for non-admin accounts * Implement found check in join command unit test properly --- api/command_join.go | 2 +- api/command_join_test.go | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/api/command_join.go b/api/command_join.go index dddba01351..b8c863425d 100644 --- a/api/command_join.go +++ b/api/command_join.go @@ -46,7 +46,7 @@ func (me *JoinProvider) DoCommand(c *Context, channelId string, message string) return &model.CommandResponse{Text: c.T("api.command_join.fail.app_error"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL} } - if err, _ := JoinChannelById(c, c.Session.UserId, channelId); err != nil { + if err, _ := JoinChannelById(c, c.Session.UserId, v.Id); err != nil { return &model.CommandResponse{Text: c.T("api.command_join.fail.app_error"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL} } diff --git a/api/command_join_test.go b/api/command_join_test.go index d586a522ac..6cf474c6be 100644 --- a/api/command_join_test.go +++ b/api/command_join_test.go @@ -41,7 +41,14 @@ func TestJoinCommands(t *testing.T) { c1 := Client.Must(Client.GetChannels("")).Data.(*model.ChannelList) - if len(c1.Channels) != 5 { - t.Fatal("didn't join channel") + found := false + for _, c := range c1.Channels { + if c.Id == channel2.Id { + found = true + } + } + + if !found { + t.Fatal("did not join channel") } }