aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/support/fake_record.rb16
-rw-r--r--test/visitors/test_ibm_db.rb2
-rw-r--r--test/visitors/test_informix.rb2
-rw-r--r--test/visitors/test_join_sql.rb2
-rw-r--r--test/visitors/test_mssql.rb2
-rw-r--r--test/visitors/test_mysql.rb2
-rw-r--r--test/visitors/test_postgres.rb2
-rw-r--r--test/visitors/test_to_sql.rb24
8 files changed, 22 insertions, 30 deletions
diff --git a/test/support/fake_record.rb b/test/support/fake_record.rb
index ddef7b66c5..79182f86bd 100644
--- a/test/support/fake_record.rb
+++ b/test/support/fake_record.rb
@@ -3,9 +3,10 @@ module FakeRecord
end
class Connection
- attr_reader :tables, :columns_hash, :visitor
+ attr_reader :tables, :columns_hash
+ attr_accessor :visitor
- def initialize(visitor)
+ def initialize(visitor = nil)
@tables = %w{ users photos developers products}
@columns = {
'users' => [
@@ -50,6 +51,10 @@ module FakeRecord
"\"#{name.to_s}\""
end
+ def schema_cache
+ self
+ end
+
def quote thing, column = nil
if column && column.type == :integer
return 'NULL' if thing.nil?
@@ -79,7 +84,8 @@ module FakeRecord
def initialize
@spec = Spec.new(:adapter => 'america')
- @connection = Connection.new(Arel::Visitors::ToSql.new(self))
+ @connection = Connection.new
+ @connection.visitor = Arel::Visitors::ToSql.new(connection)
end
def with_connection
@@ -93,6 +99,10 @@ module FakeRecord
def columns_hash
connection.columns_hash
end
+
+ def schema_cache
+ connection
+ end
end
class Base
diff --git a/test/visitors/test_ibm_db.rb b/test/visitors/test_ibm_db.rb
index 90008ba05e..b055e883d6 100644
--- a/test/visitors/test_ibm_db.rb
+++ b/test/visitors/test_ibm_db.rb
@@ -4,7 +4,7 @@ module Arel
module Visitors
describe 'the ibm_db visitor' do
before do
- @visitor = IBM_DB.new Table.engine.connection_pool
+ @visitor = IBM_DB.new Table.engine.connection
end
it 'uses FETCH FIRST n ROWS to limit results' do
diff --git a/test/visitors/test_informix.rb b/test/visitors/test_informix.rb
index 422da846fe..67b02e0a64 100644
--- a/test/visitors/test_informix.rb
+++ b/test/visitors/test_informix.rb
@@ -4,7 +4,7 @@ module Arel
module Visitors
describe 'the informix visitor' do
before do
- @visitor = Informix.new Table.engine.connection_pool
+ @visitor = Informix.new Table.engine.connection
end
it 'uses LIMIT n to limit results' do
diff --git a/test/visitors/test_join_sql.rb b/test/visitors/test_join_sql.rb
index 6f7440cc47..b3fc7661aa 100644
--- a/test/visitors/test_join_sql.rb
+++ b/test/visitors/test_join_sql.rb
@@ -4,7 +4,7 @@ module Arel
module Visitors
describe 'the join_sql visitor' do
before do
- @visitor = ToSql.new Table.engine.connection_pool
+ @visitor = ToSql.new Table.engine.connection
@visitor.extend(JoinSql)
end
diff --git a/test/visitors/test_mssql.rb b/test/visitors/test_mssql.rb
index 21588f53cf..d62d4b8d1f 100644
--- a/test/visitors/test_mssql.rb
+++ b/test/visitors/test_mssql.rb
@@ -4,7 +4,7 @@ module Arel
module Visitors
describe 'the mssql visitor' do
before do
- @visitor = MSSQL.new Table.engine.connection_pool
+ @visitor = MSSQL.new Table.engine.connection
@table = Arel::Table.new "users"
end
diff --git a/test/visitors/test_mysql.rb b/test/visitors/test_mysql.rb
index 487db325e8..6330112229 100644
--- a/test/visitors/test_mysql.rb
+++ b/test/visitors/test_mysql.rb
@@ -4,7 +4,7 @@ module Arel
module Visitors
describe 'the mysql visitor' do
before do
- @visitor = MySQL.new Table.engine.connection_pool
+ @visitor = MySQL.new Table.engine.connection
end
it 'squashes parenthesis on multiple unions' do
diff --git a/test/visitors/test_postgres.rb b/test/visitors/test_postgres.rb
index e8df681269..921bd96c1a 100644
--- a/test/visitors/test_postgres.rb
+++ b/test/visitors/test_postgres.rb
@@ -4,7 +4,7 @@ module Arel
module Visitors
describe 'the postgres visitor' do
before do
- @visitor = PostgreSQL.new Table.engine.connection_pool
+ @visitor = PostgreSQL.new Table.engine.connection
end
describe 'locking' do
diff --git a/test/visitors/test_to_sql.rb b/test/visitors/test_to_sql.rb
index 12af197596..9b86a89300 100644
--- a/test/visitors/test_to_sql.rb
+++ b/test/visitors/test_to_sql.rb
@@ -1,14 +1,10 @@
require 'helper'
-class Arel::Visitors::ToSql
- def last_column; Thread.current[:arel_visitors_to_sql_last_column]; end
-end
-
module Arel
module Visitors
describe 'the to_sql visitor' do
before do
- @visitor = ToSql.new Table.engine.connection_pool
+ @visitor = ToSql.new Table.engine.connection
@table = Table.new(:users)
@attr = @table[:id]
end
@@ -29,20 +25,6 @@ module Arel
assert visited, 'hello method was called'
end
- it "should be thread safe around usage of last_column" do
- visit_integer_column = Thread.new do
- Thread.stop
- @visitor.send(:visit_Arel_Attributes_Attribute, @attr)
- end
-
- sleep 0.2
- @visitor.accept(@table[:name])
- assert_equal(:string, @visitor.last_column.type)
- visit_integer_column.run
- visit_integer_column.join
- assert_equal(:string, @visitor.last_column.type)
- end
-
it 'should not quote sql literals' do
node = @table[Arel.star]
sql = @visitor.accept node
@@ -220,7 +202,7 @@ module Arel
end
end
in_node = Nodes::In.new @attr, %w{ a b c }
- visitor = visitor.new(Table.engine.connection_pool)
+ visitor = visitor.new(Table.engine.connection)
visitor.expected = Table.engine.connection.columns(:users).find { |x|
x.name == 'name'
}
@@ -308,7 +290,7 @@ module Arel
end
end
in_node = Nodes::NotIn.new @attr, %w{ a b c }
- visitor = visitor.new(Table.engine.connection_pool)
+ visitor = visitor.new(Table.engine.connection)
visitor.expected = Table.engine.connection.columns(:users).find { |x|
x.name == 'name'
}