diff options
author | Corey Hulen <corey@hulen.com> | 2015-12-11 06:40:37 -0800 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2015-12-11 06:40:37 -0800 |
commit | 412b45431ac913d13fb211b693e177bc92a09ecf (patch) | |
tree | 74f7e329090541f18ab30c7bf62d21987be92629 /api/post_test.go | |
parent | 607a8151de502bf45de131ef3632c741ad452333 (diff) | |
parent | c55e7895d91c9d4cd31c7cefe81319d64d7fed16 (diff) | |
download | chat-412b45431ac913d13fb211b693e177bc92a09ecf.tar.gz chat-412b45431ac913d13fb211b693e177bc92a09ecf.tar.bz2 chat-412b45431ac913d13fb211b693e177bc92a09ecf.zip |
Merge pull request #1652 from hmhealey/plt1319
PLT-1319 Fixed direct channels not being visible when no actual channel exists
Diffstat (limited to 'api/post_test.go')
-rw-r--r-- | api/post_test.go | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/api/post_test.go b/api/post_test.go index 0cb437e88..8e09ca76d 100644 --- a/api/post_test.go +++ b/api/post_test.go @@ -805,3 +805,51 @@ func TestFuzzyPosts(t *testing.T) { } } } + +func TestMakeDirectChannelVisible(t *testing.T) { + Setup() + + team := &model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN} + team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team) + + user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User) + store.Must(Srv.Store.User().VerifyEmail(user1.Id)) + + user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey@test.com", Nickname: "Corey Hulen", Password: "pwd"} + user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User) + store.Must(Srv.Store.User().VerifyEmail(user2.Id)) + + // user2 will be created with prefs created to show user1 in the sidebar so set that to false to get rid of it + Client.LoginByEmail(team.Name, user2.Email, "pwd") + + preferences := &model.Preferences{ + { + UserId: user2.Id, + Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNEL_SHOW, + Name: user1.Id, + Value: "false", + }, + } + Client.Must(Client.SetPreferences(preferences)) + + Client.LoginByEmail(team.Name, user1.Email, "pwd") + + channel := Client.Must(Client.CreateDirectChannel(map[string]string{"user_id": user2.Id})).Data.(*model.Channel) + + makeDirectChannelVisible(team.Id, channel.Id) + + if result, err := Client.GetPreference(model.PREFERENCE_CATEGORY_DIRECT_CHANNEL_SHOW, user2.Id); err != nil { + t.Fatal("Errored trying to set direct channel to be visible for user1") + } else if pref := result.Data.(*model.Preference); pref.Value != "true" { + t.Fatal("Failed to set direct channel to be visible for user1") + } + + Client.LoginByEmail(team.Name, user2.Email, "pwd") + + if result, err := Client.GetPreference(model.PREFERENCE_CATEGORY_DIRECT_CHANNEL_SHOW, user1.Id); err != nil { + t.Fatal("Errored trying to set direct channel to be visible for user2") + } else if pref := result.Data.(*model.Preference); pref.Value != "true" { + t.Fatal("Failed to set direct channel to be visible for user2") + } +} |