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

[#59925] fix specs

Tobias Dillmannc9d230d5800a
diff --git a/lib/open_project/object_linking.rb b/lib/open_project/object_linking.rb
index 15e3a5f358a..f46e20b9093 100644
--- a/lib/open_project/object_linking.rb
+++ b/lib/open_project/object_linking.rb
@@ -150,7 +150,9 @@ module OpenProject
if options.delete(:hover_card) { true }
options[clazz_key] = [options[clazz_key], "op-hover-card--preview-trigger"].compact.join(" ")
options[:data] ||= {}
- options[:data][:hover_card_url] = hover_card_user_path(user)
+ # This method is called from components that do not have direct access to the routes, so we make the call to
+ # the path helpers explicit:
+ options[:data][:hover_card_url] = Rails.application.routes.url_helpers.hover_card_user_path(user)
end
options
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index 580609b5236..7c6eb344793 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
@@ -176,8 +178,18 @@ RSpec.describe ApplicationHelper do
created = "2023-06-02"
author = build(:user, firstname: "<b>Hello</b>", lastname: "world")
author.save! validate: false
+
+ esc_name = "&lt;b&gt;Hello&lt;/b&gt; world"
+
+ exp_str = <<-HTML.squish
+ Added by
+ <a title="User #{esc_name}" class="op-hover-card--preview-trigger"
+ data-hover-card-url="/users/#{author.id}/hover_card" href="/users/#{author.id}">#{esc_name}</a>
+ at 2023-06-02
+ HTML
+
expect(authoring_at(created, author))
- .to eq("Added by <a href=\"/users/#{author.id}\">&lt;b&gt;Hello&lt;/b&gt; world</a> at 2023-06-02")
+ .to eq(exp_str)
end
end