[MM-18831] Trim whitespace of Display Name when channel is cre… (#12380)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
83bab2c125
Коммит
8c94f48991
@@ -223,6 +223,8 @@ func (a *App) RenameChannel(channel *model.Channel, newChannelName string, newDi
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) CreateChannel(channel *model.Channel, addMember bool) (*model.Channel, *model.AppError) {
|
func (a *App) CreateChannel(channel *model.Channel, addMember bool) (*model.Channel, *model.AppError) {
|
||||||
|
channel.DisplayName = strings.TrimSpace(channel.DisplayName)
|
||||||
|
|
||||||
sc, err := a.Srv.Store.Channel().Save(channel, *a.Config().TeamSettings.MaxChannelsPerTeam)
|
sc, err := a.Srv.Store.Channel().Save(channel, *a.Config().TeamSettings.MaxChannelsPerTeam)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -254,6 +254,14 @@ func TestCreateChannelPrivateCreatesChannelMemberHistoryRecord(t *testing.T) {
|
|||||||
assert.Equal(t, th.BasicUser.Id, histories[0].UserId)
|
assert.Equal(t, th.BasicUser.Id, histories[0].UserId)
|
||||||
assert.Equal(t, privateChannel.Id, histories[0].ChannelId)
|
assert.Equal(t, privateChannel.Id, histories[0].ChannelId)
|
||||||
}
|
}
|
||||||
|
func TestCreateChannelDisplayNameTrimsWhitespace(t *testing.T) {
|
||||||
|
th := Setup(t).InitBasic()
|
||||||
|
defer th.TearDown()
|
||||||
|
|
||||||
|
channel, err := th.App.CreateChannel(&model.Channel{DisplayName: " Public 1 ", Name: "public1", Type: model.CHANNEL_OPEN, TeamId: th.BasicTeam.Id}, false)
|
||||||
|
require.Nil(t, err)
|
||||||
|
require.Equal(t, channel.DisplayName, "Public 1")
|
||||||
|
}
|
||||||
|
|
||||||
func TestUpdateChannelPrivacy(t *testing.T) {
|
func TestUpdateChannelPrivacy(t *testing.T) {
|
||||||
th := Setup(t).InitBasic()
|
th := Setup(t).InitBasic()
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user