Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve html_safe? status on ActiveSupport::SafeBuffer#* #36012

Merged
merged 1 commit into from Apr 18, 2019

Conversation

r7kamura
Copy link
Contributor

Summary

separator = tag(:br) * 2 #=> "<br /><br />"
separator.html_safe? #=> `nil` on Rails 5.2.3, but it would be nice if this returns `true`.

Copy link
Member

@kamipo kamipo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good to me. Can you add CHANGELOG entry?

@@ -150,6 +150,14 @@ def test_titleize
assert_equal "hello&lt;&gt;", clean + @buffer
end

test "Should preserve html_safe? status on multiplication" do
multiplied_safe_buffer = "<br />".html_safe * 2
assert multiplied_safe_buffer.html_safe?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert multiplied_safe_buffer.html_safe?
assert_predicate multiplied_safe_buffer, :html_safe?

assert multiplied_safe_buffer.html_safe?

multiplied_unsafe_buffer = @buffer.gsub("", "<>") * 2
assert_not multiplied_unsafe_buffer.html_safe?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert_not multiplied_unsafe_buffer.html_safe?
assert_not_predicate multiplied_unsafe_buffer, :html_safe?

@r7kamura r7kamura force-pushed the feature/safe-buffer-multiplication branch from 56ca511 to 9dd254c Compare April 18, 2019 21:33
@r7kamura
Copy link
Contributor Author

Thanks. I rewrote the test code and added an entry to CHANGELOG.

@kamipo kamipo merged commit 4acddae into rails:master Apr 18, 2019
@kamipo
Copy link
Member

kamipo commented Apr 18, 2019

Thanks!

@r7kamura r7kamura deleted the feature/safe-buffer-multiplication branch April 18, 2019 22:19
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.

None yet

2 participants