Feature #31756 » 31756.patch
app/models/issue.rb | ||
---|---|---|
56 | 56 | |
57 | 57 |
acts_as_mentionable :attributes => ['description'] |
58 | 58 | |
59 |
DONE_RATIO_OPTIONS = %w(issue_field issue_status) |
|
59 |
DONE_RATIO_OPTIONS = %w[ |
|
60 |
issue_field |
|
61 |
issue_field_5_percent_increments |
|
62 |
issue_status |
|
63 |
] |
|
60 | 64 | |
61 | 65 |
attr_reader :transition_warning |
62 | 66 |
attr_writer :deleted_attachment_ids |
... | ... | |
746 | 750 |
end |
747 | 751 | |
748 | 752 |
def self.use_field_for_done_ratio? |
749 |
Setting.issue_done_ratio == 'issue_field' |
|
753 |
Setting.issue_done_ratio.start_with?('issue_field') |
|
754 |
end |
|
755 | ||
756 |
def self.done_ratio_step_value |
|
757 |
case Setting.issue_done_ratio |
|
758 |
when 'issue_field' |
|
759 |
10 |
|
760 |
when 'issue_field_5_percent_increments' |
|
761 |
5 |
|
762 |
else |
|
763 |
# Unknown option |
|
764 |
self.use_field_for_done_ratio? ? 10 : nil |
|
765 |
end |
|
750 | 766 |
end |
751 | 767 | |
752 | 768 |
def validate_issue |
app/views/issues/_attributes.html.erb | ||
---|---|---|
88 | 88 |
<% end %> |
89 | 89 | |
90 | 90 |
<% if @issue.safe_attribute?('done_ratio') && Issue.use_field_for_done_ratio? %> |
91 |
<p><%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }), :required => @issue.required_attribute?('done_ratio') %></p>
|
|
91 |
<p><%= f.select :done_ratio, ((0..100).step(Issue.done_ratio_step_value).to_a.collect {|r| ["#{r} %", r] }), :required => @issue.required_attribute?('done_ratio') %></p>
|
|
92 | 92 |
<% end %> |
93 | 93 |
</div> |
94 | 94 |
</div> |
config/locales/en.yml | ||
---|---|---|
476 | 476 |
setting_new_project_user_role_id: Role given to a non-admin user who creates a project |
477 | 477 |
setting_default_projects_modules: Default enabled modules for new projects |
478 | 478 |
setting_issue_done_ratio: Calculate the issue done ratio with |
479 |
setting_issue_done_ratio_issue_field: Use the issue field |
|
479 |
setting_issue_done_ratio_issue_field: Use the issue field (10% increments) |
|
480 |
setting_issue_done_ratio_issue_field_5_percent_increments: Use the issue field (5% increments) |
|
480 | 481 |
setting_issue_done_ratio_issue_status: Use the issue status |
481 | 482 |
setting_start_of_week: Start calendars on |
482 | 483 |
setting_rest_api_enabled: Enable REST web service |
test/functional/issues_controller_test.rb | ||
---|---|---|
8736 | 8736 |
end |
8737 | 8737 |
end |
8738 | 8738 |
end |
8739 | ||
8740 |
def test_get_new_with_issue_field_five_percent_increments |
|
8741 |
with_settings :issue_done_ratio => 'issue_field_5_percent_increments' do |
|
8742 |
@request.session[:user_id] = 1 |
|
8743 |
get :new |
|
8744 |
assert_response :success |
|
8745 | ||
8746 |
assert_select 'select#issue_done_ratio' do |
|
8747 |
assert_select 'option', count: 21 |
|
8748 |
assert_select 'option:nth-of-type(1)', text: '0 %' |
|
8749 |
assert_select 'option:nth-of-type(2)', text: '5 %' |
|
8750 |
assert_select 'option:nth-of-type(21)', text: '100 %' |
|
8751 |
end |
|
8752 |
end |
|
8753 |
end |
|
8739 | 8754 |
end |