diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-01-28 16:47:20 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-01-28 16:47:40 -0800 |
commit | 439ac72013fc1b819e711d66642b0b5b563fd72e (patch) | |
tree | 6050295500b3a28522f884206164f20f6a91c510 /activerecord/test/cases | |
parent | ba6cae4cc571fdf36a7a3cc5a2e6cdcdf3aaced4 (diff) | |
download | rails-439ac72013fc1b819e711d66642b0b5b563fd72e.tar.gz rails-439ac72013fc1b819e711d66642b0b5b563fd72e.tar.bz2 rails-439ac72013fc1b819e711d66642b0b5b563fd72e.zip |
add API to pg for enabling / disabling hstore
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/hstore_test.rb | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/hstore_test.rb b/activerecord/test/cases/adapters/postgresql/hstore_test.rb index 23bafde17b..9498c829dc 100644 --- a/activerecord/test/cases/adapters/postgresql/hstore_test.rb +++ b/activerecord/test/cases/adapters/postgresql/hstore_test.rb @@ -11,15 +11,16 @@ class PostgresqlHstoreTest < ActiveRecord::TestCase def setup @connection = ActiveRecord::Base.connection - begin - @connection.transaction do - @connection.create_table('hstores') do |t| - t.hstore 'tags', :default => '' - end - end - rescue ActiveRecord::StatementInvalid + unless @connection.extension_enabled?('hstore') + @connection.enable_extension 'hstore' return skip "do not test on PG without hstore" end + + @connection.transaction do + @connection.create_table('hstores') do |t| + t.hstore 'tags', :default => '' + end + end @column = Hstore.columns.find { |c| c.name == 'tags' } end @@ -27,6 +28,27 @@ class PostgresqlHstoreTest < ActiveRecord::TestCase @connection.execute 'drop table if exists hstores' end + def test_hstore_enabled + assert @connection.extension_enabled?('hstore') + end + + def test_disable_hstore + if @connection.extension_enabled?('hstore') + @connection.disable_extension 'hstore' + assert_not @connection.extension_enabled?('hstore') + end + end + + def test_enable_hstore + if @connection.extension_enabled?('hstore') + @connection.disable_extension 'hstore' + end + + assert_not @connection.extension_enabled?('hstore') + @connection.enable_extension 'hstore' + assert @connection.extension_enabled?('hstore') + end + def test_column assert_equal :hstore, @column.type end |