Skip to content

Test truncate when omission is longer than truncate_to - #57541

Merged
rafaelfranca merged 1 commit into
rails:mainfrom
hammadxcm:test-truncate-omission-longer
Jun 2, 2026
Merged

rafaelfranca merged 1 commit into
rails:mainfrom
hammadxcm:test-truncate-omission-longer

Conversation

@hammadxcm

Copy link
Copy Markdown
Contributor

When the :omission string is longer than the requested length, String#truncate returns just the omission, so the result can exceed truncate_to — behavior the method documents ("The total length will not exceed truncate_to ... unless both text and :omission are longer than truncate_to"). Internally this is the branch where the offset goes negative, and it had no test.

This adds coverage for the omission-longer-than-truncate_to case. No production code changes — test-only.

When the :omission string is longer than the requested length,
String#truncate returns just the omission, so the result can exceed
truncate_to (as documented). This branch, where the internal offset
goes negative, had no test.

Add coverage for the omission-longer-than-truncate_to case.
@rafaelfranca
rafaelfranca merged commit 97765e9 into rails:main Jun 2, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants