diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-03-11 08:19:25 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-03-11 08:19:25 +0100 |
commit | 0e0b41d58c0a8e5921b7eebc3a6e0e4cc012ce4d (patch) | |
tree | d96edda3a1db2bf2cd0cff4803244e911ac415ec /activerecord/test/cases/adapters/postgresql/citext_test.rb | |
parent | 47ea87b8b9357beaca1a9bd2e191d0113b677966 (diff) | |
parent | b3e0da3062f809599fb4da9f9a29ed45aebd1ff6 (diff) | |
download | rails-0e0b41d58c0a8e5921b7eebc3a6e0e4cc012ce4d.tar.gz rails-0e0b41d58c0a8e5921b7eebc3a6e0e4cc012ce4d.tar.bz2 rails-0e0b41d58c0a8e5921b7eebc3a6e0e4cc012ce4d.zip |
Merge pull request #12523 from lsylvester/pg_citext
Support for PostgreSQL citext data type.
Diffstat (limited to 'activerecord/test/cases/adapters/postgresql/citext_test.rb')
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/citext_test.rb | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/citext_test.rb b/activerecord/test/cases/adapters/postgresql/citext_test.rb new file mode 100644 index 0000000000..89ef46b539 --- /dev/null +++ b/activerecord/test/cases/adapters/postgresql/citext_test.rb @@ -0,0 +1,58 @@ +# encoding: utf-8 + +require 'cases/helper' +require 'active_record/base' +require 'active_record/connection_adapters/postgresql_adapter' + +class PostgresqlCitextTest < ActiveRecord::TestCase + class Citext < ActiveRecord::Base + self.table_name = 'citexts' + end + + def setup + @connection = ActiveRecord::Base.connection + + unless @connection.extension_enabled?('citext') + @connection.enable_extension 'citext' + @connection.commit_db_transaction + end + + @connection.reconnect! + + @connection.transaction do + @connection.create_table('citexts') do |t| + t.citext 'cival' + end + end + @column = Citext.columns_hash['cival'] + end + + def teardown + @connection.execute 'DROP TABLE IF EXISTS citexts;' + @connection.execute 'DROP EXTENSION IF EXISTS citext CASCADE;' + end + + def test_citext_enabled + assert @connection.extension_enabled?('citext') + end + + def test_column_type + assert_equal :citext, @column.type + end + + def test_column_sql_type + assert_equal 'citext', @column.sql_type + end + + def test_write + x = Citext.new(cival: 'Some CI Text') + assert x.save! + end + + def test_select_case_insensitive + @connection.execute "insert into citexts (cival) values('Cased Text')" + x = Citext.where(cival: 'cased text').first + assert_equal('Cased Text', x.cival) + end + +end
\ No newline at end of file |