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
Update incorrect spec and pass it
Mir Bhatia3fe2a6b81f0e
diff --git a/app/models/journal.rb b/app/models/journal.rbindex 419d48f9c38..bb6a4c3b53e 100644--- a/app/models/journal.rb+++ b/app/models/journal.rb@@ -44,6 +44,7 @@ class Journal < ApplicationRecordregister_journal_formatter :template, OpenProject::JournalFormatter::Templateregister_journal_formatter :visibility, OpenProject::JournalFormatter::Visibilityregister_journal_formatter :subproject_named_association, OpenProject::JournalFormatter::SubprojectNamedAssociation+ register_journal_formatter :subproject_plaintext, OpenProject::JournalFormatter::SubprojectPlaintext# Make sure each journaled model instance only has unique version idsvalidates :version, uniqueness: { scope: %i[journable_id journable_type] }diff --git a/app/models/project.rb b/app/models/project.rbindex 15d38d18df4..c402cc8323f 100644--- a/app/models/project.rb+++ b/app/models/project.rb@@ -106,8 +106,8 @@ class Project < ApplicationRecordregister_journal_formatted_fields(:active_status, 'active')register_journal_formatted_fields(:template, 'templated')- register_journal_formatted_fields(:plaintext, 'identifier')- register_journal_formatted_fields(:plaintext, 'name')+ register_journal_formatted_fields(:subproject_plaintext, 'identifier')+ register_journal_formatted_fields(:subproject_plaintext, 'name')register_journal_formatted_fields(:diff, 'description')register_journal_formatted_fields(:visibility, 'public')register_journal_formatted_fields(:subproject_named_association, 'parent_id')diff --git a/config/locales/en.yml b/config/locales/en.ymlindex 58e56ba2fd5..3f65aea7565 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -2841,11 +2841,12 @@ en:text_work_packages_ref_in_commit_messages: "Referencing and fixing work packages in commit messages"text_journal_added: "%{label} %{value} added"text_journal_changed_html: "%{label} changed from %{old} %{linebreak}<strong>to</strong> %{new}"+ text_journal_changed_html_project_activity: "%{label} changed from %{old} %{linebreak}to %{new}"text_journal_changed_plain: "%{label} changed from %{old} %{linebreak}to %{new}"text_journal_changed_no_detail: "%{label} updated"text_journal_changed_with_diff: "%{label} changed (%{link})"text_journal_deleted: "%{label} deleted (%{old})"- text_journal_deleted_custom_subproject: "%{label} (%{old})"+ text_journal_deleted_custom_subproject: "%{label} %{old}"text_journal_deleted_with_diff: "%{label} deleted (%{link})"text_journal_of: "%{label} %{value}"text_journal_set_to: "%{label} set to %{value}"diff --git a/lib/open_project/journal_formatter/subproject_named_association.rb b/lib/open_project/journal_formatter/subproject_named_association.rbindex fa7895edf2e..420d88d5691 100644--- a/lib/open_project/journal_formatter/subproject_named_association.rb+++ b/lib/open_project/journal_formatter/subproject_named_association.rb@@ -42,6 +42,15 @@ class OpenProject::JournalFormatter::SubprojectNamedAssociation < JournalFormatt[label, old_value, value]end+ def format_html_details(label, old_value, value)+ label = content_tag(:strong, label)+ old_value = content_tag('i', h(old_value)) if old_value.present?+ value = content_tag('i', h(value)) if value.present?+ value ||= ''++ [label, old_value, value]+ end+def render_ternary_detail_text(label, value, old_value, options)return I18n.t(:text_journal_deleted_custom_subproject, label:, old: old_value) if value.blank?return I18n.t(:text_journal_of, label:, value:) if old_value.blank?@@ -49,7 +58,7 @@ class OpenProject::JournalFormatter::SubprojectNamedAssociation < JournalFormattlinebreak = should_linebreak?(old_value.to_s, value.to_s)if options[:html]- I18n.t(:text_journal_changed_html,+ I18n.t(:text_journal_changed_html_project_activity,label:,linebreak: linebreak ? "<br/>".html_safe : '',old: old_value,diff --git a/lib/open_project/journal_formatter/subproject_plaintext.rb b/lib/open_project/journal_formatter/subproject_plaintext.rbnew file mode 100644index 00000000000..8fd60313079--- /dev/null+++ b/lib/open_project/journal_formatter/subproject_plaintext.rb@@ -0,0 +1,51 @@+#-- 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::SubprojectPlaintext < JournalFormatter::Base+ private++ def render_ternary_detail_text(label, value, old_value, options)+ return I18n.t(:text_journal_deleted, label:, old: old_value) if value.blank?+ return I18n.t(:text_journal_set_to, label:, value:) if old_value.blank?++ linebreak = should_linebreak?(old_value.to_s, value.to_s)++ if options[:html]+ I18n.t(:text_journal_changed_html_project_activity,+ label:,+ linebreak: linebreak ? "<br/>".html_safe : '',+ old: old_value,+ new: value)+ else+ I18n.t(:text_journal_changed_plain,+ label:,+ linebreak: linebreak ? "\n" : '',+ old: old_value,+ new: value)+ end+ end+enddiff --git a/spec/models/journal/project_journal_spec.rb b/spec/models/journal/project_journal_spec.rbindex 8a42c6ba87f..247bfde4538 100644--- a/spec/models/journal/project_journal_spec.rb+++ b/spec/models/journal/project_journal_spec.rb@@ -43,7 +43,7 @@ RSpec.describe Journal::ProjectJournal dohtml = journal.render_detail(['identifier', ['my-project', 'my-beautiful-project']], html: true)expect(html).to eq('<strong>Identifier</strong> changed from <i>my-project</i> ' \- '<strong>to</strong> <i>my-beautiful-project</i>')+ 'to <i>my-beautiful-project</i>')html = journal.render_detail(['identifier', ['my-project', 'my-beautiful-project']], html: false)expect(html).to eq('Identifier changed from my-project to my-beautiful-project')@@ -59,7 +59,7 @@ RSpec.describe Journal::ProjectJournal dohtml = journal.render_detail(['name', ['Old Project Name', 'New Project Name']], html: true)expect(html).to eq('<strong>Name</strong> changed from <i>Old Project Name</i> ' \- '<strong>to</strong> <i>New Project Name</i>')+ 'to <i>New Project Name</i>')html = journal.render_detail(['name', ['Old Project Name', 'New Project Name']], html: false)expect(html).to eq('Name changed from Old Project Name to New Project Name')@@ -79,15 +79,15 @@ RSpec.describe Journal::ProjectJournal do# Changeexpect(journal.render_detail(['parent_id', [previous_parent.id, parent.id]], html: true)).to eq('<strong>Subproject</strong> changed ' \- "from <i>#{previous_parent.name}</i> <strong>to</strong> <i>#{parent.name}</i>")+ "from <i>#{previous_parent.name}</i> to <i>#{parent.name}</i>")expect(journal.render_detail(['parent_id', [previous_parent.id, parent.id]], html: false)).to eq("Subproject changed from #{previous_parent.name} to #{parent.name}")# Deleteexpect(journal.render_detail(['parent_id', [parent.id, nil]], html: true))- .to eq("<strong>No longer subproject of</strong> (<strike><i>#{parent.name}</i></strike>)")+ .to eq("<strong>No longer subproject of</strong> <i>#{parent.name}</i>")expect(journal.render_detail(['parent_id', [parent.id, nil]], html: false))- .to eq("No longer subproject of (#{parent.name})")+ .to eq("No longer subproject of #{parent.name}")endendend