mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Fix empty project displayed in issue sidebar (#25802)
Before:  After:  This issue comes from the change in #25468. `LoadProject` will always return at least one record, so we use `ProjectID` to check whether an issue is linked to a project in the old code. As other `issue.LoadXXX` functions, we need to check the return value from `xorm.Session.Get`. In recent unit tests, we only test `issueList.LoadAttributes()` but don't test `issue.LoadAttributes()`. So I added a new test for `issue.LoadAttributes()` in this PR. --------- Co-authored-by: Denys Konovalov <privat@denyskon.de>
This commit is contained in:
		@@ -67,9 +67,7 @@ func TestIssueList_LoadAttributes(t *testing.T) {
 | 
			
		||||
		if issue.ID == int64(1) {
 | 
			
		||||
			assert.Equal(t, int64(400), issue.TotalTrackedTime)
 | 
			
		||||
			assert.NotNil(t, issue.Project)
 | 
			
		||||
		} else if issue.ID == int64(2) {
 | 
			
		||||
			assert.Equal(t, int64(3682), issue.TotalTrackedTime)
 | 
			
		||||
			assert.Nil(t, issue.Project)
 | 
			
		||||
			assert.Equal(t, int64(1), issue.Project.ID)
 | 
			
		||||
		} else {
 | 
			
		||||
			assert.Nil(t, issue.Project)
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user