diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-28 15:36:16 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-28 15:36:16 -0300 |
commit | 092b92f1bdddc21d92c8e60d1eb112759beb790a (patch) | |
tree | 73354cb994a50e1be3de7a0bf49d5a403e82617f /activerecord/test | |
parent | fcf9b712b1dbbcb8f48644e6f20676ad9480ba66 (diff) | |
parent | c59e01a108b37ad74c9ed2e8fb022e27a9f95213 (diff) | |
download | rails-092b92f1bdddc21d92c8e60d1eb112759beb790a.tar.gz rails-092b92f1bdddc21d92c8e60d1eb112759beb790a.tar.bz2 rails-092b92f1bdddc21d92c8e60d1eb112759beb790a.zip |
Merge pull request #15389 from sgrif/sg-property-inheritance
Ensure custom properties work correctly with inheritance
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/custom_properties_test.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/activerecord/test/cases/custom_properties_test.rb b/activerecord/test/cases/custom_properties_test.rb index 9598f0299c..9910e4042c 100644 --- a/activerecord/test/cases/custom_properties_test.rb +++ b/activerecord/test/cases/custom_properties_test.rb @@ -6,6 +6,13 @@ class OverloadedType < ActiveRecord::Base property :non_existent_decimal, Type::Decimal.new end +class ChildOfOverloadedType < OverloadedType +end + +class GrandchildOfOverloadedType < ChildOfOverloadedType + property :overloaded_float, Type::Float.new +end + class UnoverloadedType < ActiveRecord::Base self.table_name = 'overloaded_types' end @@ -60,5 +67,17 @@ module ActiveRecord assert_nil data.overloaded_float assert unoverloaded_data.overloaded_float end + + def test_children_inherit_custom_properties + data = ChildOfOverloadedType.new(overloaded_float: '4.4') + + assert_equal 4, data.overloaded_float + end + + def test_children_can_override_parents + data = GrandchildOfOverloadedType.new(overloaded_float: '4.4') + + assert_equal 4.4, data.overloaded_float + end end end |