Skip to content

Commit

Permalink
[50958] Stop copying estimated_hours to remaining_hours and vice versa
Browse files Browse the repository at this point in the history
It was limited to backlogs Task only, and was only updating if not set.
This is not desired anymore. Ideally, we'd like to eventually have them
always kept in sync, and for all work package types.
  • Loading branch information
cbliard committed Dec 5, 2023
1 parent 72d3967 commit 34bc774
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ module OpenProject::Backlogs::Patches::WorkPackagePatch
prepend InstanceMethods
extend ClassMethods

before_validation :backlogs_before_validation, if: -> { backlogs_enabled? }

register_journal_formatted_fields(:fraction, 'remaining_hours')
register_journal_formatted_fields(:fraction, 'derived_remaining_hours')
register_journal_formatted_fields(:decimal, 'story_points')
Expand Down Expand Up @@ -130,15 +128,6 @@ def backlogs_enabled?
def in_backlogs_type?
backlogs_enabled? && WorkPackage.backlogs_types.include?(type.try(:id))
end

private

def backlogs_before_validation
if type_id == Task.type
self.estimated_hours = remaining_hours if estimated_hours.blank? && remaining_hours.present?
self.remaining_hours = estimated_hours if remaining_hours.blank? && estimated_hours.present?
end
end
end
end

Expand Down
45 changes: 0 additions & 45 deletions modules/backlogs/spec/models/task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,49 +101,4 @@
end
end
end

describe 'copying remaining_hours to estimated_hours and vice versa' do
context 'providing only remaining_hours' do
before do
task.remaining_hours = 3

task.save!
end

it 'copies to estimated_hours' do
expect(task.estimated_hours)
.to eql task.remaining_hours
end
end

context 'providing only estimated_hours' do
before do
task.estimated_hours = 3

task.save!
end

it 'copies to estimated_hours' do
expect(task.remaining_hours)
.to eql task.estimated_hours
end
end

context 'providing estimated_hours and remaining_hours' do
before do
task.estimated_hours = 3
task.remaining_hours = 5

task.save!
end

it 'leaves the values unchanged' do
expect(task.remaining_hours)
.to be 5.0

expect(task.estimated_hours)
.to be 3.0
end
end
end
end

0 comments on commit 34bc774

Please sign in to comment.