@@ -223,23 +223,33 @@ func TestAPIEditPull(t *testing.T) {
223223
224224 session := loginUser (t , owner10 .Name )
225225 token := getTokenForLoggedInUser (t , session , auth_model .AccessTokenScopeWriteRepository )
226+ title := "create a success pr"
226227 req := NewRequestWithJSON (t , http .MethodPost , fmt .Sprintf ("/api/v1/repos/%s/%s/pulls" , owner10 .Name , repo10 .Name ), & api.CreatePullRequestOption {
227228 Head : "develop" ,
228229 Base : "master" ,
229- Title : "create a success pr" ,
230+ Title : title ,
230231 }).AddTokenAuth (token )
231- pull := new (api.PullRequest )
232+ apiPull := new (api.PullRequest )
232233 resp := MakeRequest (t , req , http .StatusCreated )
233- DecodeJSON (t , resp , pull )
234- assert .EqualValues (t , "master" , pull .Base .Name )
234+ DecodeJSON (t , resp , apiPull )
235+ assert .EqualValues (t , "master" , apiPull .Base .Name )
235236
236- req = NewRequestWithJSON (t , http .MethodPatch , fmt .Sprintf ("/api/v1/repos/%s/%s/pulls/%d" , owner10 .Name , repo10 .Name , pull .Index ), & api.EditPullRequestOption {
237+ newTitle := "edit a this pr"
238+ newBody := "edited body"
239+ req = NewRequestWithJSON (t , http .MethodPatch , fmt .Sprintf ("/api/v1/repos/%s/%s/pulls/%d" , owner10 .Name , repo10 .Name , apiPull .Index ), & api.EditPullRequestOption {
237240 Base : "feature/1" ,
238- Title : "edit a this pr" ,
241+ Title : newTitle ,
242+ Body : & newBody ,
239243 }).AddTokenAuth (token )
240244 resp = MakeRequest (t , req , http .StatusCreated )
241- DecodeJSON (t , resp , pull )
242- assert .EqualValues (t , "feature/1" , pull .Base .Name )
245+ DecodeJSON (t , resp , apiPull )
246+ assert .EqualValues (t , "feature/1" , apiPull .Base .Name )
247+ // check comment history
248+ pull := unittest .AssertExistsAndLoadBean (t , & issues_model.PullRequest {ID : apiPull .ID })
249+ err := pull .LoadIssue (db .DefaultContext )
250+ assert .NoError (t , err )
251+ unittest .AssertExistsAndLoadBean (t , & issues_model.Comment {IssueID : pull .Issue .ID , OldTitle : title , NewTitle : newTitle })
252+ unittest .AssertExistsAndLoadBean (t , & issues_model.ContentHistory {IssueID : pull .Issue .ID , ContentText : newBody , IsFirstCreated : false })
243253
244254 req = NewRequestWithJSON (t , http .MethodPatch , fmt .Sprintf ("/api/v1/repos/%s/%s/pulls/%d" , owner10 .Name , repo10 .Name , pull .Index ), & api.EditPullRequestOption {
245255 Base : "not-exist" ,
0 commit comments