[MM-41611] Only check for userId when saving userTermsOfService (#19587)
* Only check for userId when saving userTermsOfService * Add test Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
f2471200f9
Коммит
d6603b4bf8
@@ -55,7 +55,7 @@ func (s SqlUserTermsOfServiceStore) Save(userTermsOfService *model.UserTermsOfSe
|
||||
query := `
|
||||
UPDATE UserTermsOfService
|
||||
SET UserId = :UserId, TermsOfServiceId = :TermsOfServiceId, CreateAt = :CreateAt
|
||||
WHERE UserId = :UserId AND TermsOfServiceId = :TermsOfServiceId
|
||||
WHERE UserId = :UserId
|
||||
`
|
||||
result, err := s.GetMasterX().NamedExec(query, userTermsOfService)
|
||||
if err != nil {
|
||||
|
||||
@@ -31,6 +31,18 @@ func testSaveUserTermsOfService(t *testing.T, ss store.Store) {
|
||||
assert.Equal(t, userTermsOfService.UserId, savedUserTermsOfService.UserId)
|
||||
assert.Equal(t, userTermsOfService.TermsOfServiceId, savedUserTermsOfService.TermsOfServiceId)
|
||||
assert.NotEmpty(t, savedUserTermsOfService.CreateAt)
|
||||
|
||||
// Check we can save a new terms of service id (MM-41611)
|
||||
newUserTermsOfService := &model.UserTermsOfService{
|
||||
UserId: userTermsOfService.UserId,
|
||||
TermsOfServiceId: model.NewId(),
|
||||
}
|
||||
|
||||
savedUserTermsOfService, err = ss.UserTermsOfService().Save(newUserTermsOfService)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, newUserTermsOfService.UserId, savedUserTermsOfService.UserId)
|
||||
assert.Equal(t, newUserTermsOfService.TermsOfServiceId, savedUserTermsOfService.TermsOfServiceId)
|
||||
assert.NotEmpty(t, savedUserTermsOfService.CreateAt)
|
||||
}
|
||||
|
||||
func testGetByUserTermsOfService(t *testing.T, ss store.Store) {
|
||||
|
||||
Ссылка в новой задаче
Block a user