From 01d09a6079b0af387c722ba2148cf7af308d3f49 Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Sun, 2 Sep 2012 17:19:50 +0200 Subject: set the configured #inheritance_column on #become (#7503) I had to create a new table because I needed an STI table, which does not have both a "type" and a "custom_type" the test fails with: 1) Error: test_alt_becomes_works_with_sti(InheritanceTest): NoMethodError: undefined method `type=' for # /Users/username/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:432:in `method_missing' /Users/username/Projects/rails/activerecord/lib/active_record/attribute_methods.rb:100:in `method_missing' /Users/username/Projects/rails/activerecord/lib/active_record/persistence.rb:165:in `becomes' test/cases/inheritance_test.rb:134:in `test_becomes_works_with_sti' test/cases/inheritance_test.rb:140:in `test_alt_becomes_works_with_sti' Conflicts: activerecord/test/cases/inheritance_test.rb --- activerecord/test/cases/inheritance_test.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'activerecord/test/cases/inheritance_test.rb') diff --git a/activerecord/test/cases/inheritance_test.rb b/activerecord/test/cases/inheritance_test.rb index fab858e09c..54c9152c06 100644 --- a/activerecord/test/cases/inheritance_test.rb +++ b/activerecord/test/cases/inheritance_test.rb @@ -2,9 +2,10 @@ require "cases/helper" require 'models/company' require 'models/project' require 'models/subscriber' +require 'models/vegetables' class InheritanceTest < ActiveRecord::TestCase - fixtures :companies, :projects, :subscribers, :accounts + fixtures :companies, :projects, :subscribers, :accounts, :vegetables def test_class_with_store_full_sti_class_returns_full_name old = ActiveRecord::Base.store_full_sti_class @@ -98,6 +99,13 @@ class InheritanceTest < ActiveRecord::TestCase switch_to_default_inheritance_column end + def test_alt_becomes_works_with_sti + vegetable = Vegetable.find(1) + assert_kind_of Vegetable, vegetable + cabbage = vegetable.becomes(Cabbage) + assert_kind_of Cabbage, cabbage + end + def test_inheritance_find_all companies = Company.find(:all, :order => 'id') assert_kind_of Firm, companies[0], "37signals should be a firm" -- cgit v1.2.3