summaryrefslogtreecommitdiffstats
path: root/models/action_test.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2022-03-13 17:40:47 +0100
committerGitHub <noreply@github.com>2022-03-13 17:40:47 +0100
commitbc0d2c8ada14eae81542f30a81552ed5cef8bd5d (patch)
tree5242a9e288f53cfc04e56df495a048d02a902d91 /models/action_test.go
parent780cf76f6e930b5e92fd12ae1e729c5702e70afa (diff)
downloadgitea-bc0d2c8ada14eae81542f30a81552ed5cef8bd5d.tar.gz
gitea-bc0d2c8ada14eae81542f30a81552ed5cef8bd5d.zip
RSS/Atom support for Repos (#19055)
* support for repos * refactor * advertise the feeds via meta tags * allow feed suffix and feed header * optimize performance
Diffstat (limited to 'models/action_test.go')
-rw-r--r--models/action_test.go50
1 files changed, 46 insertions, 4 deletions
diff --git a/models/action_test.go b/models/action_test.go
index 0ce9183b96..e247a5ec29 100644
--- a/models/action_test.go
+++ b/models/action_test.go
@@ -8,6 +8,7 @@ import (
"path"
"testing"
+ "code.gitea.io/gitea/models/db"
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unittest"
user_model "code.gitea.io/gitea/models/user"
@@ -39,7 +40,7 @@ func TestGetFeeds(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User)
- actions, err := GetFeeds(GetFeedsOptions{
+ actions, err := GetFeeds(db.DefaultContext, GetFeedsOptions{
RequestedUser: user,
Actor: user,
IncludePrivate: true,
@@ -52,7 +53,7 @@ func TestGetFeeds(t *testing.T) {
assert.EqualValues(t, user.ID, actions[0].UserID)
}
- actions, err = GetFeeds(GetFeedsOptions{
+ actions, err = GetFeeds(db.DefaultContext, GetFeedsOptions{
RequestedUser: user,
Actor: user,
IncludePrivate: false,
@@ -62,13 +63,54 @@ func TestGetFeeds(t *testing.T) {
assert.Len(t, actions, 0)
}
+func TestGetFeedsForRepos(t *testing.T) {
+ assert.NoError(t, unittest.PrepareTestDatabase())
+ user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User)
+ privRepo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 2}).(*repo_model.Repository)
+ pubRepo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 8}).(*repo_model.Repository)
+
+ // private repo & no login
+ actions, err := GetFeeds(db.DefaultContext, GetFeedsOptions{
+ RequestedRepo: privRepo,
+ IncludePrivate: true,
+ })
+ assert.NoError(t, err)
+ assert.Len(t, actions, 0)
+
+ // public repo & no login
+ actions, err = GetFeeds(db.DefaultContext, GetFeedsOptions{
+ RequestedRepo: pubRepo,
+ IncludePrivate: true,
+ })
+ assert.NoError(t, err)
+ assert.Len(t, actions, 1)
+
+ // private repo and login
+ actions, err = GetFeeds(db.DefaultContext, GetFeedsOptions{
+ RequestedRepo: privRepo,
+ IncludePrivate: true,
+ Actor: user,
+ })
+ assert.NoError(t, err)
+ assert.Len(t, actions, 1)
+
+ // public repo & login
+ actions, err = GetFeeds(db.DefaultContext, GetFeedsOptions{
+ RequestedRepo: pubRepo,
+ IncludePrivate: true,
+ Actor: user,
+ })
+ assert.NoError(t, err)
+ assert.Len(t, actions, 1)
+}
+
func TestGetFeeds2(t *testing.T) {
// test with an organization user
assert.NoError(t, unittest.PrepareTestDatabase())
org := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 3}).(*user_model.User)
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User)
- actions, err := GetFeeds(GetFeedsOptions{
+ actions, err := GetFeeds(db.DefaultContext, GetFeedsOptions{
RequestedUser: org,
Actor: user,
IncludePrivate: true,
@@ -82,7 +124,7 @@ func TestGetFeeds2(t *testing.T) {
assert.EqualValues(t, org.ID, actions[0].UserID)
}
- actions, err = GetFeeds(GetFeedsOptions{
+ actions, err = GetFeeds(db.DefaultContext, GetFeedsOptions{
RequestedUser: org,
Actor: user,
IncludePrivate: false,