From 98baa827ac5e3a7e0fd427febed066d013198371 Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Wed, 7 May 2014 17:57:52 +0200 Subject: [PATCH] test, persist inherited class with different table name. Refs #14971. This case prevents against regressions. The change was suggested in a recent PR but the all our tests passed. --- activerecord/test/cases/persistence_test.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/activerecord/test/cases/persistence_test.rb b/activerecord/test/cases/persistence_test.rb index 823146b399..5d963098fb 100644 --- a/activerecord/test/cases/persistence_test.rb +++ b/activerecord/test/cases/persistence_test.rb @@ -1,4 +1,5 @@ require "cases/helper" +require 'models/aircraft' require 'models/post' require 'models/comment' require 'models/author' @@ -829,4 +830,17 @@ class PersistenceTest < ActiveRecord::TestCase end end + def test_persist_inherited_class_with_different_table_name + minimalistic_aircrafts = Class.new(Minimalistic) do + self.table_name = "aircraft" + end + + assert_difference "Aircraft.count", 1 do + aircraft = minimalistic_aircrafts.create(name: "Wright Flyer") + aircraft.name = "Wright Glider" + aircraft.save + end + + assert_equal "Wright Glider", Aircraft.last.name + end end