summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2013-01-04 08:30:25 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2013-01-04 08:30:25 +0000
commit9613a13b10aa4f55df122ffd3a910a10774906d6 (patch)
treeeeef4f590d29eb836a4bc5b65a6dc6609ef7cfdb
parent9c698157f44819d224a9be5c13d8b517690e4bed (diff)
downloadredmine-9613a13b10aa4f55df122ffd3a910a10774906d6.tar.gz
redmine-9613a13b10aa4f55df122ffd3a910a10774906d6.zip
Deprecates Version#*_pourcent in favour of #*_percent (#12724).
Patch by Daniel Felix. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11113 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/helpers/application_helper.rb2
-rw-r--r--app/models/project.rb2
-rw-r--r--app/models/version.rb20
-rw-r--r--app/views/versions/_overview.html.erb2
-rw-r--r--lib/redmine/helpers/gantt.rb4
-rw-r--r--public/stylesheets/application.css2
-rw-r--r--test/unit/version_test.rb34
7 files changed, 39 insertions, 27 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index e2eb9cc8b..afc6acb9c 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1026,7 +1026,7 @@ module ApplicationHelper
(pcts[1] > 0 ? content_tag('td', '', :style => "width: #{pcts[1]}%;", :class => 'done') : ''.html_safe) +
(pcts[2] > 0 ? content_tag('td', '', :style => "width: #{pcts[2]}%;", :class => 'todo') : ''.html_safe)
), :class => 'progress', :style => "width: #{width};").html_safe +
- content_tag('p', legend, :class => 'pourcent').html_safe
+ content_tag('p', legend, :class => 'percent').html_safe
end
def checked_image(checked=true)
diff --git a/app/models/project.rb b/app/models/project.rb
index e70d739f2..13842b6e6 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -567,7 +567,7 @@ class Project < ActiveRecord::Base
total / self_and_descendants.count
else
if versions.count > 0
- total = versions.collect(&:completed_pourcent).sum
+ total = versions.collect(&:completed_percent).sum
total / versions.count
else
diff --git a/app/models/version.rb b/app/models/version.rb
index f96ccb012..50225f362 100644
--- a/app/models/version.rb
+++ b/app/models/version.rb
@@ -97,10 +97,10 @@ class Version < ActiveRecord::Base
end
def behind_schedule?
- if completed_pourcent == 100
+ if completed_percent == 100
return false
elsif due_date && start_date
- done_date = start_date + ((due_date - start_date+1)* completed_pourcent/100).floor
+ done_date = start_date + ((due_date - start_date+1)* completed_percent/100).floor
return done_date <= Date.today
else
false # No issues so it's not late
@@ -109,7 +109,7 @@ class Version < ActiveRecord::Base
# Returns the completion percentage of this version based on the amount of open/closed issues
# and the time spent on the open issues.
- def completed_pourcent
+ def completed_percent
if issues_count == 0
0
elsif open_issues_count == 0
@@ -119,8 +119,14 @@ class Version < ActiveRecord::Base
end
end
+ # TODO: remove in Redmine 3.0
+ def completed_pourcent
+ ActiveSupport::Deprecation.warn "Version#completed_pourcent is deprecated and will be removed in Redmine 3.0. Please use #completed_percent instead."
+ completed_percent
+ end
+
# Returns the percentage of issues that have been marked as 'closed'.
- def closed_pourcent
+ def closed_percent
if issues_count == 0
0
else
@@ -128,6 +134,12 @@ class Version < ActiveRecord::Base
end
end
+ # TODO: remove in Redmine 3.0
+ def closed_pourcent
+ ActiveSupport::Deprecation.warn "Version#closed_pourcent is deprecated and will be removed in Redmine 3.0. Please use #closed_percent instead."
+ closed_percent
+ end
+
# Returns true if the version is overdue: due date reached and some open issues
def overdue?
effective_date && (effective_date < Date.today) && (open_issues_count > 0)
diff --git a/app/views/versions/_overview.html.erb b/app/views/versions/_overview.html.erb
index 216d82cda..4203a8463 100644
--- a/app/views/versions/_overview.html.erb
+++ b/app/views/versions/_overview.html.erb
@@ -16,7 +16,7 @@
<% end %>
<% if version.issues_count > 0 %>
- <%= progress_bar([version.closed_pourcent, version.completed_pourcent], :width => '40em', :legend => ('%0.0f%' % version.completed_pourcent)) %>
+ <%= progress_bar([version.closed_percent, version.completed_percent], :width => '40em', :legend => ('%0.0f%' % version.completed_percent)) %>
<p class="progress-info">
<%= link_to(l(:label_x_issues, :count => version.issues_count),
project_issues_path(version.project, :status_id => '*', :fixed_version_id => version, :set_filter => 1)) %>
diff --git a/lib/redmine/helpers/gantt.rb b/lib/redmine/helpers/gantt.rb
index c71eec1c8..db88b7902 100644
--- a/lib/redmine/helpers/gantt.rb
+++ b/lib/redmine/helpers/gantt.rb
@@ -307,9 +307,9 @@ module Redmine
options[:zoom] ||= 1
options[:g_width] ||= (self.date_to - self.date_from + 1) * options[:zoom]
coords = coordinates(version.start_date,
- version.due_date, version.completed_pourcent,
+ version.due_date, version.completed_percent,
options[:zoom])
- label = "#{h version} #{h version.completed_pourcent.to_i.to_s}%"
+ label = "#{h version} #{h version.completed_percent.to_i.to_s}%"
label = h("#{version.project} -") + label unless @project && @project == version.project
case options[:format]
when :html
diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css
index 1e17c1284..6cb5c0d6b 100644
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -702,7 +702,7 @@ table.progress td { height: 1em; }
table.progress td.closed { background: #BAE0BA none repeat scroll 0%; }
table.progress td.done { background: #D3EDD3 none repeat scroll 0%; }
table.progress td.todo { background: #eee none repeat scroll 0%; }
-p.pourcent {font-size: 80%;}
+p.percent {font-size: 80%;}
p.progress-info {clear: left; font-size: 80%; margin-top:-4px; color:#777;}
#roadmap table.progress td { height: 1.2em; }
diff --git a/test/unit/version_test.rb b/test/unit/version_test.rb
index ad4c0e0ca..ecc0d227e 100644
--- a/test/unit/version_test.rb
+++ b/test/unit/version_test.rb
@@ -46,8 +46,8 @@ class VersionTest < ActiveSupport::TestCase
def test_progress_should_be_0_with_no_assigned_issues
project = Project.find(1)
v = Version.create!(:project => project, :name => 'Progress')
- assert_equal 0, v.completed_pourcent
- assert_equal 0, v.closed_pourcent
+ assert_equal 0, v.completed_percent
+ assert_equal 0, v.closed_percent
end
def test_progress_should_be_0_with_unbegun_assigned_issues
@@ -55,8 +55,8 @@ class VersionTest < ActiveSupport::TestCase
v = Version.create!(:project => project, :name => 'Progress')
add_issue(v)
add_issue(v, :done_ratio => 0)
- assert_progress_equal 0, v.completed_pourcent
- assert_progress_equal 0, v.closed_pourcent
+ assert_progress_equal 0, v.completed_percent
+ assert_progress_equal 0, v.closed_percent
end
def test_progress_should_be_100_with_closed_assigned_issues
@@ -67,8 +67,8 @@ class VersionTest < ActiveSupport::TestCase
add_issue(v, :status => status, :done_ratio => 20)
add_issue(v, :status => status, :done_ratio => 70, :estimated_hours => 25)
add_issue(v, :status => status, :estimated_hours => 15)
- assert_progress_equal 100.0, v.completed_pourcent
- assert_progress_equal 100.0, v.closed_pourcent
+ assert_progress_equal 100.0, v.completed_percent
+ assert_progress_equal 100.0, v.closed_percent
end
def test_progress_should_consider_done_ratio_of_open_assigned_issues
@@ -77,8 +77,8 @@ class VersionTest < ActiveSupport::TestCase
add_issue(v)
add_issue(v, :done_ratio => 20)
add_issue(v, :done_ratio => 70)
- assert_progress_equal (0.0 + 20.0 + 70.0)/3, v.completed_pourcent
- assert_progress_equal 0, v.closed_pourcent
+ assert_progress_equal (0.0 + 20.0 + 70.0)/3, v.completed_percent
+ assert_progress_equal 0, v.closed_percent
end
def test_progress_should_consider_closed_issues_as_completed
@@ -87,8 +87,8 @@ class VersionTest < ActiveSupport::TestCase
add_issue(v)
add_issue(v, :done_ratio => 20)
add_issue(v, :status => IssueStatus.where(:is_closed => true).first)
- assert_progress_equal (0.0 + 20.0 + 100.0)/3, v.completed_pourcent
- assert_progress_equal (100.0)/3, v.closed_pourcent
+ assert_progress_equal (0.0 + 20.0 + 100.0)/3, v.completed_percent
+ assert_progress_equal (100.0)/3, v.closed_percent
end
def test_progress_should_consider_estimated_hours_to_weigth_issues
@@ -98,8 +98,8 @@ class VersionTest < ActiveSupport::TestCase
add_issue(v, :estimated_hours => 20, :done_ratio => 30)
add_issue(v, :estimated_hours => 40, :done_ratio => 10)
add_issue(v, :estimated_hours => 25, :status => IssueStatus.where(:is_closed => true).first)
- assert_progress_equal (10.0*0 + 20.0*0.3 + 40*0.1 + 25.0*1)/95.0*100, v.completed_pourcent
- assert_progress_equal 25.0/95.0*100, v.closed_pourcent
+ assert_progress_equal (10.0*0 + 20.0*0.3 + 40*0.1 + 25.0*1)/95.0*100, v.completed_percent
+ assert_progress_equal 25.0/95.0*100, v.closed_percent
end
def test_progress_should_consider_average_estimated_hours_to_weigth_unestimated_issues
@@ -109,8 +109,8 @@ class VersionTest < ActiveSupport::TestCase
add_issue(v, :status => IssueStatus.where(:is_closed => true).first)
add_issue(v, :estimated_hours => 10, :done_ratio => 30)
add_issue(v, :estimated_hours => 40, :done_ratio => 10)
- assert_progress_equal (25.0*0.2 + 25.0*1 + 10.0*0.3 + 40.0*0.1)/100.0*100, v.completed_pourcent
- assert_progress_equal 25.0/100.0*100, v.closed_pourcent
+ assert_progress_equal (25.0*0.2 + 25.0*1 + 10.0*0.3 + 40.0*0.1)/100.0*100, v.completed_percent
+ assert_progress_equal 25.0/100.0*100, v.closed_percent
end
def test_should_sort_scheduled_then_unscheduled_versions
@@ -152,7 +152,7 @@ class VersionTest < ActiveSupport::TestCase
@version.update_attribute(:effective_date, 7.days.from_now.to_date)
add_issue(@version, :start_date => 7.days.ago, :done_ratio => 60) # 14 day span, 60% done, 50% time left
add_issue(@version, :start_date => 7.days.ago, :done_ratio => 60) # 14 day span, 60% done, 50% time left
- assert_equal 60, @version.completed_pourcent
+ assert_equal 60, @version.completed_percent
assert_equal false, @version.behind_schedule?
end
@@ -160,7 +160,7 @@ class VersionTest < ActiveSupport::TestCase
@version.update_attribute(:effective_date, 7.days.from_now.to_date)
add_issue(@version, :start_date => 7.days.ago, :done_ratio => 60) # 14 day span, 60% done, 50% time left
add_issue(@version, :start_date => 7.days.ago, :done_ratio => 20) # 14 day span, 20% done, 50% time left
- assert_equal 40, @version.completed_pourcent
+ assert_equal 40, @version.completed_percent
assert_equal true, @version.behind_schedule?
end
@@ -168,7 +168,7 @@ class VersionTest < ActiveSupport::TestCase
@version.update_attribute(:effective_date, 7.days.from_now.to_date)
add_issue(@version, :start_date => 14.days.ago, :done_ratio => 100, :status => IssueStatus.find(5)) # 7 day span
add_issue(@version, :start_date => 14.days.ago, :done_ratio => 100, :status => IssueStatus.find(5)) # 7 day span
- assert_equal 100, @version.completed_pourcent
+ assert_equal 100, @version.completed_percent
assert_equal false, @version.behind_schedule?
end
end