Commit 0913204f authored by Robert Speicher's avatar Robert Speicher

Merge branch 'issue_1752' into 'master'

Fix milestone removal problem when editing issues

fixes #1752 

See merge request !3571
parents 7998725e 8d5ad4e3
...@@ -52,6 +52,7 @@ module IssuesHelper ...@@ -52,6 +52,7 @@ module IssuesHelper
def milestone_options(object) def milestone_options(object)
milestones = object.project.milestones.active.reorder(due_date: :asc, title: :asc).to_a 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) milestones.unshift(Milestone::None)
options_from_collection_for_select(milestones, 'id', 'title', object.milestone_id) options_from_collection_for_select(milestones, 'id', 'title', object.milestone_id)
......
...@@ -80,7 +80,7 @@ describe IssuesHelper do ...@@ -80,7 +80,7 @@ describe IssuesHelper do
end end
end end
describe '#url_for_new_issue' do describe 'url_for_new_issue' do
let(:issues_url) { ext_project.external_issue_tracker.new_issue_url } let(:issues_url) { ext_project.external_issue_tracker.new_issue_url }
let(:ext_expected) do let(:ext_expected) do
issues_url.gsub(':project_id', ext_project.id.to_s) issues_url.gsub(':project_id', ext_project.id.to_s)
...@@ -117,7 +117,7 @@ describe IssuesHelper do ...@@ -117,7 +117,7 @@ describe IssuesHelper do
end end
end end
describe "#merge_requests_sentence" do describe "merge_requests_sentence" do
subject { merge_requests_sentence(merge_requests)} subject { merge_requests_sentence(merge_requests)}
let(:merge_requests) do let(:merge_requests) do
[ build(:merge_request, iid: 1), build(:merge_request, iid: 2), [ build(:merge_request, iid: 1), build(:merge_request, iid: 2),
...@@ -127,7 +127,7 @@ describe IssuesHelper do ...@@ -127,7 +127,7 @@ describe IssuesHelper do
it { is_expected.to eq("!1, !2, or !3") } it { is_expected.to eq("!1, !2, or !3") }
end end
describe "#note_active_class" do describe "note_active_class" do
before do before do
@note = create :note @note = create :note
@note1 = create :note @note1 = create :note
...@@ -142,10 +142,25 @@ describe IssuesHelper do ...@@ -142,10 +142,25 @@ describe IssuesHelper do
end end
end end
describe "#awards_sort" do describe "awards_sort" do
it "sorts a hash so thumbsup and thumbsdown are always on top" do it "sorts a hash so thumbsup and thumbsdown are always on top" do
data = { "thumbsdown" => "some value", "lifter" => "some value", "thumbsup" => "some value" } data = { "thumbsdown" => "some value", "lifter" => "some value", "thumbsup" => "some value" }
expect(awards_sort(data).keys).to eq(["thumbsup", "thumbsdown", "lifter"]) expect(awards_sort(data).keys).to eq(["thumbsup", "thumbsdown", "lifter"])
end end
end end
describe "milestone_options" do
it "gets closed milestone from current issue" do
closed_milestone = create(:closed_milestone, project: project)
milestone1 = create(:milestone, project: project)
milestone2 = create(:milestone, project: project)
issue.update_attributes(milestone_id: closed_milestone.id)
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 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