diff options
author | Sean Griffin <sean@thoughtbot.com> | 2014-05-26 17:06:05 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2014-05-30 08:51:58 -0700 |
commit | 5aa1f5d39987e176631fa9119d12e0aaabf98787 (patch) | |
tree | 8e8e2da8fd7ccadb3448c9cfe956610af41f57ae /activerecord/test/cases | |
parent | 8c77b0a086bb47ef7cd4b827460a51613f94094e (diff) | |
download | rails-5aa1f5d39987e176631fa9119d12e0aaabf98787.tar.gz rails-5aa1f5d39987e176631fa9119d12e0aaabf98787.tar.bz2 rails-5aa1f5d39987e176631fa9119d12e0aaabf98787.zip |
Allow specifying a default value in overloaded properties
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/custom_properties_test.rb | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/activerecord/test/cases/custom_properties_test.rb b/activerecord/test/cases/custom_properties_test.rb index 047c1b9b74..a406704114 100644 --- a/activerecord/test/cases/custom_properties_test.rb +++ b/activerecord/test/cases/custom_properties_test.rb @@ -4,6 +4,7 @@ class OverloadedType < ActiveRecord::Base property :overloaded_float, Type::Integer.new property :overloaded_string_with_limit, Type::String.new(limit: 50) property :non_existent_decimal, Type::Decimal.new + property :string_with_default, Type::String.new, default: 'the overloaded default' end class ChildOfOverloadedType < OverloadedType @@ -62,12 +63,12 @@ module ActiveRecord end end - def test_overloaded_properties_have_no_default + def test_changing_defaults data = OverloadedType.new unoverloaded_data = UnoverloadedType.new - assert_nil data.overloaded_float - assert unoverloaded_data.overloaded_float + assert_equal 'the overloaded default', data.string_with_default + assert_equal 'the original default', unoverloaded_data.string_with_default end def test_children_inherit_custom_properties @@ -84,7 +85,7 @@ module ActiveRecord def test_overloading_properties_does_not_change_column_order column_names = OverloadedType.column_names - assert_equal %w(id overloaded_float unoverloaded_float overloaded_string_with_limit non_existent_decimal), column_names + assert_equal %w(id overloaded_float unoverloaded_float overloaded_string_with_limit string_with_default non_existent_decimal), column_names end end end |