Этот коммит содержится в:
Chris
2017-06-26 09:36:47 -07:00
коммит произвёл Christopher Speller
родитель e285839ee1
Коммит 14467ee134
4 изменённых файлов: 56 добавлений и 3 удалений

Просмотреть файл

@@ -10,7 +10,8 @@ import (
"github.com/mattermost/platform/model"
)
func TestJoinCommands(t *testing.T) {
// also used to test /open (see command_open_test.go)
func testJoinCommands(t *testing.T, alias string) {
th := Setup().InitBasic()
Client := th.BasicClient
team := th.BasicTeam
@@ -29,12 +30,12 @@ func TestJoinCommands(t *testing.T) {
channel3 := Client.Must(Client.CreateDirectChannel(user2.Id)).Data.(*model.Channel)
rs5 := Client.Must(Client.Command(channel0.Id, "/join "+channel2.Name)).Data.(*model.CommandResponse)
rs5 := Client.Must(Client.Command(channel0.Id, "/"+alias+" "+channel2.Name)).Data.(*model.CommandResponse)
if !strings.HasSuffix(rs5.GotoLocation, "/"+team.Name+"/channels/"+channel2.Name) {
t.Fatal("failed to join channel")
}
rs6 := Client.Must(Client.Command(channel0.Id, "/join "+channel3.Name)).Data.(*model.CommandResponse)
rs6 := Client.Must(Client.Command(channel0.Id, "/"+alias+" "+channel3.Name)).Data.(*model.CommandResponse)
if strings.HasSuffix(rs6.GotoLocation, "/"+team.Name+"/channels/"+channel3.Name) {
t.Fatal("should not have joined direct message channel")
}
@@ -52,3 +53,7 @@ func TestJoinCommands(t *testing.T) {
t.Fatal("did not join channel")
}
}
func TestJoinCommands(t *testing.T) {
testJoinCommands(t, "join")
}

12
api/command_open_test.go Обычный файл
Просмотреть файл

@@ -0,0 +1,12 @@
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package api
import (
"testing"
)
func TestOpenCommands(t *testing.T) {
testJoinCommands(t, "open")
}

32
app/command_open.go Обычный файл
Просмотреть файл

@@ -0,0 +1,32 @@
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package app
import (
"github.com/mattermost/platform/model"
goi18n "github.com/nicksnyder/go-i18n/i18n"
)
type OpenProvider struct {
JoinProvider
}
const (
CMD_OPEN = "open"
)
func init() {
RegisterCommandProvider(&OpenProvider{})
}
func (open *OpenProvider) GetTrigger() string {
return CMD_OPEN
}
func (open *OpenProvider) GetCommand(T goi18n.TranslateFunc) *model.Command {
cmd := open.JoinProvider.GetCommand(T)
cmd.Trigger = CMD_OPEN
cmd.DisplayName = T("api.command_open.name")
return cmd
}

Просмотреть файл

@@ -671,6 +671,10 @@
"id": "api.command_settings.unsupported.app_error",
"translation": "The settings command is not supported on your device"
},
{
"id": "api.command_open.name",
"translation": "open"
},
{
"id": "api.command_shortcuts.browser.channel_next",
"translation": "{{.ChannelNextCmd}}: Next channel in your history\n"