mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Restore autoloading test for STI
This commit restores the test deleted in
fc7c029467
Active Record should not test things about autoloading, this would
belong to the railties test suite probably. However, there, it feels
a bit too distant from here.
Imperfect, but on a second thought I believe this trade-off is better.
This commit is contained in:
parent
e933dc0b84
commit
194866854f
1 changed files with 14 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "active_support/inflector"
|
||||
require "zeitwerk"
|
||||
require "cases/helper"
|
||||
require "models/author"
|
||||
require "models/company"
|
||||
|
@ -373,6 +374,19 @@ class InheritanceTest < ActiveRecord::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_new_with_autoload_paths
|
||||
path = File.expand_path("../models/autoloadable", __dir__)
|
||||
Zeitwerk.with_loader do |loader|
|
||||
loader.push_dir(path)
|
||||
loader.setup
|
||||
|
||||
firm = Company.new(type: "ExtraFirm")
|
||||
assert_equal ExtraFirm, firm.class
|
||||
ensure
|
||||
loader.unload
|
||||
end
|
||||
end
|
||||
|
||||
def test_inheritance_condition
|
||||
assert_equal 12, Company.count
|
||||
assert_equal 3, Firm.count
|
||||
|
|
Loading…
Reference in a new issue