aboutsummaryrefslogtreecommitdiffstats
path: root/models/action_test.go
diff options
context:
space:
mode:
authorEthan Koenig <etk39@cornell.edu>2017-06-01 20:42:25 -0400
committerLunny Xiao <xiaolunwen@gmail.com>2017-06-02 08:42:25 +0800
commit4e5ee2b67ac9c54ce2b0e05daf8b61a97cbe743b (patch)
tree99bb3a3ab373b625cf4ae17f4d9b210d83c1cb9f /models/action_test.go
parent5ca6867aaf1d82f21a474d0c65041f21d7b416c3 (diff)
downloadgitea-4e5ee2b67ac9c54ce2b0e05daf8b61a97cbe743b.tar.gz
gitea-4e5ee2b67ac9c54ce2b0e05daf8b61a97cbe743b.zip
Fix user profile activity feed (#1848)
* Fix user profile activity feed * gofmt, and avoid overlapping database connections
Diffstat (limited to 'models/action_test.go')
-rw-r--r--models/action_test.go45
1 files changed, 33 insertions, 12 deletions
diff --git a/models/action_test.go b/models/action_test.go
index c6d3911a63..debc884b37 100644
--- a/models/action_test.go
+++ b/models/action_test.go
@@ -305,13 +305,23 @@ func TestGetFeeds(t *testing.T) {
assert.NoError(t, PrepareTestDatabase())
user := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
- actions, err := GetFeeds(user, user.ID, 0, false)
+ actions, err := GetFeeds(GetFeedsOptions{
+ RequestedUser: user,
+ RequestingUserID: user.ID,
+ IncludePrivate: true,
+ OnlyPerformedBy: false,
+ })
assert.NoError(t, err)
assert.Len(t, actions, 1)
- assert.Equal(t, int64(1), actions[0].ID)
- assert.Equal(t, user.ID, actions[0].UserID)
-
- actions, err = GetFeeds(user, user.ID, 0, true)
+ assert.EqualValues(t, 1, actions[0].ID)
+ assert.EqualValues(t, user.ID, actions[0].UserID)
+
+ actions, err = GetFeeds(GetFeedsOptions{
+ RequestedUser: user,
+ RequestingUserID: user.ID,
+ IncludePrivate: false,
+ OnlyPerformedBy: false,
+ })
assert.NoError(t, err)
assert.Len(t, actions, 0)
}
@@ -319,15 +329,26 @@ func TestGetFeeds(t *testing.T) {
func TestGetFeeds2(t *testing.T) {
// test with an organization user
assert.NoError(t, PrepareTestDatabase())
- user := AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
-
- actions, err := GetFeeds(user, user.ID, 0, false)
+ org := AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
+ userID := AssertExistsAndLoadBean(t, &OrgUser{OrgID: org.ID, IsOwner: true}).(*OrgUser).UID
+
+ actions, err := GetFeeds(GetFeedsOptions{
+ RequestedUser: org,
+ RequestingUserID: userID,
+ IncludePrivate: true,
+ OnlyPerformedBy: false,
+ })
assert.NoError(t, err)
assert.Len(t, actions, 1)
- assert.Equal(t, int64(2), actions[0].ID)
- assert.Equal(t, user.ID, actions[0].UserID)
-
- actions, err = GetFeeds(user, user.ID, 0, true)
+ assert.EqualValues(t, 2, actions[0].ID)
+ assert.EqualValues(t, org.ID, actions[0].UserID)
+
+ actions, err = GetFeeds(GetFeedsOptions{
+ RequestedUser: org,
+ RequestingUserID: userID,
+ IncludePrivate: false,
+ OnlyPerformedBy: false,
+ })
assert.NoError(t, err)
assert.Len(t, actions, 0)
}