Skip to content

Commit 44ede67

Browse files
committed
tests ...
1 parent 5d9fd10 commit 44ede67

File tree

3 files changed

+43
-13
lines changed

3 files changed

+43
-13
lines changed

models/action_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,38 @@ func TestGetFeeds(t *testing.T) {
6363
assert.Len(t, actions, 0)
6464
}
6565

66+
func TestGetFeedsForRepos(t *testing.T) {
67+
assert.NoError(t, unittest.PrepareTestDatabase())
68+
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User)
69+
privRepo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 2}).(*repo_model.Repository)
70+
pubRepo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 8}).(*repo_model.Repository)
71+
72+
// private repo & no login
73+
actions, err := GetFeeds(db.DefaultContext, GetFeedsOptions{
74+
RequestedRepo: privRepo,
75+
IncludePrivate: true,
76+
})
77+
assert.NoError(t, err)
78+
assert.Len(t, actions, 0)
79+
80+
// public repo & no login
81+
actions, err = GetFeeds(db.DefaultContext, GetFeedsOptions{
82+
RequestedRepo: pubRepo,
83+
IncludePrivate: true,
84+
})
85+
assert.NoError(t, err)
86+
assert.Len(t, actions, 1)
87+
88+
// private repo and login
89+
actions, err = GetFeeds(db.DefaultContext, GetFeedsOptions{
90+
RequestedRepo: privRepo,
91+
IncludePrivate: true,
92+
Actor: user,
93+
})
94+
assert.NoError(t, err)
95+
assert.Len(t, actions, 1)
96+
}
97+
6698
func TestGetFeeds2(t *testing.T) {
6799
// test with an organization user
68100
assert.NoError(t, unittest.PrepareTestDatabase())

models/fixtures/action.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
user_id: 2
44
op_type: 12 # close issue
55
act_user_id: 2
6-
repo_id: 2
6+
repo_id: 2 # private
77
is_private: true
88
created_unix: 1603228283
99

@@ -12,7 +12,7 @@
1212
user_id: 3
1313
op_type: 2 # rename repo
1414
act_user_id: 2
15-
repo_id: 3
15+
repo_id: 3 # private
1616
is_private: true
1717
content: oldRepoName
1818

@@ -21,38 +21,38 @@
2121
user_id: 11
2222
op_type: 1 # create repo
2323
act_user_id: 11
24-
repo_id: 9
24+
repo_id: 9 # public
2525
is_private: false
2626

2727
-
2828
id: 4
2929
user_id: 16
3030
op_type: 12 # close issue
3131
act_user_id: 16
32-
repo_id: 22
32+
repo_id: 22 # private
3333
is_private: true
3434
created_unix: 1603267920
3535

3636
- id: 5
3737
user_id: 10
3838
op_type: 1 # create repo
3939
act_user_id: 10
40-
repo_id: 6
40+
repo_id: 6 # private
4141
is_private: true
4242
created_unix: 1603010100
4343

4444
- id: 6
4545
user_id: 10
4646
op_type: 1 # create repo
4747
act_user_id: 10
48-
repo_id: 7
48+
repo_id: 7 # private
4949
is_private: true
5050
created_unix: 1603011300
5151

5252
- id: 7
5353
user_id: 10
5454
op_type: 1 # create repo
5555
act_user_id: 10
56-
repo_id: 8
56+
repo_id: 8 # public
5757
is_private: false
5858
created_unix: 1603011540 # grouped with id:7

routers/web/feed/repo.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,10 @@ import (
1717
// ShowRepoFeed show user activitys based on repo as RSS / Atom feed
1818
func ShowRepoFeed(ctx *context.Context, repo *repo_model.Repository, formatType string) {
1919
actions, err := models.GetFeeds(ctx, models.GetFeedsOptions{
20-
RequestedRepo: repo,
21-
Actor: ctx.User,
22-
IncludePrivate: false,
23-
OnlyPerformedBy: false,
24-
IncludeDeleted: false,
25-
Date: ctx.FormString("date"),
20+
RequestedRepo: repo,
21+
Actor: ctx.User,
22+
IncludePrivate: true,
23+
Date: ctx.FormString("date"),
2624
})
2725
if err != nil {
2826
ctx.ServerError("GetFeeds", err)

0 commit comments

Comments
 (0)