aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml18
-rw-r--r--actionpack/CHANGELOG.md4
-rw-r--r--activemodel/lib/active_model/attribute_set/builder.rb20
-rw-r--r--activemodel/test/cases/attribute_set_test.rb16
-rw-r--r--activestorage/app/models/active_storage/blob.rb2
5 files changed, 41 insertions, 19 deletions
diff --git a/.travis.yml b/.travis.yml
index 1f18478919..d783d6c97e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -60,9 +60,9 @@ env:
- "GEM=ac:integration"
rvm:
- - 2.2.8
- - 2.3.5
- - 2.4.2
+ - 2.2.9
+ - 2.3.6
+ - 2.4.3
- 2.5.0
- ruby-head
@@ -70,19 +70,19 @@ matrix:
include:
- rvm: 2.5.0
env: "GEM=av:ujs"
- - rvm: 2.2.8
+ - rvm: 2.2.9
env: "GEM=aj:integration"
services:
- memcached
- redis-server
- rabbitmq
- - rvm: 2.3.5
+ - rvm: 2.3.6
env: "GEM=aj:integration"
services:
- memcached
- redis-server
- rabbitmq
- - rvm: 2.4.2
+ - rvm: 2.4.3
env: "GEM=aj:integration"
services:
- memcached
@@ -100,15 +100,15 @@ matrix:
- memcached
- redis-server
- rabbitmq
- - rvm: 2.3.5
+ - rvm: 2.3.6
env:
- "GEM=ar:mysql2 MYSQL=mariadb"
addons:
mariadb: 10.2
- - rvm: 2.3.5
+ - rvm: 2.3.6
env:
- "GEM=ar:sqlite3_mem"
- - rvm: 2.3.5
+ - rvm: 2.3.6
env:
- "GEM=ar:postgresql POSTGRES=9.2"
addons:
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index 184ebecca9..0d10a9a3f2 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -1,3 +1,7 @@
+* Add alias method `to_hash` to `to_h` for `cookies`.
+ Add alias method `to_h` to `to_hash` for `session`.
+
+ *Igor Kasyanchuk*
Please check [5-2-stable](https://github.com/rails/rails/blob/5-2-stable/actionpack/CHANGELOG.md) for previous changes.
diff --git a/activemodel/lib/active_model/attribute_set/builder.rb b/activemodel/lib/active_model/attribute_set/builder.rb
index 758eb830fc..bf2d06b48a 100644
--- a/activemodel/lib/active_model/attribute_set/builder.rb
+++ b/activemodel/lib/active_model/attribute_set/builder.rb
@@ -22,12 +22,12 @@ module ActiveModel
class LazyAttributeHash # :nodoc:
delegate :transform_values, :each_key, :each_value, :fetch, :except, to: :materialize
- def initialize(types, values, additional_types, default_attributes)
+ def initialize(types, values, additional_types, default_attributes, delegate_hash = {})
@types = types
@values = values
@additional_types = additional_types
@materialized = false
- @delegate_hash = {}
+ @delegate_hash = delegate_hash
@default_attributes = default_attributes
end
@@ -76,15 +76,17 @@ module ActiveModel
end
def marshal_dump
- materialize
+ [@types, @values, @additional_types, @default_attributes, @delegate_hash]
end
- def marshal_load(delegate_hash)
- @delegate_hash = delegate_hash
- @types = {}
- @values = {}
- @additional_types = {}
- @materialized = true
+ def marshal_load(values)
+ if values.is_a?(Hash)
+ empty_hash = {}.freeze
+ initialize(empty_hash, empty_hash, empty_hash, empty_hash, values)
+ @materialized = true
+ else
+ initialize(*values)
+ end
end
protected
diff --git a/activemodel/test/cases/attribute_set_test.rb b/activemodel/test/cases/attribute_set_test.rb
index 9b323dae9d..b868dba743 100644
--- a/activemodel/test/cases/attribute_set_test.rb
+++ b/activemodel/test/cases/attribute_set_test.rb
@@ -217,6 +217,22 @@ module ActiveModel
assert_equal({ foo: "1" }, attributes.to_hash)
end
+ test "marshaling dump/load legacy materialized attribute hash" do
+ builder = AttributeSet::Builder.new(foo: Type::String.new)
+ attributes = builder.build_from_database(foo: "1")
+
+ attributes.instance_variable_get(:@attributes).instance_eval do
+ class << self
+ def marshal_dump
+ materialize
+ end
+ end
+ end
+
+ attributes = Marshal.load(Marshal.dump(attributes))
+ assert_equal({ foo: "1" }, attributes.to_hash)
+ end
+
test "#accessed_attributes returns only attributes which have been read" do
builder = AttributeSet::Builder.new(foo: Type::Value.new, bar: Type::Value.new)
attributes = builder.build_from_database(foo: "1", bar: "2")
diff --git a/activestorage/app/models/active_storage/blob.rb b/activestorage/app/models/active_storage/blob.rb
index 886fbb31e3..892a833fae 100644
--- a/activestorage/app/models/active_storage/blob.rb
+++ b/activestorage/app/models/active_storage/blob.rb
@@ -19,7 +19,7 @@ class ActiveStorage::Blob < ActiveRecord::Base
self.table_name = "active_storage_blobs"
has_secure_token :key
- store :metadata, accessors: [ :analyzed, :identified ], coder: JSON
+ store :metadata, accessors: [ :analyzed, :identified ], coder: ActiveRecord::Coders::JSON
class_attribute :service