Commit 9e6c6137 authored by Felipe Artur's avatar Felipe Artur

Fix milestone removal problem when editing issues

parent 74313988
......@@ -52,6 +52,7 @@ module IssuesHelper
def milestone_options(object)
milestones = object.project.milestones.active.reorder(due_date: :asc, title: :asc).to_a
milestones.unshift(object.milestone) if object.milestone.present? && object.milestone.closed?
milestones.unshift(Milestone::None)
options_from_collection_for_select(milestones, 'id', 'title', object.milestone_id)
......
......@@ -148,4 +148,19 @@ describe IssuesHelper do
expect(awards_sort(data).keys).to eq(["thumbsup", "thumbsdown", "lifter"])
end
end
describe "#milestone options" do
let!(:closed_milestone) { create :closed_milestone, title: "closed milestone", project: project }
let!(:milestone1) { create :milestone, title: "open milestone 1", project: project }
let!(:milestone2) { create :milestone, title: "open milestone 2", project: project }
before { issue.update_attributes(milestone_id: closed_milestone.id) }
it "gets closed milestone from current issue" do
options = milestone_options(issue)
expect(options).to have_selector('option[selected]', text: closed_milestone.title)
expect(options).to have_selector('option', text: milestone1.title)
expect(options).to have_selector('option', text: milestone2.title)
end
end
end
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