From fa25c0ec215ee2dca8c3b7fd812aeba3f7936d0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Thu, 13 Feb 2020 13:19:20 +0100 Subject: [PATCH] Remove magic start_date applied to version, but not saved to DB [ci skip] --- app/models/version.rb | 11 ----------- spec_legacy/unit/version_spec.rb | 14 +------------- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/app/models/version.rb b/app/models/version.rb index 35c63ad4c6..98207a66f0 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 97c550a9f5..725d38960d 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