summaryrefslogtreecommitdiffstats
path: root/models/repo_watch_test.go
diff options
context:
space:
mode:
authorDavid Schneiderbauer <daviian@users.noreply.github.com>2017-09-16 02:18:25 +0200
committerLunny Xiao <xiaolunwen@gmail.com>2017-09-16 08:18:25 +0800
commitd766d0c4e064bf7f66098123f39d15c2dc67e415 (patch)
tree274eebecadd724502dd5c82e95f2f6f4cc4d6d34 /models/repo_watch_test.go
parentb496e3e1cc70829e5a6f78f3dff28277993f8406 (diff)
downloadgitea-d766d0c4e064bf7f66098123f39d15c2dc67e415.tar.gz
gitea-d766d0c4e064bf7f66098123f39d15c2dc67e415.zip
Prevent sending emails and notifications to inactive users (#2384)
* Filter inactive users before sending emails or creating browser notifications Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com> * fix formatting issues Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com> * included requested changes Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com> * optimized database queries * rebasing new master and add tablenames for clarification in xorm queries * remove escaped quotationmarks using backticks Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com>
Diffstat (limited to 'models/repo_watch_test.go')
-rw-r--r--models/repo_watch_test.go14
1 files changed, 5 insertions, 9 deletions
diff --git a/models/repo_watch_test.go b/models/repo_watch_test.go
index a1543566c1..1277b156c5 100644
--- a/models/repo_watch_test.go
+++ b/models/repo_watch_test.go
@@ -40,7 +40,8 @@ func TestGetWatchers(t *testing.T) {
repo := AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
watches, err := GetWatchers(repo.ID)
assert.NoError(t, err)
- assert.Len(t, watches, repo.NumWatches)
+ // Two watchers are inactive, thus minus 2
+ assert.Len(t, watches, repo.NumWatches-2)
for _, watch := range watches {
assert.EqualValues(t, repo.ID, watch.RepoID)
}
@@ -77,21 +78,16 @@ func TestNotifyWatchers(t *testing.T) {
}
assert.NoError(t, NotifyWatchers(action))
+ // Two watchers are inactive, thus action is only created for user 8, 10
AssertExistsAndLoadBean(t, &Action{
ActUserID: action.ActUserID,
- UserID: 1,
- RepoID: action.RepoID,
- OpType: action.OpType,
- })
- AssertExistsAndLoadBean(t, &Action{
- ActUserID: action.ActUserID,
- UserID: 4,
+ UserID: 8,
RepoID: action.RepoID,
OpType: action.OpType,
})
AssertExistsAndLoadBean(t, &Action{
ActUserID: action.ActUserID,
- UserID: 8,
+ UserID: 10,
RepoID: action.RepoID,
OpType: action.OpType,
})