Skip to content

Commit c509713

Browse files
committed
Postgres, fix schema dump tests
1 parent 951bdb6 commit c509713

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

test/db/postgresql/schema_dump_test.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ def test_dumps_array_with_default
9292
private
9393

9494
def dump_with_data_types(io = StringIO.new)
95+
pool = ActiveRecord::Base.connection_pool
9596
ActiveRecord::SchemaDumper.ignore_tables = [/^[^d]/] # keep data_types
96-
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, io)
97+
ActiveRecord::SchemaDumper.dump(pool, io)
9798
io.string
9899
end
99100

test/schema_dump.rb

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,13 @@ def test_dumping_schema_with_index
1010
connection = ActiveRecord::Base.connection
1111
connection.add_index :entries, :title
1212
StringIO.open do |io|
13-
ActiveRecord::SchemaDumper.dump(connection, io)
13+
ActiveRecord::SchemaDumper.dump(db_pool, io)
1414
assert_match(/"index_entries_on_title"/, io.string)
1515
end
1616
ensure
1717
connection.remove_index :entries, :title
1818
end
1919

20-
def standard_dump(io = StringIO.new, ignore_tables = [])
21-
io = StringIO.new
22-
ActiveRecord::SchemaDumper.ignore_tables = ignore_tables
23-
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, io)
24-
io.string
25-
end
26-
private :standard_dump
27-
2820
def test_magic_comment
2921
standard_dump(strio = StringIO.new)
3022
assert_match "# encoding: #{strio.external_encoding.name}", standard_dump
@@ -60,7 +52,7 @@ def test_schema_dump_with_string_ignored_table
6052
stream = StringIO.new
6153

6254
ActiveRecord::SchemaDumper.ignore_tables = ['users']
63-
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
55+
ActiveRecord::SchemaDumper.dump(db_pool, stream)
6456
output = stream.string
6557
assert_no_match %r{create_table "users"}, output
6658
assert_match %r{create_table "entries"}, output
@@ -135,4 +127,16 @@ def test_schema_dump_with_table_name_prefix_and_suffix
135127
ActiveRecord::Base.table_name_suffix = ActiveRecord::Base.table_name_prefix = ''
136128
end
137129

130+
private
131+
132+
def standard_dump(io = StringIO.new, ignore_tables = [])
133+
pool = ActiveRecord::Base.connection_pool
134+
ActiveRecord::SchemaDumper.ignore_tables = ignore_tables
135+
ActiveRecord::SchemaDumper.dump(pool, io)
136+
io.string
137+
end
138+
139+
def db_pool
140+
ActiveRecord::Base.connection_pool
141+
end
138142
end

0 commit comments

Comments
 (0)