diff options
author | Felipe Artur <felipefac@gmail.com> | 2016-04-06 17:02:22 +0300 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2016-04-06 17:02:22 +0300 |
commit | 9e6c61372fe0f7f2199f4e8f72b3c4e4a4219020 (patch) | |
tree | e8549747bf296c95f94cb9aed6a9782ec431e4bd | |
parent | 74313988aca5de1e65940d311f0f87e9da1b93c2 (diff) |
Fix milestone removal problem when editing issues
-rw-r--r-- | app/helpers/issues_helper.rb | 1 | ||||
-rw-r--r-- | spec/helpers/issues_helper_spec.rb | 15 |
2 files changed, 16 insertions, 0 deletions
diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 24b90fef4fe..414056c809f 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -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) diff --git a/spec/helpers/issues_helper_spec.rb b/spec/helpers/issues_helper_spec.rb index ffd8ebae029..df0eb22d6f6 100644 --- a/spec/helpers/issues_helper_spec.rb +++ b/spec/helpers/issues_helper_spec.rb @@ -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 |