diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2016-05-31 09:56:19 -0400 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2016-05-31 10:03:26 -0400 |
commit | ff4986b917f6cc64398e2ba687f998fc52cf630c (patch) | |
tree | 23e0fd76336473d594cafde4b995fbc6581c3c7c /activerecord/test/cases/aggregations_test.rb | |
parent | 998bbbcc0e043e16b96613387cdb8f0ee4784ff2 (diff) | |
download | rails-ff4986b917f6cc64398e2ba687f998fc52cf630c.tar.gz rails-ff4986b917f6cc64398e2ba687f998fc52cf630c.tar.bz2 rails-ff4986b917f6cc64398e2ba687f998fc52cf630c.zip |
Ensure hashes can be passed to attributes using `composed_of`
This behavior was broken by 36e9be85. When the value is assigned
directly, either through mass assignment or directly assigning a hash,
the hash gets passed through to this writer method directly. While this
is intended to handle certain cases, when an explicit converter has been
provided, we should continue to use that instead. The positioning of the
added guard caused the new behavior to override that case.
Fixes #25210
Diffstat (limited to 'activerecord/test/cases/aggregations_test.rb')
-rw-r--r-- | activerecord/test/cases/aggregations_test.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/test/cases/aggregations_test.rb b/activerecord/test/cases/aggregations_test.rb index 5536702f58..8a728902a8 100644 --- a/activerecord/test/cases/aggregations_test.rb +++ b/activerecord/test/cases/aggregations_test.rb @@ -138,6 +138,11 @@ class AggregationsTest < ActiveRecord::TestCase assert_equal 'Barnoit GUMBLEAU', customers(:barney).fullname.to_s assert_kind_of Fullname, customers(:barney).fullname end + + def test_assigning_hash_to_custom_converter + customers(:barney).fullname = { first: "Barney", last: "Stinson" } + assert_equal "Barney STINSON", customers(:barney).name + end end class OverridingAggregationsTest < ActiveRecord::TestCase |