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

@r7kamura r7kamura 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`.
kamipo
kamipo approved these changes Apr 18, 2019
Copy link
Member

@kamipo kamipo left a comment

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

Loading

@@ -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

@kamipo kamipo Apr 18, 2019

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?

Loading

assert multiplied_safe_buffer.html_safe?

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

@kamipo kamipo Apr 18, 2019

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?

Loading

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

@r7kamura r7kamura commented Apr 18, 2019

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

Loading

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

@kamipo kamipo commented Apr 18, 2019

Thanks!

Loading

@r7kamura r7kamura deleted the 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
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants