From dbc8c0ee36ddda7c27a375c78bbdb989fd30c298 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 10 Apr 2014 17:24:10 -0700 Subject: decouple the factory method from the constructing model The factory method only requires the constructing model to get the connection object. Since the model is available when calling the factory method, we can just pass the appropriate connection in. --- activerecord/test/cases/statement_cache_test.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'activerecord/test/cases') diff --git a/activerecord/test/cases/statement_cache_test.rb b/activerecord/test/cases/statement_cache_test.rb index 0455764f6c..96a899a08b 100644 --- a/activerecord/test/cases/statement_cache_test.rb +++ b/activerecord/test/cases/statement_cache_test.rb @@ -15,7 +15,7 @@ module ActiveRecord Book.create(name: "my book") Book.create(name: "my other book") - cache = StatementCache.create do |params| + cache = StatementCache.create(Book.connection) do |params| Book.where(:name => params[:name]) end @@ -30,7 +30,7 @@ module ActiveRecord b1 = Book.create(name: "my book") b2 = Book.create(name: "my other book") - cache = StatementCache.create do |params| + cache = StatementCache.create(Book.connection) do |params| Book.where(id: params[:id]) end @@ -53,7 +53,7 @@ module ActiveRecord #End def test_statement_cache_with_simple_statement - cache = ActiveRecord::StatementCache.create do |params| + cache = ActiveRecord::StatementCache.create(Book.connection) do |params| Book.where(name: "my book").where("author_id > 3") end @@ -64,7 +64,7 @@ module ActiveRecord end def test_statement_cache_with_complex_statement - cache = ActiveRecord::StatementCache.create do |params| + cache = ActiveRecord::StatementCache.create(Book.connection) do |params| Liquid.joins(:molecules => :electrons).where('molecules.name' => 'dioxane', 'electrons.name' => 'lepton') end @@ -77,7 +77,7 @@ module ActiveRecord end def test_statement_cache_values_differ - cache = ActiveRecord::StatementCache.create do |params| + cache = ActiveRecord::StatementCache.create(Book.connection) do |params| Book.where(name: "my book") end -- cgit v1.2.3