Commit ea5c25bb authored by Stan Hu's avatar Stan Hu

Remove milestones from merge requests when milestones are deleted

Reported by
parent abaa65ef
......@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 8.0.0 (unreleased)
- Fix Markdown links not showing up in dashboard activity feed (Stan Hu)
- Remove milestones from merge requests when milestones are deleted (Stan Hu)
- Fix HTML link that was improperly escaped in new user e-mail (Stan Hu)
- Fix broken sort in merge request API (Stan Hu)
- Bump rouge to 1.10.1 to remove warning noise and fix other syntax highlighting bugs (Stan Hu)
......@@ -4,10 +4,15 @@ def execute(milestone)
Milestone.transaction do
update_params = { milestone: nil }
milestone.issues.each do |issue|, current_user, update_params).execute(issue)
milestone.merge_requests.each do |merge_request|, current_user, update_params).execute(merge_request)
event_service.destroy_milestone(milestone, current_user)
Event.for_milestone_id( do |event|
......@@ -5,6 +5,7 @@
let(:user) { create(:user) }
let(:milestone) { create(:milestone, project: project) }
let(:issue) { create(:issue, project: project, milestone: milestone) }
let(:merge_request) { create(:merge_request, source_project: project, target_project: project, milestone: milestone) }
before do
......@@ -14,6 +15,7 @@
describe "#destroy" do
it "should remove milestone" do
expect(issue.milestone_id).to eq(
delete :destroy, namespace_id:, project_id:, id:, format: :js
......@@ -24,6 +26,10 @@
expect { Milestone.find( }.to raise_exception(ActiveRecord::RecordNotFound)
expect(issue.milestone_id).to eq(nil)
expect(merge_request.milestone_id).to eq(nil)
# Check system note left for milestone removal
last_note = project.issues.find([-1].note
expect(last_note).to eq('Milestone removed')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment