Vote #78664
完了User link syntax causes an exception while sending email notification on Rails 5.1
0%
説明
journals
--------------------------------------------------------------------------------
Indeed, I'm able to reproduce the issue, but I'm not sure how to fix it.
--------------------------------------------------------------------------------
Adding "include Rails.application.routes.url_helpers" to ApplicationHelper fixes the issue, but still I'm not sure that is the best solution.
<pre><code class="diff">
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
</code></pre>
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------
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.
{{collapse(error log)
<pre>
$ 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
</pre>
}}
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Jean-Philippe Lang wrote:
> 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.
Thanks Jean-Philippe Lang for fixing this issue.
--------------------------------------------------------------------------------
Without this change user links in emails are invalid (as they are relative), so please include it into the very next release.
--------------------------------------------------------------------------------
related_issues
relates,Closed,23630,Migrate to Rails 5.2