aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorGuo Xiang Tan <tgx_world@hotmail.com>2014-03-18 19:06:44 -0700
committerGuo Xiang Tan <tgx_world@hotmail.com>2014-03-20 11:48:17 -0700
commit79405a07a45dfaeb6c39d794b42b72ee73e420e9 (patch)
tree22b64cb731b66efbba6565ea95c25c72fb040b06 /activerecord
parentf522aebb6a844a278f1230e8e1f201e96f95203b (diff)
downloadrails-79405a07a45dfaeb6c39d794b42b72ee73e420e9.tar.gz
rails-79405a07a45dfaeb6c39d794b42b72ee73e420e9.tar.bz2
rails-79405a07a45dfaeb6c39d794b42b72ee73e420e9.zip
Extract with_example_table into helper method.
This setups the helper method which other tests can benefit from.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb11
-rw-r--r--activerecord/test/support/ddl_helper.rb8
2 files changed, 13 insertions, 6 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb b/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb
index de7acdf3ab..49d8ec238d 100644
--- a/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb
@@ -1,9 +1,12 @@
# encoding: utf-8
require "cases/helper"
+require 'support/ddl_helper'
module ActiveRecord
module ConnectionAdapters
class PostgreSQLAdapterTest < ActiveRecord::TestCase
+ include DdlHelper
+
def setup
@connection = ActiveRecord::Base.connection
end
@@ -369,12 +372,8 @@ module ActiveRecord
ctx.exec_insert(sql, 'SQL', binds)
end
- def with_example_table(definition = nil)
- definition ||= 'id serial primary key, number integer, data character varying(255)'
- @connection.exec_query("create table ex(#{definition})")
- yield
- ensure
- @connection.exec_query('drop table if exists ex')
+ def with_example_table(definition = 'id serial primary key, number integer, data character varying(255)', &block)
+ super(@connection, 'ex', definition, &block)
end
def connection_without_insert_returning
diff --git a/activerecord/test/support/ddl_helper.rb b/activerecord/test/support/ddl_helper.rb
new file mode 100644
index 0000000000..0107babaaf
--- /dev/null
+++ b/activerecord/test/support/ddl_helper.rb
@@ -0,0 +1,8 @@
+module DdlHelper
+ def with_example_table(connection, table_name, definition = nil)
+ connection.exec_query("CREATE TABLE #{table_name}(#{definition})")
+ yield
+ ensure
+ connection.exec_query("DROP TABLE #{table_name}")
+ end
+end