mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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.
This commit is contained in:
parent
4346102172
commit
98baa827ac
1 changed files with 14 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue