@@ -26,7 +26,6 @@ import (
2626	api "code.gitea.io/gitea/modules/structs" 
2727	"code.gitea.io/gitea/modules/test" 
2828	"code.gitea.io/gitea/tests" 
29- 	"xorm.io/builder" 
3029
3130	"github.com/PuerkitoBio/goquery" 
3231	"github.com/stretchr/testify/assert" 
@@ -477,49 +476,42 @@ func TestIssueRedirect(t *testing.T) {
477476	session  :=  loginUser (t , "user2" )
478477
479478	// Test external tracker where style not set (shall default numeric) 
480- 	req  :=  NewRequest (t , "GET" , path . Join ( " org26" ,  " repo_external_tracker" ,  " issues" ,  "1" ) )
479+ 	req  :=  NewRequest (t , "GET" , "/ org26/ repo_external_tracker/ issues/1"  )
481480	resp  :=  session .MakeRequest (t , req , http .StatusSeeOther )
482481	assert .Equal (t , "https://tracker.com/org26/repo_external_tracker/issues/1" , test .RedirectURL (resp ))
483482
484483	// Test external tracker with numeric style 
485- 	req  =  NewRequest (t , "GET" , path . Join ( " org26" ,  " repo_external_tracker_numeric" ,  " issues" ,  "1" ) )
484+ 	req  =  NewRequest (t , "GET" , "/ org26/ repo_external_tracker_numeric/ issues/1"  )
486485	resp  =  session .MakeRequest (t , req , http .StatusSeeOther )
487486	assert .Equal (t , "https://tracker.com/org26/repo_external_tracker_numeric/issues/1" , test .RedirectURL (resp ))
488487
489488	// Test external tracker with alphanumeric style (for a pull request) 
490- 	req  =  NewRequest (t , "GET" , path . Join ( " org26" ,  " repo_external_tracker_alpha" ,  " issues" ,  "1" ) )
489+ 	req  =  NewRequest (t , "GET" , "/ org26/ repo_external_tracker_alpha/ issues/1"  )
491490	resp  =  session .MakeRequest (t , req , http .StatusSeeOther )
492- 	assert .Equal (t , "/"  + path . Join ( " org26" ,  " repo_external_tracker_alpha" ,  " pulls" ,  "1" ) , test .RedirectURL (resp ))
491+ 	assert .Equal (t , "/org26/ repo_external_tracker_alpha/ pulls/1"  , test .RedirectURL (resp ))
493492
494493	// test to check that the PR redirection works if the issue unit is disabled 
495494	// repo1 is a normal repository with issue unit enabled, visit issue 2(which is a pull request) 
496495	// will redirect to pulls 
497- 	req  =  NewRequest (t , "GET" , path . Join ( " user2" ,  " repo1" ,  " issues" ,  "2" ) )
496+ 	req  =  NewRequest (t , "GET" , "/ user2/ repo1/ issues/2"  )
498497	resp  =  session .MakeRequest (t , req , http .StatusSeeOther )
499- 	assert .Equal (t , "/"  + path . Join ( " user2" ,  " repo1" ,  " pulls" ,  "2" ) , test .RedirectURL (resp ))
498+ 	assert .Equal (t , "/user2/ repo1/ pulls/2"  , test .RedirectURL (resp ))
500499
501500	// disable issue unit 
502- 	repoUnit , exist , err  :=  db .Get [repo_model.RepoUnit ](t .Context (), builder.Eq {
503- 		"repo_id" : 1 ,
504- 		"type" :    unit .TypeIssues ,
505- 	})
506- 	assert .NoError (t , err )
507- 	assert .True (t , exist )
508- 	assert .NotNil (t , repoUnit )
501+ 	repoUnit  :=  unittest .AssertExistsAndLoadBean (t , & repo_model.RepoUnit {RepoID : 1 , Type : unit .TypeIssues })
509502
510- 	_ , err  =  db .DeleteByID [repo_model.RepoUnit ](t .Context (), repoUnit .ID )
503+ 	_ , err  : =  db .DeleteByID [repo_model.RepoUnit ](t .Context (), repoUnit .ID )
511504	assert .NoError (t , err )
512505
513- 	defer  func () {
514- 		repoUnit .ID  =  0 
515- 		assert .NoError (t , db .Insert (t .Context (), repoUnit ))
516- 	}()
517- 
518506	// even if the issue unit is disabled, visiting an issue which is a pull request 
519507	// will still redirect to pull request 
520- 	req  =  NewRequest (t , "GET" , path . Join ( " user2" ,  " repo1" ,  " issues" ,  "2" ) )
508+ 	req  =  NewRequest (t , "GET" , "/ user2/ repo1/ issues/2"  )
521509	resp  =  session .MakeRequest (t , req , http .StatusSeeOther )
522- 	assert .Equal (t , "/" + path .Join ("user2" , "repo1" , "pulls" , "2" ), test .RedirectURL (resp ))
510+ 	assert .Equal (t , "/user2/repo1/pulls/2" , test .RedirectURL (resp ))
511+ 
512+ 	// cleanup, re-enable issue unit 
513+ 	repoUnit .ID  =  0 
514+ 	assert .NoError (t , db .Insert (t .Context (), repoUnit ))
523515}
524516
525517func  TestSearchIssues (t  * testing.T ) {
0 commit comments