From 8c67e709d0b2946473af84959deaac0ced962d5e Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Fri, 23 Dec 2011 12:52:57 +0000 Subject: [PATCH] Add test for inheritance from a non-AR superclass --- activerecord/test/cases/inclusion_test.rb | 8 ++++++++ activerecord/test/models/teapot.rb | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/activerecord/test/cases/inclusion_test.rb b/activerecord/test/cases/inclusion_test.rb index 07d538f6bc..d092e748e8 100644 --- a/activerecord/test/cases/inclusion_test.rb +++ b/activerecord/test/cases/inclusion_test.rb @@ -6,6 +6,14 @@ class BasicInclusionModelTest < ActiveRecord::TestCase Teapot.create!(:name => "Ronnie Kemper") assert_equal "Ronnie Kemper", Teapot.find(1).name end + + def test_inherited_model + teapot = CoolTeapot.create!(:name => "Bob") + teapot.reload + + assert_equal "Bob", teapot.name + assert_equal "mmm", teapot.aaahhh + end end class InclusionUnitTest < ActiveRecord::TestCase diff --git a/activerecord/test/models/teapot.rb b/activerecord/test/models/teapot.rb index 638a1b38f8..00e066a1b3 100644 --- a/activerecord/test/models/teapot.rb +++ b/activerecord/test/models/teapot.rb @@ -11,3 +11,14 @@ class Teapot include ActiveRecord::Model end + +class OMFGIMATEAPOT + def aaahhh + "mmm" + end +end + +class CoolTeapot < OMFGIMATEAPOT + include ActiveRecord::Model + self.table_name = "teapots" +end