Commit 0ec1e4c0 authored by Robert Schilling's avatar Robert Schilling

Merge branch 'milestoneRescue' into 'master'

Change percent_complete rescue value from 100 to 0

The percent_complete method returns a value of 100 when a
ZeroDivisionError occurs. That seems like a very strange default for an
error case, and results in a bug when a milestone has no corresponding
issues (new, empty milestones show 100% completion). This commit changes
the rescue value to 0, and subsequently fixes #1656, which reported this
problem.

See merge request !714
parents f955554d 8b92946b
......@@ -14,6 +14,7 @@ v 7.12.0 (unreleased)
- Use the user list from the target project in a merge request (Stan Hu)
- Default extention for wiki pages is now .md instead of .markdown (Jeroen van Baarsen)
- Add validation to wiki page creation (only [a-zA-Z0-9/_-] are allowed) (Jeroen van Baarsen)
- Fix new/empty milestones showing 100% completion value (Jonah Bishop)
v 7.11.2
- no changes
......
......@@ -44,7 +44,7 @@ class GroupMilestone
def percent_complete
((closed_items_count * 100) / total_items_count).abs
rescue ZeroDivisionError
100
0
end
def state
......
......@@ -66,7 +66,7 @@ class Milestone < ActiveRecord::Base
def percent_complete
((closed_items_count * 100) / total_items_count).abs
rescue ZeroDivisionError
100
0
end
def expires_at
......
......@@ -47,7 +47,7 @@ describe Milestone do
it "should recover from dividing by zero" do
expect(milestone.issues).to receive(:count).and_return(0)
expect(milestone.percent_complete).to eq(100)
expect(milestone.percent_complete).to eq(0)
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