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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
remove behind_schedule methods since they are unused
ulferts8d5b62b5cd5a
diff --git a/app/models/version.rb b/app/models/version.rbindex b2de329603a..94ddbc35c73 100644--- a/app/models/version.rb+++ b/app/models/version.rb@@ -100,17 +100,6 @@ class Version < ApplicationRecordeffective_date && (effective_date <= Date.today) && open_issues_count.zero?end- def behind_schedule?- if completed_percent == 100- false- elsif due_date && start_date- done_date = start_date + ((due_date - start_date + 1) * completed_percent / 100).floor- done_date <= Date.today- else- false # No issues so it's not late- end- end-# Returns the completion percentage of this version based on the amount of open/closed issues# and the time spent on the open issues.def completed_percentdiff --git a/app/models/work_package.rb b/app/models/work_package.rbindex 8da46d1c286..4b21d566709 100644--- a/app/models/work_package.rb+++ b/app/models/work_package.rb@@ -350,14 +350,6 @@ class WorkPackage < ApplicationRecordendend- # Is the amount of work done less than it should for the finish date- def behind_schedule?- return false if start_date.nil? || due_date.nil?-- done_date = start_date + (duration * done_ratio / 100).floor- done_date <= Date.today- end-# check if user is allowed to edit WorkPackage Journals.# see Acts::Journalized::Permissions#journal_editable_bydef journal_editable_by?(journal, user)diff --git a/spec/models/work_package/work_package_scheduling_spec.rb b/spec/models/work_package/work_package_scheduling_spec.rbindex b9bb62de59c..c1d94f0edf4 100644--- a/spec/models/work_package/work_package_scheduling_spec.rb+++ b/spec/models/work_package/work_package_scheduling_spec.rb@@ -85,65 +85,4 @@ describe WorkPackage, type: :model doit_behaves_like 'on time'endend-- describe '#behind_schedule?' do- let(:work_package) do- create(:work_package,- start_date: start_date,- due_date: due_date,- done_ratio: done_ratio)- end-- shared_examples_for 'behind schedule' do- subject { work_package.behind_schedule? }-- it { is_expected.to be_truthy }- end-- shared_examples_for 'in schedule' do- subject { work_package.behind_schedule? }-- it { is_expected.to be_falsey }- end-- context 'no start date' do- let(:start_date) { nil }- let(:due_date) { 1.day.from_now.to_date }- let(:done_ratio) { 0 }-- it_behaves_like 'in schedule'- end-- context 'no end date' do- let(:start_date) { 1.day.from_now.to_date }- let(:due_date) { nil }- let(:done_ratio) { 0 }-- it_behaves_like 'in schedule'- end-- context "more done than it's calendar time" do- let(:start_date) { 50.day.ago.to_date }- let(:due_date) { 50.day.from_now.to_date }- let(:done_ratio) { 90 }-- it_behaves_like 'in schedule'- end-- context 'not started' do- let(:start_date) { 1.day.ago.to_date }- let(:due_date) { 1.day.from_now.to_date }- let(:done_ratio) { 0 }-- it_behaves_like 'behind schedule'- end-- context "more done than it's calendar time" do- let(:start_date) { 100.day.ago.to_date }- let(:due_date) { Date.today }- let(:done_ratio) { 90 }-- it_behaves_like 'behind schedule'- end- endenddiff --git a/spec_legacy/unit/version_spec.rb b/spec_legacy/unit/version_spec.rbindex 8666afe35d4..d1d83458797 100644--- a/spec_legacy/unit/version_spec.rb+++ b/spec_legacy/unit/version_spec.rb@@ -145,58 +145,6 @@ describe Version, type: :model doassert_progress_equal 25.0 / 100.0 * 100, v.closed_percentend- context '#behind_schedule?' do- before do- ProjectCustomField.destroy_all # Custom values are a mess to isolate in tests- @project = create(:project, identifier: 'test0')- @project.types << create(:type)-- (@version = Version.new.tap do |v|- v.attributes = { project: @project, effective_date: nil, name: 'test' }- end).save!- end-- it 'should be false if there are no issues assigned' do- @version.update_attribute(:effective_date, Date.yesterday)- assert_equal false, @version.behind_schedule?- end-- it 'should be false if there is no effective_date' do- assert_equal false, @version.behind_schedule?- end-- it 'should be false if all of the issues are ahead of schedule' do- @version.update_attribute(:effective_date, 7.days.from_now.to_date)- @version.work_packages = [- create(:work_package, project: @project, start_date: 7.days.ago, done_ratio: 60), # 14 day span, 60% done, 50% time left- create(:work_package, project: @project, start_date: 7.days.ago, done_ratio: 60) # 14 day span, 60% done, 50% time left- ]- assert_equal 60, @version.completed_percent- assert_equal false, @version.behind_schedule?- 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.work_packages = [- create(:work_package, project: @project, start_date: 7.days.ago, done_ratio: 60), # 14 day span, 60% done, 50% time left- create(:work_package, project: @project, start_date: 7.days.ago, done_ratio: 20) # 14 day span, 20% done, 50% time left- ]- assert_equal 40, @version.completed_percent- assert_equal true, @version.behind_schedule?- end-- it 'should be false if all of the issues are complete' do- @version.update_attribute(:effective_date, 7.days.from_now.to_date)- @version.work_packages = [- create(:work_package, project: @project, start_date: 14.days.ago, done_ratio: 100, status: Status.find(5)), # 7 day span- create(:work_package, project: @project, start_date: 14.days.ago, done_ratio: 100, status: Status.find(5)) # 7 day span- ]- assert_equal 100, @version.completed_percent- assert_equal false, @version.behind_schedule?- end- end-context '#estimated_hours' dobefore do(@version = Version.new.tap do |v|