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:
parent
8d4bb4ef6c
commit
4345e84587
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user