Skip to content

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

Fix white-space display in Journal diff (#16810)

Oliver Günther1cf80976e7a3
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index d7cca379cf7..fbeabfd68b2 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -180,13 +180,13 @@ module ApplicationHelper
def html_safe_gsub(string, *gsub_args, &)
html_safe = string.html_safe?
- string.gsub(*gsub_args, &)
+ result = string.gsub(*gsub_args, &)
# We only mark the string as safe if the previous string was already safe
if html_safe
- string.html_safe # rubocop:disable Rails/OutputSafety
+ result.html_safe # rubocop:disable Rails/OutputSafety
else
- string
+ result
end
end
diff --git a/spec/controllers/journals_controller_spec.rb b/spec/controllers/journals_controller_spec.rb
index 8119c8ab339..7742171fd3a 100644
--- a/spec/controllers/journals_controller_spec.rb
+++ b/spec/controllers/journals_controller_spec.rb
@@ -52,7 +52,7 @@ RSpec.describe JournalsController do
let(:params) { { id: work_package.last_journal.id.to_s, field: :description, format: "js" } }
before do
- work_package.update_attribute :description, "description"
+ work_package.update_attribute :description, "description\nmore changes"
end
describe "with a user having :view_work_package permission" do
@@ -62,7 +62,11 @@ RSpec.describe JournalsController do
expect(response.body.strip).to be_html_eql <<-HTML
<div class="text-diff">
<label class="hidden-for-sighted">Begin of the insertion</label>
- <ins class="diffmod">description</ins>
+ <ins class="diffmod">
+ description
+ <br/>
+ more changes
+ </ins>
<label class="hidden-for-sighted">End of the insertion</label>
</div>
HTML