Defect #26506
closedUser link syntax causes an exception while sending email notification on Rails 5.1
Added by Go MAEDA over 7 years ago. Updated almost 7 years ago.
0%
Description
Steps to reproduce:
- Open "New issue" page.
- Enter something in the subject field.
- Enter "@admin" in the description field.
- Press "Create" button. You will see "NoMethodError" exception (please see the attached screenshot).
Affected version: r16859 and later
Files
NoMethodError@2x.png (45.1 KB) NoMethodError@2x.png | screenshot | Go MAEDA, 2017-07-24 05:33 | |
development.log (2.73 KB) development.log | Go MAEDA, 2017-07-24 05:38 |
Related issues
Updated by Marius BĂLTEANU over 7 years ago
Indeed, I'm able to reproduce the issue, but I'm not sure how to fix it.
Updated by Marius BĂLTEANU over 7 years ago
Adding "include Rails.application.routes.url_helpers" to ApplicationHelper fixes the issue, but still I'm not sure that is the best solution.
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index e14cff2..e28a446 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -29,6 +29,7 @@ module ApplicationHelper
include Redmine::Themes::Helper
include Redmine::Hook::Helper
include Redmine::Helpers::URL
+ include Rails.application.routes.url_helpers
extend Forwardable
def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter
Updated by Go MAEDA over 7 years ago
Marius BALTEANU wrote:
Adding "include Rails.application.routes.url_helpers" to ApplicationHelper fixes the issue, but still I'm not sure that is the best solution.
[...]
The issue was fixed by your patch.
Thank you for inspecting it so quickly.
Updated by Go MAEDA over 7 years ago
Go MAEDA wrote:
Marius BALTEANU wrote:
Adding "include Rails.application.routes.url_helpers" to ApplicationHelper fixes the issue, but still I'm not sure that is the best solution.
[...]
The issue was fixed by your patch.
Unfortunately some tests fail because of the fix.
$ ruby test/unit/helpers/application_helper_test.rb Run options: --seed 43089 # Running: ..............E Error: ApplicationHelperTest#test_due_date_distance_in_words: TypeError: no implicit conversion of Symbol into String app/helpers/application_helper.rb:276:in `due_date_distance_in_words' test/unit/helpers/application_helper_test.rb:1326:in `block in test_due_date_distance_in_words' test/unit/helpers/application_helper_test.rb:1325:in `each' test/unit/helpers/application_helper_test.rb:1325:in `test_due_date_distance_in_words' bin/rails test test/unit/helpers/application_helper_test.rb:1315 E Error: ApplicationHelperTest#test_table_of_content_should_generate_unique_anchors: I18n::ArgumentError: Object must be a Date, DateTime or Time object. :label_table_of_contents given. app/helpers/application_helper.rb:1130:in `block in replace_toc' app/helpers/application_helper.rb:1120:in `gsub!' app/helpers/application_helper.rb:1120:in `replace_toc' app/helpers/application_helper.rb:654:in `textilizable' test/unit/helpers/application_helper_test.rb:1206:in `test_table_of_content_should_generate_unique_anchors' bin/rails test test/unit/helpers/application_helper_test.rb:1182 .......E Error: ApplicationHelperTest#test_principals_options_for_select_should_include_me_option_when_current_user_is_in_collection: I18n::ArgumentError: Object must be a Date, DateTime or Time object. :label_me given. app/helpers/application_helper.rb:442:in `principals_options_for_select' test/unit/helpers/application_helper_test.rb:1462:in `test_principals_options_for_select_should_include_me_option_when_current_user_is_in_collection' bin/rails test test/unit/helpers/application_helper_test.rb:1458 .....................E Error: ApplicationHelperTest#test_table_of_content_should_contain_included_page_headings: I18n::ArgumentError: Object must be a Date, DateTime or Time object. :label_table_of_contents given. app/helpers/application_helper.rb:1130:in `block in replace_toc' app/helpers/application_helper.rb:1120:in `gsub!' app/helpers/application_helper.rb:1120:in `replace_toc' app/helpers/application_helper.rb:654:in `textilizable' test/unit/helpers/application_helper_test.rb:1230:in `test_table_of_content_should_contain_included_page_headings' bin/rails test test/unit/helpers/application_helper_test.rb:1212 ..E Error: ApplicationHelperTest#test_toc_with_textile_formatting_should_be_parsed: I18n::ArgumentError: Object must be a Date, DateTime or Time object. :label_table_of_contents given. app/helpers/application_helper.rb:1130:in `block in replace_toc' app/helpers/application_helper.rb:1120:in `gsub!' app/helpers/application_helper.rb:1120:in `replace_toc' app/helpers/application_helper.rb:654:in `textilizable' test/unit/helpers/application_helper_test.rb:1235:in `block in test_toc_with_textile_formatting_should_be_parsed' test/test_helper.rb:93:in `with_settings' test/unit/helpers/application_helper_test.rb:1234:in `test_toc_with_textile_formatting_should_be_parsed' bin/rails test test/unit/helpers/application_helper_test.rb:1233 E Error: ApplicationHelperTest#test_toc_with_markdown_formatting_should_be_parsed: I18n::ArgumentError: Object must be a Date, DateTime or Time object. :label_table_of_contents given. app/helpers/application_helper.rb:1130:in `block in replace_toc' app/helpers/application_helper.rb:1120:in `gsub!' app/helpers/application_helper.rb:1120:in `replace_toc' app/helpers/application_helper.rb:654:in `textilizable' test/unit/helpers/application_helper_test.rb:1244:in `block in test_toc_with_markdown_formatting_should_be_parsed' test/test_helper.rb:93:in `with_settings' test/unit/helpers/application_helper_test.rb:1243:in `test_toc_with_markdown_formatting_should_be_parsed' bin/rails test test/unit/helpers/application_helper_test.rb:1242 .....E Error: ApplicationHelperTest#test_principals_options_for_select_with_users_and_groups: I18n::ArgumentError: Object must be a Date, DateTime or Time object. :label_group_plural given. app/helpers/application_helper.rb:450:in `principals_options_for_select' test/unit/helpers/application_helper_test.rb:1451:in `test_principals_options_for_select_with_users_and_groups' bin/rails test test/unit/helpers/application_helper_test.rb:1445 ..........E Error: ApplicationHelperTest#test_table_of_content: I18n::ArgumentError: Object must be a Date, DateTime or Time object. :label_table_of_contents given. app/helpers/application_helper.rb:1130:in `block in replace_toc' app/helpers/application_helper.rb:1120:in `gsub!' app/helpers/application_helper.rb:1120:in `replace_toc' app/helpers/application_helper.rb:654:in `textilizable' test/unit/helpers/application_helper_test.rb:1179:in `test_table_of_content' bin/rails test test/unit/helpers/application_helper_test.rb:1118 ......E Error: ApplicationHelperTest#test_section_edit_links: I18n::ArgumentError: Object must be a Date, DateTime or Time object. :button_edit_section given. app/helpers/application_helper.rb:1031:in `block in parse_sections' app/helpers/application_helper.rb:1026:in `gsub!' app/helpers/application_helper.rb:1026:in `parse_sections' app/helpers/application_helper.rb:645:in `textilizable' test/unit/helpers/application_helper_test.rb:1276:in `test_section_edit_links' bin/rails test test/unit/helpers/application_helper_test.rb:1251 .....................E Error: ApplicationHelperTest#test_hours_formatting: I18n::ArgumentError: Object must be a Date, DateTime or Time object. :label_f_hour_short given. lib/redmine/i18n.rb:52:in `l_hours_short' test/unit/helpers/application_helper_test.rb:1594:in `block in test_hours_formatting' test/test_helper.rb:93:in `with_settings' test/unit/helpers/application_helper_test.rb:1592:in `test_hours_formatting' bin/rails test test/unit/helpers/application_helper_test.rb:1589 ............ Finished in 4.059187s, 26.6063 runs/s, 91.6440 assertions/s. 108 runs, 372 assertions, 0 failures, 10 errors, 0 skips
Updated by Jean-Philippe Lang over 7 years ago
- Status changed from New to Closed
- Assignee set to Jean-Philippe Lang
- Target version deleted (
4.0.0) - Resolution set to Fixed
This should be fixed in r16876 by using _url
helper instead of _path
like in other link_to_
methods. It also fixed that generated links to users were missing the host name.
Updated by Jean-Philippe Lang over 7 years ago
- Related to Feature #23630: Migrate to Rails 5.2 added
Updated by Marius BĂLTEANU over 7 years ago
Jean-Philippe Lang wrote:
This should be fixed in r16876 by using
_url
helper instead of_path
like in otherlink_to_
methods. It also fixed that generated links to users were missing the host name.
Thanks Jean-Philippe Lang for fixing this issue.
Updated by Andriy Lesyuk almost 7 years ago
Without this change user links in emails are invalid (as they are relative), so please include it into the very next release.