Ticket #7284: AbstractClassAndInheritancePatch.diff
| File AbstractClassAndInheritancePatch.diff, 2.0 kB (added by BertG, 2 years ago) |
|---|
-
activerecord/test/inheritance_test.rb
old new 5 5 6 6 class InheritanceTest < Test::Unit::TestCase 7 7 fixtures :companies, :projects, :subscribers, :accounts 8 8 9 def test_company_descends_from_active_record 10 assert Company.descends_from_active_record?, 'Company should descend from ActiveRecord' 11 end 12 9 13 def test_a_bad_type_column 10 14 #SQLServer need to turn Identity Insert On before manually inserting into the Identity column 11 15 if current_adapter?(:SQLServerAdapter, :SybaseAdapter) -
activerecord/test/fixtures/company.rb
old new 1 class Company < ActiveRecord::Base 1 class AbstractCompany < ActiveRecord::Base 2 self.abstract_class = true 3 end 4 5 class Company < AbstractCompany 2 6 attr_protected :rating 3 7 set_sequence_name :companies_nonstd_seq 4 8 -
activerecord/lib/active_record/base.rb
old new 816 816 def human_attribute_name(attribute_key_name) #:nodoc: 817 817 attribute_key_name.humanize 818 818 end 819 820 def descends_from_active_record? # :nodoc: 821 superclass == Base || !columns_hash.include?(inheritance_column) 819 820 # Returns true when the class is the first non-abstract class to descend from ActiveRecord::Base 821 def descends_from_active_record? 822 if superclass.abstract_class? 823 superclass.descends_from_active_record? 824 else 825 superclass == Base || !columns_hash.include?(inheritance_column) 826 end 822 827 end 823 828 824 829