Enable hstore extensions on tests if it is not enabled and database supports it

上级 655e95c8
...@@ -11,11 +11,18 @@ class Hstore < ActiveRecord::Base ...@@ -11,11 +11,18 @@ class Hstore < ActiveRecord::Base
def setup def setup
@connection = ActiveRecord::Base.connection @connection = ActiveRecord::Base.connection
unless @connection.supports_extensions?
return skip "do not test on PG without hstore"
end
unless @connection.extension_enabled?('hstore') unless @connection.extension_enabled?('hstore')
@connection.enable_extension 'hstore' @connection.enable_extension 'hstore'
return skip "do not test on PG without hstore" @connection.commit_db_transaction
end end
@connection.reconnect!
@connection.transaction do @connection.transaction do
@connection.create_table('hstores') do |t| @connection.create_table('hstores') do |t|
t.hstore 'tags', :default => '' t.hstore 'tags', :default => ''
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册