mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Extract with_example_table into helper method.
This setups the helper method which other tests can benefit from.
This commit is contained in:
parent
f522aebb6a
commit
79405a07a4
2 changed files with 13 additions and 6 deletions
|
@ -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
|
||||
|
|
8
activerecord/test/support/ddl_helper.rb
Normal file
8
activerecord/test/support/ddl_helper.rb
Normal file
|
@ -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
|
Loading…
Reference in a new issue