Deprecate SafeBuffer#clone_empty
This method is unused within the Rails codebase, the last caller was removed by 479c7cac in 2014 (Rails 4.2.0).
This commit is contained in:
parent
fc9470aa97
commit
4b6894168b
@ -1,3 +1,9 @@
|
||||
* Deprecate `SafeBuffer#clone_empty`.
|
||||
|
||||
This method has not been used internally since Rails 4.2.0.
|
||||
|
||||
*Mike Dalessio*
|
||||
|
||||
* `MessageEncryptor`, `MessageVerifier`, and `config.active_support.message_serializer`
|
||||
now accept `:message_pack` and `:message_pack_allow_marshal` as serializers.
|
||||
These serializers require the [`msgpack` gem](https://rubygems.org/gems/msgpack)
|
||||
|
@ -77,7 +77,10 @@ def initialize_copy(other)
|
||||
@html_safe = other.html_safe?
|
||||
end
|
||||
|
||||
def clone_empty
|
||||
def clone_empty # :nodoc:
|
||||
ActiveSupport.deprecator.warn <<~EOM
|
||||
ActiveSupport::SafeBuffer#clone_empty is deprecated and will be removed in Rails 7.2.
|
||||
EOM
|
||||
self[0, 0]
|
||||
end
|
||||
|
||||
|
@ -196,12 +196,18 @@ def test_titleize
|
||||
end
|
||||
|
||||
test "clone_empty returns an empty buffer" do
|
||||
assert_equal "", ActiveSupport::SafeBuffer.new("foo").clone_empty
|
||||
assert_deprecated(ActiveSupport.deprecator) do
|
||||
assert_equal "", ActiveSupport::SafeBuffer.new("foo").clone_empty
|
||||
end
|
||||
end
|
||||
|
||||
test "clone_empty keeps the original dirtiness" do
|
||||
assert_predicate @buffer.clone_empty, :html_safe?
|
||||
assert_not_predicate @buffer.gsub!("", "").clone_empty, :html_safe?
|
||||
assert_deprecated(ActiveSupport.deprecator) do
|
||||
assert_predicate @buffer.clone_empty, :html_safe?
|
||||
end
|
||||
assert_deprecated(ActiveSupport.deprecator) do
|
||||
assert_not_predicate @buffer.gsub!("", "").clone_empty, :html_safe?
|
||||
end
|
||||
end
|
||||
|
||||
test "Should be safe when sliced if original value was safe" do
|
||||
|
Loading…
Reference in New Issue
Block a user