aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2014-06-22 13:55:59 +0200
committerYves Senn <yves.senn@gmail.com>2014-06-22 13:55:59 +0200
commitebf552bd2c0ac97c0b2a9943819368a352ce636c (patch)
treea79284295d22166e52122b124eb0ca3d224bd44d /activerecord/test/cases
parent1e122ff71dc65637bfbb0abf6e530af8af140345 (diff)
parent3e422e201de47c6158d2f60679604e51d2539dfb (diff)
downloadrails-ebf552bd2c0ac97c0b2a9943819368a352ce636c.tar.gz
rails-ebf552bd2c0ac97c0b2a9943819368a352ce636c.tar.bz2
rails-ebf552bd2c0ac97c0b2a9943819368a352ce636c.zip
Merge pull request #15849 from sgrif/sg-move-attributes
Move `attributes` to the `AttributeSet` object.
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/attribute_set_test.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/cases/attribute_set_test.rb b/activerecord/test/cases/attribute_set_test.rb
index 091f7e396a..e63d278650 100644
--- a/activerecord/test/cases/attribute_set_test.rb
+++ b/activerecord/test/cases/attribute_set_test.rb
@@ -45,5 +45,13 @@ module ActiveRecord
assert clone.frozen?
assert_not attributes.frozen?
end
+
+ test "to_hash returns a hash of the type cast values" do
+ builder = AttributeSet::Builder.new(foo: Type::Integer.new, bar: Type::Float.new)
+ attributes = builder.build_from_database(foo: '1.1', bar: '2.2')
+
+ assert_equal({ foo: 1, bar: 2.2 }, attributes.to_hash)
+ assert_equal({ foo: 1, bar: 2.2 }, attributes.to_h)
+ end
end
end