PLT-2559 Always return successful when trying to join a channel that the user is already a member of (#3265)

* Added unit tests for SqlChannelStore.GetMember

* Fixed api routes for accessing channels by name when the name includes an underscore

* Changed join channel API to always return successful when the user is already a member of the channel
Этот коммит содержится в:
Harrison Healey
2016-06-06 13:03:56 -04:00
родитель 2c42294bbc
Коммит 384d0eb245
4 изменённых файлов: 97 добавлений и 4 удалений

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

@@ -462,11 +462,25 @@ func TestJoinChannelById(t *testing.T) {
user3 := th.CreateUser(th.BasicClient)
LinkUserToTeam(user3, team)
Client.Login(user3.Email, "pwd")
Client.Must(Client.Login(user3.Email, "Password1"))
if _, err := Client.JoinChannel(rchannel.Id); err == nil {
t.Fatal("shoudn't be able to join direct channel")
}
th.LoginBasic()
if _, err := Client.JoinChannel(channel1.Id); err != nil {
t.Fatal("should be able to join public channel that we're a member of")
}
if _, err := Client.JoinChannel(channel3.Id); err != nil {
t.Fatal("should be able to join private channel that we're a member of")
}
if _, err := Client.JoinChannel(rchannel.Id); err != nil {
t.Fatal("should be able to join direct channel that we're a member of")
}
}
func TestJoinChannelByName(t *testing.T) {
@@ -492,11 +506,25 @@ func TestJoinChannelByName(t *testing.T) {
user3 := th.CreateUser(th.BasicClient)
LinkUserToTeam(user3, team)
Client.Login(user3.Email, "pwd")
Client.Must(Client.Login(user3.Email, "Password1"))
if _, err := Client.JoinChannelByName(rchannel.Name); err == nil {
t.Fatal("shoudn't be able to join direct channel")
}
th.LoginBasic()
if _, err := Client.JoinChannelByName(channel1.Name); err != nil {
t.Fatal("should be able to join public channel that we're a member of")
}
if _, err := Client.JoinChannelByName(channel3.Name); err != nil {
t.Fatal("should be able to join private channel that we're a member of")
}
if _, err := Client.JoinChannelByName(rchannel.Name); err != nil {
t.Fatal("should be able to join direct channel that we're a member of")
}
}
func TestLeaveChannel(t *testing.T) {