diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 4767b8efa..82e1def84 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -10,9 +10,9 @@ nav_order: 6 ## main -* Fix segfault when Ruby coverage is enabled but template annotations are disabled. +* Fix segfaults when Ruby coverage is enabled. - *George Holborn* + *George Holborn*, *Joel Hawksley* * Add `protocol` parameter to `with_request_url` test helper to enable testing with HTTPS protocol. diff --git a/lib/view_component/template.rb b/lib/view_component/template.rb index ba15b1dc6..23ca0c5ee 100644 --- a/lib/view_component/template.rb +++ b/lib/view_component/template.rb @@ -65,7 +65,7 @@ def compiled_source result = super # Strip the annotation line to maintain correct line numbers when coverage # is running (avoids segfault from negative lineno) - result = result.sub(/\A[^\n]*\n/, "") if @strip_annotation_line + result = result.partition(";").last if @strip_annotation_line result end end diff --git a/test/sandbox/test/mailer_test.rb b/test/sandbox/test/mailer_test.rb index 04f3495ea..a114a5726 100644 --- a/test/sandbox/test/mailer_test.rb +++ b/test/sandbox/test/mailer_test.rb @@ -6,7 +6,6 @@ class MailerTest < ActionMailer::TestCase def test_rendering_component_in_an_action_mailer result = TestMailer.test_email.deliver_now.body.to_s assert_includes result, "
Hello world!
" - assert_includes result, "test_email.html.erb" end def test_rendering_component_in_an_action_mailer_with_asset_component