class InheritanceAttributeMappingTest
Public Instance Methods
test_polymorphic_associations_custom_type()
click to toggle source
# File activerecord/test/cases/inheritance_test.rb, line 604 def test_polymorphic_associations_custom_type startup = Startup.create! name: "a Startup" sponsor = Sponsor.create! sponsorable: startup assert_equal ["omg_inheritance_attribute_mapping_test/company"], ActiveRecord::Base.connection.select_values("SELECT sponsorable_type FROM sponsors") sponsor = Sponsor.first assert_equal startup, sponsor.sponsorable end
test_sti_with_custom_type()
click to toggle source
# File activerecord/test/cases/inheritance_test.rb, line 584 def test_sti_with_custom_type Startup.create! name: "a Startup" Empire.create! name: "an Empire" assert_equal [["a Startup", "omg_inheritance_attribute_mapping_test/startup"], ["an Empire", "omg_inheritance_attribute_mapping_test/empire"]], ActiveRecord::Base.connection.select_rows("SELECT name, type FROM companies").sort assert_equal [["a Startup", "InheritanceAttributeMappingTest::Startup"], ["an Empire", "InheritanceAttributeMappingTest::Empire"]], Company.all.map { |a| [a.name, a.type] }.sort startup = Startup.first startup.becomes! Empire startup.save! assert_equal [["a Startup", "omg_inheritance_attribute_mapping_test/empire"], ["an Empire", "omg_inheritance_attribute_mapping_test/empire"]], ActiveRecord::Base.connection.select_rows("SELECT name, type FROM companies").sort assert_equal [["a Startup", "InheritanceAttributeMappingTest::Empire"], ["an Empire", "InheritanceAttributeMappingTest::Empire"]], Company.all.map { |a| [a.name, a.type] }.sort end