Remove unnecessary remove/establish_connection

This test does not need to remove and re-establish a connection to
`ActiveRecord::Base` because `College` inherits from `Arunit2` which
defines and connects to a separate database.

If we want to test that `College` is not using the connection from
`ActiveRecord::Base`, we can assert the connections directly.
This commit is contained in:
eileencodes 2023-02-14 16:42:13 -05:00
parent 8d4bb4ef6c
commit 4345e84587
No known key found for this signature in database
GPG Key ID: BA5C575120BBE8DF

@ -98,19 +98,15 @@ def test_connection
unless in_memory_db?
def test_count_on_custom_connection
ActiveRecord::Base.remove_connection
assert_equal ARUnit2Model.connection, College.connection
assert_not_equal ActiveRecord::Base.connection, College.connection
assert_equal 1, College.count
ensure
ActiveRecord::Base.establish_connection :arunit
end
def test_associations_should_work_when_model_has_no_connection
ActiveRecord::Base.remove_connection
assert_nothing_raised do
College.first.courses.first
end
ensure
ActiveRecord::Base.establish_connection :arunit
end
end
end