Skip to content

Commit 7572a13

Browse files
committed
Raise an error if the connection name doesn't match the adapter
This will prevent us from accidentally running mysql2 tests against trilogy adapter as we currently are doing.
1 parent 756cea1 commit 7572a13

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

activerecord/test/support/connection.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,12 @@ def self.connect
2525
ActiveRecord::Base.configurations = test_configuration_hashes
2626
ActiveRecord::Base.establish_connection :arunit
2727
ARUnit2Model.establish_connection :arunit2
28+
29+
arunit_adapter = ActiveRecord::Base.connection.pool.db_config.adapter
30+
31+
if connection_name != arunit_adapter
32+
return if connection_name == "sqlite3_mem" && arunit_adapter == "sqlite3"
33+
raise ArgumentError, "The connection name did not match the adapter name. Connection name is '#{connection_name}' and the adapter name is '#{arunit_adapter}'."
34+
end
2835
end
2936
end

0 commit comments

Comments
 (0)