From ccc0165ed78a71b52cb3cd70457623380bd04c65 Mon Sep 17 00:00:00 2001 From: Samuel Esposito Date: Fri, 21 Apr 2017 09:09:36 +0200 Subject: [PATCH 1/2] Return connection class This method is used in the `#connection_class` method and should return a class after establishing the connection --- lib/database_cleaner/active_record/base.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/database_cleaner/active_record/base.rb b/lib/database_cleaner/active_record/base.rb index 85bf50b..d2fe82f 100644 --- a/lib/database_cleaner/active_record/base.rb +++ b/lib/database_cleaner/active_record/base.rb @@ -69,6 +69,7 @@ module DatabaseCleaner def establish_connection ::ActiveRecord::Base.establish_connection(connection_hash) + ::ActiveRecord::Base end end From d5610b5794b7e07a5fa49260e065296bf78a8364 Mon Sep 17 00:00:00 2001 From: Samuel Esposito Date: Fri, 21 Apr 2017 09:28:04 +0200 Subject: [PATCH 2/2] Extend activerecord base spec --- spec/database_cleaner/active_record/base_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spec/database_cleaner/active_record/base_spec.rb b/spec/database_cleaner/active_record/base_spec.rb index ff5be7f..370356f 100644 --- a/spec/database_cleaner/active_record/base_spec.rb +++ b/spec/database_cleaner/active_record/base_spec.rb @@ -181,6 +181,12 @@ my_db: subject.connection_class end + + it "returns the connection class" do + ::ActiveRecord::Base.stub(:establish_connection) + + subject.connection_class.should eq ::ActiveRecord::Base + end end end end