aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters/postgresql/full_text_test.rb
blob: 9dadb177cad95a3183d1d02c217a172afcb297cf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# encoding: utf-8
require "cases/helper"

class PostgresqlFullTextTest < ActiveRecord::TestCase
  class PostgresqlTsvector < ActiveRecord::Base; end

  def test_tsvector_column
    column = PostgresqlTsvector.columns_hash["text_vector"]
    assert_equal :tsvector, column.type
    assert_equal "tsvector", column.sql_type
    assert_not column.number?
    assert_not column.binary?
    assert_not column.array
  end

  def test_update_tsvector
    PostgresqlTsvector.create text_vector: "'text' 'vector'"
    tsvector = PostgresqlTsvector.first
    assert_equal "'text' 'vector'", tsvector.text_vector

    tsvector.text_vector = "'new' 'text' 'vector'"
    tsvector.save!
    assert tsvector.reload
    assert_equal "'new' 'text' 'vector'", tsvector.text_vector
  end
end