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
WIP: Add project journal attribute for identifier
Mir Bhatia604de7f88394
diff --git a/app/models/journal.rb b/app/models/journal.rbindex ed672f249b5..dd6a0fd07b8 100644--- a/app/models/journal.rb+++ b/app/models/journal.rb@@ -41,6 +41,8 @@ class Journal < ApplicationRecordregister_journal_formatter :ignore_non_working_days, OpenProject::JournalFormatter::IgnoreNonWorkingDaysregister_journal_formatter :active_status, OpenProject::JournalFormatter::ActiveStatusregister_journal_formatter :template, OpenProject::JournalFormatter::Template+ register_journal_formatter :identifier, OpenProject::JournalFormatter::Identifier+# Make sure each journaled model instance only has unique version idsdiff --git a/app/models/project.rb b/app/models/project.rbindex db79e0523d1..ac37aba8a49 100644--- a/app/models/project.rb+++ b/app/models/project.rb@@ -106,6 +106,7 @@ class Project < ApplicationRecordregister_on_journal_formatter(:active_status, 'active')register_on_journal_formatter(:template, 'templated')+ register_on_journal_formatter(:identifier, 'identifier')has_paper_traildiff --git a/lib/open_project/journal_formatter/identifier.rb b/lib/open_project/journal_formatter/identifier.rbnew file mode 100644index 00000000000..bd4f1774c87--- /dev/null+++ b/lib/open_project/journal_formatter/identifier.rb@@ -0,0 +1,37 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2023 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-2013 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 COPYRIGHT and LICENSE files for more details.+#++++class OpenProject::JournalFormatter::Identifier < JournalFormatter::Base+ def render(_key, values, options = { html: true })+ binding.pry+ label_text = options[:html] ? content_tag('strong', "Template:") : "Template:"+ activated_text = values.last ? "Project un-marked as template" : "Project marked as template"++ I18n.t(:text_journal_label_value, label: label_text, value: activated_text)+ end+enddiff --git a/spec/lib/journal_formatter/identifier_spec.rb b/spec/lib/journal_formatter/identifier_spec.rbnew file mode 100644index 00000000000..9720d401974--- /dev/null+++ b/spec/lib/journal_formatter/identifier_spec.rb@@ -0,0 +1,41 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2023 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-2013 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 COPYRIGHT and LICENSE files for more details.+#++++require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')++describe OpenProject::JournalFormatter::Identifier do+ let(:instance) { described_class.new(build(:journal)) }++ it "renders correctly when identifier is changed" do+ html = instance.render("templated", [false, true], html: true)+ expect(html).to eq("<strong>Identifier</strong> changed to []")++ html = instance.render("templated", [false, true], html: false)+ expect(html).to eq("Identifier changed to []")+ end+end