Permalink
Browse files

Add unit coverage for TSearch#conditions

  • Loading branch information...
1 parent 263a0b0 commit b3d6b79329994a8ff580689f716777ec1b1d28d4 @nertzy nertzy committed Apr 2, 2013
Showing with 24 additions and 0 deletions.
  1. +24 −0 spec/lib/pg_search/features/tsearch_spec.rb
@@ -24,4 +24,28 @@
%Q{(ts_rank((to_tsvector('simple', coalesce(#{Model.quoted_table_name}."name"::text, '')) || to_tsvector('simple', coalesce(#{Model.quoted_table_name}."content"::text, ''))), (to_tsquery('simple', ''' ' || 'query' || ' ''')), 0))}
end
end
+
+ describe "#conditions" do
+ with_model :Model do
+ table do |t|
+ t.string :name
+ t.text :content
+ end
+ end
+
+ it "returns an expression using the @@ infix operator" do
+ query = "query"
+ columns = [
+ PgSearch::Configuration::Column.new(:name, nil, Model),
+ PgSearch::Configuration::Column.new(:content, nil, Model),
+ ]
+ options = {}
+ config = stub(:config, :ignore => [])
+ normalizer = PgSearch::Normalizer.new(config)
+
+ feature = described_class.new(query, options, columns, Model, normalizer)
+ feature.conditions.to_sql.should ==
+ %Q{((to_tsvector('simple', coalesce(#{Model.quoted_table_name}."name"::text, '')) || to_tsvector('simple', coalesce(#{Model.quoted_table_name}."content"::text, ''))) @@ (to_tsquery('simple', ''' ' || 'query' || ' ''')))}
+ end
+ end
end

0 comments on commit b3d6b79

Please sign in to comment.