Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Remove magic start_date applied to version, but not saved to DB

Oliver Güntherfa25c0ec215e
diff --git a/app/models/version.rb b/app/models/version.rb
index 35c63ad4c66..98207a66f05 100644
--- a/app/models/version.rb
+++ b/app/models/version.rb
@@ -72,17 +72,6 @@ class Version < ActiveRecord::Base
user.allowed_to?(:view_work_packages, project)
end
- # When a version started.
- #
- # Can either be a set date stored in the database or a dynamic one
- # based on the earlist start_date of the fixed_issues
- def start_date
- # when self.id is nil (e.g. when self is a new_record),
- # minimum('start_date') works on all issues with fixed_version: nil
- # but we expect only issues belonging to this version
- read_attribute(:start_date) || fixed_issues.where(WorkPackage.arel_table[:fixed_version_id].not_eq(nil)).minimum('start_date')
- end
-
def due_date
effective_date
end
diff --git a/spec_legacy/unit/version_spec.rb b/spec_legacy/unit/version_spec.rb
index 97c550a9f54..725d38960db 100644
--- a/spec_legacy/unit/version_spec.rb
+++ b/spec_legacy/unit/version_spec.rb
@@ -49,19 +49,6 @@ describe Version, type: :model do
end
context '#start_date' do
- context 'with no value saved' do
- it 'should be the date of the earlist issue' do
- project = Project.find(1)
- (v = Version.new.tap do |v|
- v.attributes = { project: project, name: 'Progress' }
- end).save!
- add_work_package(v, estimated_hours: 10, start_date: '2010-03-01')
- FactoryBot.create(:work_package, project: project, subject: 'not assigned', start_date: '2010-01-01')
-
- assert_equal '2010-03-01', v.start_date.to_s
- end
- end
-
context 'with a value saved' do
it 'should be the value' do
project = Project.find(1)
@@ -191,6 +178,7 @@ describe Version, type: :model do
end
it 'should be true if any of the issues are behind schedule' do
+ @version.update_attribute(:start_date, 7.days.ago.to_date)
@version.update_attribute(:effective_date, 7.days.from_now.to_date)
@version.fixed_issues = [
FactoryBot.create(:work_package, project: @project, start_date: 7.days.ago, done_ratio: 60), # 14 day span, 60% done, 50% time left