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

commented Apr 18, 2019

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`.

@rails-bot rails-bot bot added the activesupport label Apr 18, 2019

@kamipo

kamipo approved these changes Apr 18, 2019

Copy link
Member

left a comment

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?

This comment has been minimized.

Copy link
@kamipo

kamipo Apr 18, 2019

Member
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?

This comment has been minimized.

Copy link
@kamipo

kamipo Apr 18, 2019

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

@r7kamura r7kamura force-pushed the r7kamura:feature/safe-buffer-multiplication branch from 56ca511 to 9dd254c Apr 18, 2019

@r7kamura

This comment has been minimized.

Copy link
Contributor Author

commented Apr 18, 2019

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

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

2 checks passed

buildkite/rails Build #60580 passed (14 minutes, 26 seconds)
Details
codeclimate All good!
Details
@kamipo

This comment has been minimized.

Copy link
Member

commented Apr 18, 2019

Thanks!

@r7kamura r7kamura deleted the r7kamura:feature/safe-buffer-multiplication branch Apr 18, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.