Fix notifications for public/private channels and add basic unit test (#4295)

Этот коммит содержится в:
Joram Wilander
2016-10-21 16:23:59 -04:00
коммит произвёл Christopher Speller
родитель 254cefee1a
Коммит 3885532750
2 изменённых файлов: 51 добавлений и 15 удалений

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

@@ -1273,3 +1273,41 @@ func TestGetFileInfosForPost(t *testing.T) {
t.Fatal("should've returned nothing because of etag")
}
}
// TODO: Needs to be vastly fleshed out
func TestSendNotifications(t *testing.T) {
th := Setup().InitBasic()
Client := th.BasicClient
AddUserToChannel(th.BasicUser2, th.BasicChannel)
mockSession := model.Session{
UserId: th.BasicUser.Id,
TeamMembers: []*model.TeamMember{{TeamId: th.BasicTeam.Id, UserId: th.BasicUser.Id}},
IsOAuth: false,
}
newContext := &Context{
Session: mockSession,
RequestId: model.NewId(),
IpAddress: "",
Path: "fake",
Err: nil,
siteURL: *utils.Cfg.ServiceSettings.SiteURL,
TeamId: th.BasicTeam.Id,
}
post1 := Client.Must(Client.CreatePost(&model.Post{
ChannelId: th.BasicChannel.Id,
Message: "@" + th.BasicUser2.Username,
})).Data.(*model.Post)
mentions := sendNotifications(newContext, post1, th.BasicTeam, th.BasicChannel)
if mentions == nil {
t.Log(mentions)
t.Fatal("user should have been mentioned")
} else if mentions[0] != th.BasicUser2.Id {
t.Log(mentions)
t.Fatal("user should have been mentioned")
}
}