WorkPackage: Don't update parent done_ratio if done_ratio is disabled

The change would appear in the journal and would thus be visible.

Since WorkPackage already knows about the setting, this seems a nicer
solution than preventing the journal from displaying the field.
pull/423/head
Michael Frister 11 years ago
parent a12bbb2fa1
commit 7093a6830e
  1. 2
      app/models/work_package.rb
  2. 1
      doc/CHANGELOG.md
  3. 6
      spec/factories/issue_status_factory.rb
  4. 24
      spec/models/work_package_spec.rb

@ -648,6 +648,8 @@ class WorkPackage < ActiveRecord::Base
end
def inherit_done_ratio_from_leaves
return if Setting.issue_done_ratio == 'disabled'
# done ratio = weighted average ratio of leaves
unless WorkPackage.use_status_for_done_ratio? && status && status.default_done_ratio
leaves_count = leaves.count

@ -27,6 +27,7 @@ See doc/COPYRIGHT.rdoc for more details.
* `#1898` Separate action for changing wiki parent page (was same as rename before)
* `#1923` Add permission that allows hiding repository statistics on commits per author
* `#1950` Grey line near the lower end of the modal, cuts off a bit of the content
* `#1921` Allow disabling done ratio for work packages
## 3.0.0pre15

@ -14,9 +14,13 @@ FactoryGirl.define do
sequence(:name) { |n| "status #{n}" }
is_closed false
factory :closed_issue_status do
is_closed true
end
factory :default_issue_status do
is_default true
end
end
end

@ -1230,4 +1230,28 @@ describe WorkPackage do
end
end
end
describe :inherit_done_ratio_from_leaves do
describe 'with done ratio disabled' do
let(:project) { FactoryGirl.create(:project) }
let(:work_package) { FactoryGirl.create(:work_package, :project => project) }
let(:child) { FactoryGirl.create(:work_package, :parent => work_package,
:project => project)}
let(:closed_issue_status) { FactoryGirl.create(:closed_issue_status) }
before do
Setting.stub(:issue_done_ratio).and_return('disabled')
end
it 'should not update the work package done_ratio' do
work_package.done_ratio.should == 0
child.status = closed_issue_status
child.save!
work_package.reload
work_package.done_ratio.should == 0
end
end
end
end

Loading…
Cancel
Save