diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2024-12-24 21:52:46 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-25 05:52:46 +0000 |
commit | f44712f22bc7bfce049c64c27f60453ff1e41a5c (patch) | |
tree | 2fbb530d8fc22747775898941a26c4230a92de96 | |
parent | 1a7591d7f9feada9556627344ed2189315c23033 (diff) | |
download | gitea-f44712f22bc7bfce049c64c27f60453ff1e41a5c.tar.gz gitea-f44712f22bc7bfce049c64c27f60453ff1e41a5c.zip |
demilestone should not include milestone (#32923)
Fix #32887
-rw-r--r-- | services/issue/milestone.go | 4 | ||||
-rw-r--r-- | services/issue/milestone_test.go | 8 |
2 files changed, 12 insertions, 0 deletions
diff --git a/services/issue/milestone.go b/services/issue/milestone.go index ff645744a7..beb6f131a9 100644 --- a/services/issue/milestone.go +++ b/services/issue/milestone.go @@ -59,6 +59,10 @@ func changeMilestoneAssign(ctx context.Context, doer *user_model.User, issue *is } } + if issue.MilestoneID == 0 { + issue.Milestone = nil + } + return nil } diff --git a/services/issue/milestone_test.go b/services/issue/milestone_test.go index 42b910166f..bf5abc85b7 100644 --- a/services/issue/milestone_test.go +++ b/services/issue/milestone_test.go @@ -23,6 +23,7 @@ func TestChangeMilestoneAssign(t *testing.T) { oldMilestoneID := issue.MilestoneID issue.MilestoneID = 2 + assert.NoError(t, issue.LoadMilestone(db.DefaultContext)) assert.NoError(t, ChangeMilestoneAssign(db.DefaultContext, issue, doer, oldMilestoneID)) unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{ IssueID: issue.ID, @@ -31,4 +32,11 @@ func TestChangeMilestoneAssign(t *testing.T) { OldMilestoneID: oldMilestoneID, }) unittest.CheckConsistencyFor(t, &issues_model.Milestone{}, &issues_model.Issue{}) + assert.NotNil(t, issue.Milestone) + + oldMilestoneID = issue.MilestoneID + issue.MilestoneID = 0 + assert.NoError(t, ChangeMilestoneAssign(db.DefaultContext, issue, doer, oldMilestoneID)) + assert.EqualValues(t, 0, issue.MilestoneID) + assert.Nil(t, issue.Milestone) } |