File tree 1 file changed +24
-6
lines changed
1 file changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -97,26 +97,44 @@ func TestCollaborationPost(t *testing.T) {
97
97
assert .True (t , exists )
98
98
}
99
99
100
- func TestCollaborationPost_InactiveUser (t * testing.T ) {
100
+ func TestCollaborationPost_AddCollaboratorTwice (t * testing.T ) {
101
101
102
102
models .PrepareTestEnv (t )
103
103
ctx := test .MockContext (t , "user2/repo1/issues/labels" )
104
104
test .LoadUser (t , ctx , 2 )
105
- test .LoadUser (t , ctx , 9 )
105
+ test .LoadUser (t , ctx , 4 )
106
106
test .LoadRepo (t , ctx , 1 )
107
107
108
- ctx .Req .Form .Set ("collaborator" , "user9" )
108
+ ctx .Req .Form .Set ("collaborator" , "user4" )
109
+
110
+ u := & models.User {
111
+ LowerName : "user2" ,
112
+ Type : models .UserTypeIndividual ,
113
+ }
114
+
115
+ re := & models.Repository {
116
+ ID : 2 ,
117
+ Owner : u ,
118
+ }
109
119
110
120
repo := & context.Repository {
111
- Owner : & models.User {
112
- LowerName : "user2" ,
113
- },
121
+ Owner : u ,
122
+ Repository : re ,
114
123
}
115
124
116
125
ctx .Repo = repo
117
126
118
127
CollaborationPost (ctx )
119
128
129
+ assert .EqualValues (t , http .StatusFound , ctx .Resp .Status ())
130
+
131
+ exists , err := re .IsCollaborator (4 )
132
+ assert .NoError (t , err )
133
+ assert .True (t , exists )
134
+
135
+ // Try adding the same collaborator again
136
+ CollaborationPost (ctx )
137
+
120
138
assert .EqualValues (t , http .StatusFound , ctx .Resp .Status ())
121
139
assert .NotEmpty (t , ctx .Flash .ErrorMsg )
122
140
}
You can’t perform that action at this time.
0 commit comments