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
journalize changes to the scheduling mode
ulferts3a3a48e26775
diff --git a/app/models/journal.rb b/app/models/journal.rbindex c569e32cb4e..fc601268d50 100644--- a/app/models/journal.rb+++ b/app/models/journal.rb@@ -37,6 +37,7 @@ class Journal < ApplicationRecordregister_journal_formatter :diff, OpenProject::JournalFormatter::Diffregister_journal_formatter :attachment, OpenProject::JournalFormatter::Attachmentregister_journal_formatter :custom_field, OpenProject::JournalFormatter::CustomField+ register_journal_formatter :schedule_manually, OpenProject::JournalFormatter::ScheduleManually# Make sure each journaled model instance only has unique version idsvalidates_uniqueness_of :version, scope: [:journable_id, :journable_type]diff --git a/app/models/work_package/journalized.rb b/app/models/work_package/journalized.rbindex 66d9c1bd7b9..1868d42c090 100644--- a/app/models/work_package/journalized.rb+++ b/app/models/work_package/journalized.rb@@ -93,6 +93,7 @@ module WorkPackage::Journalizedregister_on_journal_formatter(:fraction, 'derived_estimated_hours')register_on_journal_formatter(:decimal, 'done_ratio')register_on_journal_formatter(:diff, 'description')+ register_on_journal_formatter(:schedule_manually, 'schedule_manually')register_on_journal_formatter(:attachment, /attachments_?\d+/)register_on_journal_formatter(:custom_field, /custom_fields_\d+/)@@ -101,7 +102,6 @@ module WorkPackage::Journalized:status_id, :type_id,:assigned_to_id, :priority_id,:category_id, :version_id,- :planning_element_status_id,:author_id, :responsible_idregister_on_journal_formatter :datetime, :start_date, :due_dateregister_on_journal_formatter :plaintext, :subjectdiff --git a/config/locales/en.yml b/config/locales/en.ymlindex 3193cf8ad49..7ea9a52898d 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -543,7 +543,7 @@ en:parent_work_package: "Parent"priority: "Priority"progress: "Progress (%)"- schedule_manually: "Schedule manually"+ schedule_manually: "Manual scheduling"spent_hours: "Spent time"spent_time: "Spent time"subproject: "Subproject"@@ -2165,6 +2165,10 @@ en:warnings:cannot_annotate: "This file cannot be annotated."+ scheduling:+ activated: 'activated'+ deactivated: 'deactivated'+search_input_placeholder: "Search ..."setting_email_delivery_method: "Email delivery method"@@ -2377,6 +2381,7 @@ en:text_journal_deleted_with_diff: "%{label} deleted (%{link})"text_journal_set_to: "%{label} set to %{value}"text_journal_set_with_diff: "%{label} set (%{link})"+ text_journal_label_value: "%{label} %{value}"text_latest_note: "The latest comment is: %{note}"text_length_between: "Length between %{min} and %{max} characters."text_line_separated: "Multiple values allowed (one line for each value)."diff --git a/db/migrate/20200803081038_journalize_scheduling_mode.rb b/db/migrate/20200803081038_journalize_scheduling_mode.rbnew file mode 100644index 00000000000..0de970bc580--- /dev/null+++ b/db/migrate/20200803081038_journalize_scheduling_mode.rb@@ -0,0 +1,5 @@+class JournalizeSchedulingMode < ActiveRecord::Migration[6.0]+ def change+ add_column :work_package_journals, :schedule_manually, :boolean, default: false+ end+enddiff --git a/lib/open_project/journal_formatter/diff.rb b/lib/open_project/journal_formatter/diff.rbindex b23170e4b1f..315dcbec089 100644--- a/lib/open_project/journal_formatter/diff.rb+++ b/lib/open_project/journal_formatter/diff.rb@@ -55,12 +55,10 @@ class OpenProject::JournalFormatter::Diff < JournalFormatter::Baseif value.blank?l(:text_journal_deleted_with_diff, label: label, link: link)+ elsif old_value.present?+ l(:text_journal_changed_with_diff, label: label, link: link)else- if old_value.present?- l(:text_journal_changed_with_diff, label: label, link: link)- else- l(:text_journal_set_with_diff, label: label, link: link)- end+ l(:text_journal_set_with_diff, label: label, link: link)endenddiff --git a/lib/open_project/journal_formatter/schedule_manually.rb b/lib/open_project/journal_formatter/schedule_manually.rbnew file mode 100644index 00000000000..516f35252ae--- /dev/null+++ b/lib/open_project/journal_formatter/schedule_manually.rb@@ -0,0 +1,36 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2020 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2017 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See docs/COPYRIGHT.rdoc for more details.+#++++class OpenProject::JournalFormatter::ScheduleManually < JournalFormatter::Base+ def render(key, values, options = { no_html: false })+ label_text = options[:no_html] ? label(key) : content_tag('strong', label(key))+ activated_text = values.last ? I18n.t('scheduling.activated') : I18n.t('scheduling.deactivated')++ I18n.t(:text_journal_label_value, label: label_text, value: activated_text)+ end+enddiff --git a/lib/plugins/acts_as_journalized/lib/journal_formatter/attribute.rb b/lib/plugins/acts_as_journalized/lib/journal_formatter/attribute.rbindex f27b8347b45..0e2f084ae99 100644--- a/lib/plugins/acts_as_journalized/lib/journal_formatter/attribute.rb+++ b/lib/plugins/acts_as_journalized/lib/journal_formatter/attribute.rb@@ -22,11 +22,9 @@# You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-## See docs/COPYRIGHT.rdoc for more details.#++-module JournalFormatterclass Attribute < Baseprivatediff --git a/spec/features/work_packages/scheduling/scheduling_mode_spec.rb b/spec/features/work_packages/scheduling/scheduling_mode_spec.rbindex cc3d5ffc589..37275f9e6ef 100644--- a/spec/features/work_packages/scheduling/scheduling_mode_spec.rb+++ b/spec/features/work_packages/scheduling/scheduling_mode_spec.rb@@ -113,6 +113,9 @@ describe 'scheduling mode',work_packages_page.expect_and_dismiss_notification message: 'Successful update.'+ # Changing the scheduling mode is journalized+ work_packages_page.expect_activity_message("Manual scheduling activated")+expect_dates(wp, '2016-01-05', '2016-01-10')expect(wp.schedule_manually).to be_truthydiff --git a/spec/lib/journal_formatter/schedule_manually_spec.rb b/spec/lib/journal_formatter/schedule_manually_spec.rbnew file mode 100644index 00000000000..f0fb8cbc708--- /dev/null+++ b/spec/lib/journal_formatter/schedule_manually_spec.rb@@ -0,0 +1,61 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2020 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2017 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See docs/COPYRIGHT.rdoc for more details.+#++++require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')++describe OpenProject::JournalFormatter::ScheduleManually do+ let(:klass) { described_class }+ let(:id) { 1 }+ let(:journal) do+ OpenStruct.new(id: id, journable: WorkPackage.new)+ end+ let(:instance) { klass.new(journal) }+ let(:key) { 'schedule_manually' }++ describe '#render' do+ describe 'with the first value being true, and the second false' do+ let(:expected) do+ I18n.t(:text_journal_label_value,+ label: "<strong>Manual scheduling</strong>",+ value: 'deactivated')+ end++ it { expect(instance.render(key, [true, false])).to eq(expected) }+ end++ describe 'with the first value being false, and the second true' do+ let(:expected) do+ I18n.t(:text_journal_label_value,+ label: "<strong>Manual scheduling</strong>",+ value: 'activated')+ end++ it { expect(instance.render(key, [false, true])).to eq(expected) }+ end+ end+enddiff --git a/spec/models/work_package/work_package_acts_as_journalized_spec.rb b/spec/models/work_package/work_package_acts_as_journalized_spec.rbindex 5ea6c15ada5..bd5e4c27bd2 100644--- a/spec/models/work_package/work_package_acts_as_journalized_spec.rb+++ b/spec/models/work_package/work_package_acts_as_journalized_spec.rb@@ -69,11 +69,16 @@ describe WorkPackage, type: :model do.to match_array [nil, work_package.project_id]end- it 'notes the description to project' do+ it 'notes the description' doexpect(Journal.first.details[:description]).to match_array [nil, work_package.description]end+ it 'notes the scheduling mode' do+ expect(Journal.first.details[:schedule_manually])+ .to match_array [nil, false]+ end+it 'has the timestamp of the work package update time for created_at' do# This seemingly unnecessary reload leads to the updated_at having the same# precision as the created_at of the Journal. It is database dependent, so it would work without@@ -173,6 +178,7 @@ describe WorkPackage, type: :model dowork_package.assigned_to = User.currentwork_package.responsible = User.currentwork_package.parent = parent_work_package+ work_package.schedule_manually = truework_package.save!end@@ -183,7 +189,7 @@ describe WorkPackage, type: :model doit 'contains all changes' do%i(subject description type_id status_id priority_idstart_date due_date estimated_hours assigned_to_id- responsible_id parent_id).each do |a|+ responsible_id parent_id schedule_manually).each do |a|expect(subject).to have_key(a.to_s), "Missing change for #{a}"endend@@ -217,6 +223,22 @@ describe WorkPackage, type: :model doit_behaves_like 'new value'endend++ context 'schedule_manually' do+ let(:property) { 'schedule_manually' }++ context 'old_value' do+ let(:expected_value) { false }++ it_behaves_like 'old value'+ end++ context 'new value' do+ let(:expected_value) { true }++ it_behaves_like 'new value'+ end+ endenddescribe 'adding journal with a missing journal and an existing journal' do