Feature #33894 » 33894.patch
app/models/issue.rb | ||
---|---|---|
54 | 54 |
acts_as_activity_provider :scope => preload(:project, :author, :tracker, :status), |
55 | 55 |
:author_key => :author_id |
56 | 56 | |
57 |
DONE_RATIO_OPTIONS = %w(issue_field issue_status) |
|
57 |
DONE_RATIO_OPTIONS = %w(issue_field issue_status issue_field_and_closed_status)
|
|
58 | 58 | |
59 | 59 |
attr_reader :transition_warning |
60 | 60 |
attr_writer :deleted_attachment_ids |
... | ... | |
702 | 702 |
def done_ratio |
703 | 703 |
if Issue.use_status_for_done_ratio? && status && status.default_done_ratio |
704 | 704 |
status.default_done_ratio |
705 |
elsif Issue.use_issue_field_and_closed_status_for_done_ratio? && status && status.is_closed? |
|
706 |
100 |
|
705 | 707 |
else |
706 | 708 |
read_attribute(:done_ratio) |
707 | 709 |
end |
... | ... | |
715 | 717 |
Setting.issue_done_ratio == 'issue_field' |
716 | 718 |
end |
717 | 719 | |
720 |
def self.use_issue_field_and_closed_status_for_done_ratio? |
|
721 |
Setting.issue_done_ratio == 'issue_field_and_closed_status' |
|
722 |
end |
|
723 | ||
724 |
def self.done_ratio_editable? |
|
725 |
use_status_for_done_ratio? || use_issue_field_and_closed_status_for_done_ratio? |
|
726 |
end |
|
727 | ||
718 | 728 |
def validate_issue |
719 | 729 |
if due_date && start_date && (start_date_changed? || due_date_changed?) && due_date < start_date |
720 | 730 |
errors.add :due_date, :greater_than_start_date |
... | ... | |
816 | 826 |
def update_done_ratio_from_issue_status |
817 | 827 |
if Issue.use_status_for_done_ratio? && status && status.default_done_ratio |
818 | 828 |
self.done_ratio = status.default_done_ratio |
829 |
elsif Issue.use_issue_field_and_closed_status_for_done_ratio? && status && status.is_closed? |
|
830 |
self.done_ratio = 100 |
|
819 | 831 |
end |
820 | 832 |
end |
821 | 833 |
app/views/issues/_attributes.html.erb | ||
---|---|---|
83 | 83 |
<p><%= f.hours_field :estimated_hours, :size => 3, :required => @issue.required_attribute?('estimated_hours') %> <%= l(:field_hours) %></p> |
84 | 84 |
<% end %> |
85 | 85 | |
86 |
<% if @issue.safe_attribute?('done_ratio') && Issue.use_field_for_done_ratio? %>
|
|
86 |
<% if @issue.safe_attribute?('done_ratio') && Issue.done_ratio_editable? %>
|
|
87 | 87 |
<p><%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }), :required => @issue.required_attribute?('done_ratio') %></p> |
88 | 88 |
<% end %> |
89 | 89 |
</div> |
app/views/issues/bulk_edit.html.erb | ||
---|---|---|
175 | 175 |
</p> |
176 | 176 |
<% end %> |
177 | 177 | |
178 |
<% if @safe_attributes.include?('done_ratio') && Issue.use_field_for_done_ratio? %>
|
|
178 |
<% if @safe_attributes.include?('done_ratio') && Issue.done_ratio_editable? %>
|
|
179 | 179 |
<p> |
180 | 180 |
<label for='issue_done_ratio'><%= l(:field_done_ratio) %></label> |
181 | 181 |
<%= select_tag 'issue[done_ratio]', options_for_select([[l(:label_no_change_option), '']] + (0..10).to_a.collect {|r| ["#{r*10} %", r*10] }, @issue_params[:done_ratio]) %> |
config/locales/en.yml | ||
---|---|---|
463 | 463 |
setting_issue_done_ratio: Calculate the issue done ratio with |
464 | 464 |
setting_issue_done_ratio_issue_field: Use the issue field |
465 | 465 |
setting_issue_done_ratio_issue_status: Use the issue status |
466 |
setting_issue_done_ratio_issue_field_and_closed_status: Use the issue field (100% if closed) |
|
466 | 467 |
setting_start_of_week: Start calendars on |
467 | 468 |
setting_rest_api_enabled: Enable REST web service |
468 | 469 |
setting_cache_formatted_text: Cache formatted text |
config/locales/ja.yml | ||
---|---|---|
394 | 394 |
setting_issue_done_ratio: 進捗率の算出方法 |
395 | 395 |
setting_issue_done_ratio_issue_field: チケットのフィールドを使用 |
396 | 396 |
setting_issue_done_ratio_issue_status: チケットのステータスに連動 |
397 |
setting_issue_done_ratio_issue_field_and_closed_status: チケットのフィールドを使用(終了したチケットは100%) |
|
397 | 398 |
setting_start_of_week: 週の開始曜日 |
398 | 399 |
setting_rest_api_enabled: RESTによるWebサービスを有効にする |
399 | 400 |
setting_default_notification_option: デフォルトのメール通知オプション |
test/unit/issue_test.rb | ||
---|---|---|
2823 | 2823 |
end |
2824 | 2824 |
end |
2825 | 2825 | |
2826 |
# done_ratio should change to 100 when the status is closed and Setting.issue_done_ratio equal issue_field_and_closed_status |
|
2827 |
test "when updating to closed status should update done_ratio according to Setting.issue_done_ratio" do |
|
2828 |
closed_status = IssueStatus.find(5) |
|
2829 |
closed_status.update!(:default_done_ratio => 90) |
|
2830 | ||
2831 |
with_settings :issue_done_ratio => 'issue_field' do |
|
2832 |
issue = Issue.generate!(:status_id => 1, :done_ratio => 30) |
|
2833 |
issue.update!(:status => closed_status) |
|
2834 | ||
2835 |
assert_equal 30, issue.done_ratio |
|
2836 |
assert_equal 30, issue.read_attribute(:done_ratio) |
|
2837 |
end |
|
2838 | ||
2839 |
with_settings :issue_done_ratio => 'issue_status' do |
|
2840 |
issue = Issue.generate!(:status_id => 1, :done_ratio => 30) |
|
2841 |
issue.update!(:status => closed_status) |
|
2842 | ||
2843 |
assert_equal 90, issue.done_ratio |
|
2844 |
assert_equal 90, issue.read_attribute(:done_ratio) |
|
2845 |
end |
|
2846 | ||
2847 |
with_settings :issue_done_ratio => 'issue_field_and_closed_status' do |
|
2848 |
issue = Issue.generate!(:status_id => 1, :done_ratio => 30) |
|
2849 |
issue.update!(:status => closed_status) |
|
2850 | ||
2851 |
assert_equal 100, issue.done_ratio |
|
2852 |
assert_equal 100, issue.read_attribute(:done_ratio) |
|
2853 |
end |
|
2854 |
end |
|
2855 | ||
2856 |
test "done ratio of existing issues follows the new issue_done_ratio setting" do |
|
2857 |
closed_status = IssueStatus.find(5) |
|
2858 |
closed_status.update!(:default_done_ratio => 90) |
|
2859 | ||
2860 |
issue = Issue.generate!(:status_id => 1, :done_ratio => 30) |
|
2861 |
issue.update!(:status => closed_status) |
|
2862 | ||
2863 |
with_settings :issue_done_ratio => 'issue_status' do |
|
2864 |
assert_equal 90, issue.done_ratio |
|
2865 |
assert_equal 30, issue.read_attribute(:done_ratio) |
|
2866 |
end |
|
2867 | ||
2868 |
with_settings :issue_done_ratio => 'issue_field_and_closed_status' do |
|
2869 |
assert_equal 100, issue.done_ratio |
|
2870 |
assert_equal 30, issue.read_attribute(:done_ratio) |
|
2871 |
end |
|
2872 | ||
2873 |
with_settings :issue_done_ratio => 'issue_field' do |
|
2874 |
assert_equal 30, issue.done_ratio |
|
2875 |
assert_equal 30, issue.read_attribute(:done_ratio) |
|
2876 |
end |
|
2877 |
end |
|
2878 | ||
2826 | 2879 |
test "#by_tracker" do |
2827 | 2880 |
User.current = User.find(2) |
2828 | 2881 |
groups = Issue.by_tracker(Project.find(1)) |