diff options
author | chapmajs <glitch@glitchwrks.com> | 2013-04-30 23:11:49 -0300 |
---|---|---|
committer | Takehiro Adachi <takehiro0740@gmail.com> | 2013-06-26 14:55:18 +0900 |
commit | 839efc5b6d754697682d5b2bd34ef28b2c5d2adf (patch) | |
tree | 9c714d14456c766dd3441e4ef66d14f419f4ac86 /activerecord/test | |
parent | b23e0d66394a7c5442cc1ebbf4f1f2441878a8d2 (diff) | |
download | rails-839efc5b6d754697682d5b2bd34ef28b2c5d2adf.tar.gz rails-839efc5b6d754697682d5b2bd34ef28b2c5d2adf.tar.bz2 rails-839efc5b6d754697682d5b2bd34ef28b2c5d2adf.zip |
Allow global override of default STI inheritance column
This change fixes a bug by which 3.2-STABLE users can't globally override the default STI inheritance column with `ActiveRecord::Base.inheritance_column = 'some_column'`. 3.2-STABLE users are forced to use a deprecated method or monkey patch it otherwise.
Test case written by tkhr <takehiro0740@gmail.com>.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/inheritance_test.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/activerecord/test/cases/inheritance_test.rb b/activerecord/test/cases/inheritance_test.rb index 54c9152c06..99a252a389 100644 --- a/activerecord/test/cases/inheritance_test.rb +++ b/activerecord/test/cases/inheritance_test.rb @@ -290,3 +290,26 @@ class InheritanceComputeTypeTest < ActiveRecord::TestCase ActiveRecord::Base.store_full_sti_class = true end end + + +class GlobalInheritanceColumnTest < ActiveRecord::TestCase + fixtures :companies + + setup do + @inheritance_column = ActiveRecord::Base.inheritance_column + end + + teardown do + ActiveRecord::Base.inheritance_column = @inheritance_column + end + + def test_changing_global_inheritance_column + ActiveRecord::Base.inheritance_column = 'ruby_type' + + firm = Firm.create('name' => 'FirmWithAltInheritanceColumn') + assert_equal 'Firm', firm.ruby_type + + assert_equal 'ruby_type', Company.inheritance_column + assert_equal 'ruby_type', Firm.inheritance_column + end +end |