diff options
author | Godfrey Chan <godfreykfc@gmail.com> | 2014-08-17 11:59:46 -0700 |
---|---|---|
committer | Godfrey Chan <godfreykfc@gmail.com> | 2014-08-17 11:59:46 -0700 |
commit | a5e2d2ef8565a96ed915afe734f67b604fa48450 (patch) | |
tree | ede6951a5532f2acab505af4cc27b72858ffacd3 /activerecord/test | |
parent | b662273df3d546a1fdd2de79005fd802f0e12643 (diff) | |
parent | 2638d5c72444db1dc73c0593cb35f9916fc6284c (diff) | |
download | rails-a5e2d2ef8565a96ed915afe734f67b604fa48450.tar.gz rails-a5e2d2ef8565a96ed915afe734f67b604fa48450.tar.bz2 rails-a5e2d2ef8565a96ed915afe734f67b604fa48450.zip |
Merge pull request #16458 from chancancode/ar_fix_reserved_inheritance
Fixed issue w/custom accessors + reserved name + inheritance
Conflicts:
activerecord/CHANGELOG.md
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/attribute_methods_test.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb index 535928783f..b4917e727a 100644 --- a/activerecord/test/cases/attribute_methods_test.rb +++ b/activerecord/test/cases/attribute_methods_test.rb @@ -810,6 +810,24 @@ class AttributeMethodsTest < ActiveRecord::TestCase assert_equal "lol", topic.author_name end + def test_inherited_custom_accessors_with_reserved_names + klass = Class.new(ActiveRecord::Base) do + self.table_name = 'computers' + self.abstract_class = true + def system; "omg"; end + def system=(val); self.developer = val; end + end + + subklass = Class.new(klass) + [klass, subklass].each(&:define_attribute_methods) + + computer = subklass.find(1) + assert_equal "omg", computer.system + + computer.developer = 99 + assert_equal 99, computer.developer + end + def test_on_the_fly_super_invokable_generated_attribute_methods_via_method_missing klass = new_topic_like_ar_class do def title |