-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move some actions to notification/action (#8779)
* Move some actions to notification/action * Fix test * fix test
- Loading branch information
1 parent
fb459f2
commit 016a5d0
Showing
10 changed files
with
88 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2019 The Gitea Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package action | ||
|
||
import ( | ||
"path/filepath" | ||
"strings" | ||
"testing" | ||
|
||
"code.gitea.io/gitea/models" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestMain(m *testing.M) { | ||
models.MainTest(m, filepath.Join("..", "..", "..")) | ||
} | ||
|
||
func TestRenameRepoAction(t *testing.T) { | ||
assert.NoError(t, models.PrepareTestDatabase()) | ||
|
||
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User) | ||
repo := models.AssertExistsAndLoadBean(t, &models.Repository{OwnerID: user.ID}).(*models.Repository) | ||
repo.Owner = user | ||
|
||
oldRepoName := repo.Name | ||
const newRepoName = "newRepoName" | ||
repo.Name = newRepoName | ||
repo.LowerName = strings.ToLower(newRepoName) | ||
|
||
actionBean := &models.Action{ | ||
OpType: models.ActionRenameRepo, | ||
ActUserID: user.ID, | ||
ActUser: user, | ||
RepoID: repo.ID, | ||
Repo: repo, | ||
IsPrivate: repo.IsPrivate, | ||
Content: oldRepoName, | ||
} | ||
models.AssertNotExistsBean(t, actionBean) | ||
|
||
NewNotifier().NotifyRenameRepository(user, repo, oldRepoName) | ||
|
||
models.AssertExistsAndLoadBean(t, actionBean) | ||
models.CheckConsistencyFor(t, &models.Action{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters