Remove support to Marshal load Rails 5.x `ActiveModel::AttributeSet` format

This commit is contained in:
Rafael Mendonça França 2021-11-16 14:56:30 -05:00
parent 2996732089
commit 1f3cfb272c
No known key found for this signature in database
GPG Key ID: FC23B6D0F1EEE948
4 changed files with 9 additions and 20 deletions

View File

@ -1,3 +1,7 @@
* Remove support to Marshal load Rails 5.x `ActiveModel::AttributeSet` format.
*Rafael Mendonça França*
* Remove support to Marshal and YAML load Rails 5.x error format.
*Rafael Mendonça França*

View File

@ -144,16 +144,7 @@ module ActiveModel
end
def marshal_load(values)
if values.is_a?(Hash)
ActiveSupport::Deprecation.warn(<<~MSG)
Marshalling load from legacy attributes format is deprecated and will be removed in Rails 7.0.
MSG
empty_hash = {}.freeze
initialize(empty_hash, empty_hash, empty_hash, empty_hash, values)
@materialized = true
else
initialize(*values)
end
initialize(*values)
end
protected

View File

@ -232,7 +232,7 @@ module ActiveModel
assert_equal({ foo: "1" }, attributes.to_hash)
end
test "marshalling dump/load legacy materialized attribute hash" do
test "marshalling dump/load materialized attribute hash" do
builder = AttributeSet::Builder.new(foo: Type::String.new)
def builder.build_from_database(values = {}, additional_types = {})
@ -242,16 +242,8 @@ module ActiveModel
attributes = builder.build_from_database(foo: "1")
attributes.instance_variable_get(:@attributes).instance_eval do
class << self
def marshal_dump
materialize # legacy marshal format before Rails 5.1
end
end
end
data = Marshal.dump(attributes)
attributes = assert_deprecated { Marshal.load(data) }
attributes = Marshal.load(data)
assert_equal({ foo: "1" }, attributes.to_hash)
end

View File

@ -144,6 +144,8 @@ Please refer to the [Changelog][active-model] for detailed changes.
* Remove support to Marshal and YAML load Rails 5.x error format.
* Remove support to Marshal load Rails 5.x `ActiveModel::AttributeSet` format.
### Deprecations
### Notable changes