Skip to content

Commit aa4e713

Browse files
committed
Extract public file to maintain test schema so RSpec can use as well
Since `load_schema` is private API, we don't want it to be explicitly called by RSpec. This feature can be used by RSpec by exposing it in `rails/testing/maintain_test_schema` so they don't need to reimplement the same thing.
1 parent 70843ff commit aa4e713

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

railties/lib/rails/test_help.rb

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,9 @@
1414

1515
require "active_support/testing/autorun"
1616

17-
if defined?(ActiveRecord::Base)
18-
begin
19-
ActiveRecord::Migration.maintain_test_schema!
20-
rescue ActiveRecord::PendingMigrationError => e
21-
puts e.to_s.strip
22-
exit 1
23-
end
24-
25-
if Rails.configuration.eager_load
26-
ActiveRecord::Base.descendants.each do |model|
27-
model.load_schema unless model.abstract_class?
28-
end
29-
end
17+
require "rails/testing/maintain_test_schema"
3018

19+
if defined?(ActiveRecord::Base)
3120
ActiveSupport.on_load(:active_support_test_case) do
3221
include ActiveRecord::TestDatabases
3322
include ActiveRecord::TestFixtures
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# frozen_string_literal: true
2+
3+
if defined?(ActiveRecord::Base)
4+
begin
5+
ActiveRecord::Migration.maintain_test_schema!
6+
rescue ActiveRecord::PendingMigrationError => e
7+
puts e.to_s.strip
8+
exit 1
9+
end
10+
11+
if Rails.configuration.eager_load
12+
ActiveRecord::Base.descendants.each do |model|
13+
model.load_schema unless model.abstract_class?
14+
end
15+
end
16+
end

0 commit comments

Comments
 (0)