Refactor schema dumping helper for tests

There isn't a single test that passes a connection to this method so
refactor this to remove that option until it is needed.
This commit is contained in:
eileencodes 2023-01-13 12:52:52 -05:00
parent f86a529559
commit d891425de7
No known key found for this signature in database
GPG Key ID: BA5C575120BBE8DF

@ -1,11 +1,13 @@
# frozen_string_literal: true
module SchemaDumpingHelper
def dump_table_schema(table, connection = ActiveRecord::Base.connection)
def dump_table_schema(table)
connection = ActiveRecord::Base.connection
old_ignore_tables = ActiveRecord::SchemaDumper.ignore_tables
ActiveRecord::SchemaDumper.ignore_tables = connection.data_sources - [table]
stream = StringIO.new
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
ActiveRecord::SchemaDumper.dump(connection, stream)
stream.string
ensure
ActiveRecord::SchemaDumper.ignore_tables = old_ignore_tables