summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2007-10-10 18:56:59 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2007-10-10 18:56:59 +0000
commit5f10cc867327cd2d2620f10b30ca9c5f2f3a8791 (patch)
treef842a577ec88d42c5ef72d57d195e3b695e106f9
parent45203143c15d3909e1cd343fc59ee21cc5f52a86 (diff)
downloadredmine-5f10cc867327cd2d2620f10b30ca9c5f2f3a8791.tar.gz
redmine-5f10cc867327cd2d2620f10b30ca9c5f2f3a8791.zip
Added the ability to set the "done ratio" of issues fixed by commit (original path by Nikolay Solakov, slightly edited).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@821 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/models/changeset.rb4
-rw-r--r--app/views/settings/edit.rhtml1
-rw-r--r--config/settings.yml3
-rw-r--r--test/unit/repository_test.rb9
4 files changed, 13 insertions, 4 deletions
diff --git a/app/models/changeset.rb b/app/models/changeset.rb
index 330338ab1..21e14fc0d 100644
--- a/app/models/changeset.rb
+++ b/app/models/changeset.rb
@@ -55,8 +55,9 @@ class Changeset < ActiveRecord::Base
ref_keywords = Setting.commit_ref_keywords.downcase.split(",")
# keywords used to fix issues
fix_keywords = Setting.commit_fix_keywords.downcase.split(",")
- # status applied
+ # status and optional done ratio applied
fix_status = IssueStatus.find_by_id(Setting.commit_fix_status_id)
+ done_ratio = Setting.commit_fix_done_ratio.blank? ? nil : Setting.commit_fix_done_ratio.to_i
kw_regexp = (ref_keywords + fix_keywords).collect{|kw| Regexp.escape(kw.strip)}.join("|")
return if kw_regexp.blank?
@@ -75,6 +76,7 @@ class Changeset < ActiveRecord::Base
# don't change the status is the issue is already closed
next if issue.status.is_closed?
issue.status = fix_status
+ issue.done_ratio = done_ratio if done_ratio
issue.save
end
end
diff --git a/app/views/settings/edit.rhtml b/app/views/settings/edit.rhtml
index 736e6c421..503339884 100644
--- a/app/views/settings/edit.rhtml
+++ b/app/views/settings/edit.rhtml
@@ -85,6 +85,7 @@
<p><label><%= l(:setting_commit_fix_keywords) %></label>
<%= text_field_tag 'settings[commit_fix_keywords]', Setting.commit_fix_keywords, :size => 30 %>
&nbsp;<%= l(:label_applied_status) %>: <%= select_tag 'settings[commit_fix_status_id]', options_for_select( [["", 0]] + IssueStatus.find(:all).collect{|status| [status.name, status.id.to_s]}, Setting.commit_fix_status_id) %>
+&nbsp;<%= l(:field_done_ratio) %>: <%= select_tag 'settings[commit_fix_done_ratio]', options_for_select( [[l(:label_no_change_option), '']] + ((0..10).to_a.collect {|r| ["#{r*10} %", "#{r*10}"] }), Setting.commit_fix_done_ratio) %>
<br /><em><%= l(:text_comma_separated) %></em></p>
</fieldset>
diff --git a/config/settings.yml b/config/settings.yml
index e2897775e..f0591ba5a 100644
--- a/config/settings.yml
+++ b/config/settings.yml
@@ -61,6 +61,9 @@ commit_fix_keywords:
commit_fix_status_id:
format: int
default: 0
+commit_fix_done_ratio:
+ format: int
+ default: 100
# autologin duration in days
# 0 means autologin is disabled
autologin:
diff --git a/test/unit/repository_test.rb b/test/unit/repository_test.rb
index bc2fa626c..ea2122aa7 100644
--- a/test/unit/repository_test.rb
+++ b/test/unit/repository_test.rb
@@ -39,7 +39,8 @@ class RepositoryTest < Test::Unit::TestCase
def test_scan_changesets_for_issue_ids
# choosing a status to apply to fix issues
Setting.commit_fix_status_id = IssueStatus.find(:first, :conditions => ["is_closed = ?", true]).id
-
+ Setting.commit_fix_done_ratio = "90"
+
# make sure issue 1 is not already closed
assert !Issue.find(1).status.is_closed?
@@ -47,8 +48,10 @@ class RepositoryTest < Test::Unit::TestCase
assert_equal [101, 102], Issue.find(3).changeset_ids
# fixed issues
- assert Issue.find(1).status.is_closed?
- assert_equal [101], Issue.find(1).changeset_ids
+ fixed_issue = Issue.find(1)
+ assert fixed_issue.status.is_closed?
+ assert_equal 90, fixed_issue.done_ratio
+ assert_equal [101], fixed_issue.changeset_ids
# ignoring commits referencing an issue of another project
assert_equal [], Issue.find(4).changesets