Skip to content

Commit 9a6d5b6

Browse files
authored
Merge pull request #2556 from ViewComponent/fix-segfault-compiled-source
fix bug where part of template annotation line was not stripped
2 parents 5ded019 + 0e6dc1c commit 9a6d5b6

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

docs/CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ nav_order: 6
1010

1111
## main
1212

13-
* Fix segfault when Ruby coverage is enabled but template annotations are disabled.
13+
* Fix segfaults when Ruby coverage is enabled.
1414

15-
*George Holborn*
15+
*George Holborn*, *Joel Hawksley*
1616

1717
* Add `protocol` parameter to `with_request_url` test helper to enable testing with HTTPS protocol.
1818

lib/view_component/template.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def compiled_source
6565
result = super
6666
# Strip the annotation line to maintain correct line numbers when coverage
6767
# is running (avoids segfault from negative lineno)
68-
result = result.sub(/\A[^\n]*\n/, "") if @strip_annotation_line
68+
result = result.partition(";").last if @strip_annotation_line
6969
result
7070
end
7171
end

test/sandbox/test/mailer_test.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ class MailerTest < ActionMailer::TestCase
66
def test_rendering_component_in_an_action_mailer
77
result = TestMailer.test_email.deliver_now.body.to_s
88
assert_includes result, "<div>Hello world!</div>"
9-
assert_includes result, "test_email.html.erb"
109
end
1110

1211
def test_rendering_component_in_an_action_mailer_with_asset_component

0 commit comments

Comments
 (0)