class PostgresqlCitextTest
Public Instance Methods
setup()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/citext_test.rb, line 13 def setup @connection = ActiveRecord::Base.connection enable_extension!("citext", @connection) @connection.create_table("citexts") do |t| t.citext "cival" end end
test_change_table_supports_json()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/citext_test.rb, line 42 def test_change_table_supports_json @connection.transaction do @connection.change_table("citexts") do |t| t.citext "username" end Citext.reset_column_information column = Citext.columns_hash["username"] assert_equal :citext, column.type raise ActiveRecord::Rollback # reset the schema change end ensure Citext.reset_column_information end
test_citext_enabled()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/citext_test.rb, line 28 def test_citext_enabled assert @connection.extension_enabled?("citext") end
test_column()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/citext_test.rb, line 32 def test_column column = Citext.columns_hash["cival"] assert_equal :citext, column.type assert_equal "citext", column.sql_type assert_not column.array? type = Citext.type_for_attribute("cival") assert_not type.binary? end
test_schema_dump_with_shorthand()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/citext_test.rb, line 75 def test_schema_dump_with_shorthand output = dump_table_schema("citexts") assert_match %r[t\.citext "cival"], output end
test_select_case_insensitive()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/citext_test.rb, line 69 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
test_write()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/citext_test.rb, line 57 def test_write x = Citext.new(cival: "Some CI Text") x.save! citext = Citext.first assert_equal "Some CI Text", citext.cival citext.cival = "Some NEW CI Text" citext.save! assert_equal "Some NEW CI Text", citext.reload.cival end