From e3e95d12627a5072122c5b04953d40dd88a17209 Mon Sep 17 00:00:00 2001 From: ulferts Date: Wed, 4 Dec 2024 11:13:32 +0100 Subject: [PATCH] improve robustness of activity back url --- app/helpers/journals_helper.rb | 3 ++- spec/helpers/journals_helper_spec.rb | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/helpers/journals_helper.rb b/app/helpers/journals_helper.rb index 85217057380e..821798a5cec2 100644 --- a/app/helpers/journals_helper.rb +++ b/app/helpers/journals_helper.rb @@ -38,7 +38,8 @@ def back_to_activity_page_url(activity_page) in ["users", user_id] user_url(user_id) in ["work_packages", work_package_id] - work_package_url(work_package_id) + # Sometimes the parameter provided is erroneous (having an extra ') for unknown reasons. + work_package_url(work_package_id.chomp("'")) else nil end diff --git a/spec/helpers/journals_helper_spec.rb b/spec/helpers/journals_helper_spec.rb index fb9dcba080e3..8910302da9a3 100644 --- a/spec/helpers/journals_helper_spec.rb +++ b/spec/helpers/journals_helper_spec.rb @@ -38,6 +38,8 @@ "unsupported_gizmo" => nil, "users/5" => "http://test.host/users/5", "work_packages/42" => "http://test.host/work_packages/42", + # Sometimes the url is erroneous (having an extra ') for unknown reasons. + "work_packages/42'" => "http://test.host/work_packages/42", nil => nil }.each do |activity_page, expected_url| context "when activity page is #{activity_page.inspect}" do