[MM-17741] when converting bot to a user set the correct email. (#11879)

* Send notifications when bot converted to user

* Revert notification sending from CLI.
If user is a bot, set email to CLI email, not the previous email because
previous email <botname>@localhost

* Add comment describing the additional if statement

* Rewording

* remove duplicate word

* Update Comment

* Add tests for bots.  In both cases of RequireEmailVerification settings,
the Email should be set to the value passed to the UpdateUser function
and the previous faked localhost email ignored
Этот коммит содержится в:
jfrerich
2019-08-16 09:37:22 -05:00
коммит произвёл Christopher Speller
родитель 7e7447eff7
Коммит baedcc856f
2 изменённых файлов: 38 добавлений и 1 удалений

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

@@ -393,6 +393,22 @@ func TestUpdateUserEmail(t *testing.T) {
assert.Nil(t, err)
assert.Equal(t, newEmail, user2.Email)
assert.True(t, user2.EmailVerified)
// Create bot user
botuser := model.User{
Email: "botuser@localhost",
Username: model.NewId(),
IsBot: true,
}
_, err = th.App.Srv.Store.User().Save(&botuser)
assert.Nil(t, err)
newBotEmail := th.MakeEmail()
botuser.Email = newBotEmail
botuser2, err := th.App.UpdateUser(&botuser, false)
assert.Nil(t, err)
assert.Equal(t, botuser2.Email, newBotEmail)
})
t.Run("RequireVerificationAlreadyUsedEmail", func(t *testing.T) {
@@ -420,6 +436,21 @@ func TestUpdateUserEmail(t *testing.T) {
user2, err := th.App.UpdateUser(user, false)
assert.Nil(t, err)
assert.Equal(t, newEmail, user2.Email)
// Create bot user
botuser := model.User{
Email: "botuser@localhost",
Username: model.NewId(),
IsBot: true,
}
_, err = th.App.Srv.Store.User().Save(&botuser)
assert.Nil(t, err)
newBotEmail := th.MakeEmail()
botuser.Email = newBotEmail
botuser2, err := th.App.UpdateUser(&botuser, false)
assert.Nil(t, err)
assert.Equal(t, botuser2.Email, newBotEmail)
})
}