Created
July 15, 2016 09:14
-
-
Save matt-thomson/24c3dd588608b09b6a12871ab6947822 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "cases/helper" | |
require 'support/schema_dumping_helper' | |
if ActiveRecord::Base.connection.supports_extensions? | |
class PostgresqlHstoreTest < ActiveRecord::PostgreSQLTestCase | |
include SchemaDumpingHelper | |
class Hstore < ActiveRecord::Base | |
self.table_name = 'hstores' | |
store_accessor :settings, :language, :timezone | |
end | |
def setup | |
@connection = ActiveRecord::Base.connection | |
unless @connection.extension_enabled?('hstore') | |
@connection.enable_extension 'hstore' | |
@connection.commit_db_transaction | |
end | |
@connection.reconnect! | |
@connection.transaction do | |
@connection.create_table('hstores') do |t| | |
t.hstore 'tags', :default => '' | |
t.hstore 'payload', array: true | |
t.hstore 'settings' | |
end | |
end | |
Hstore.reset_column_information | |
@column = Hstore.columns_hash['tags'] | |
@type = Hstore.type_for_attribute("tags") | |
end | |
teardown do | |
@connection.drop_table 'hstores', if_exists: true | |
end | |
def test_illegal_characters | |
x = Hstore.create!(:tags => {"ab" => "c\u0000d"}) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment