~gaspard-teti/zena/master

« back to all changes in this revision

Viewing changes to test/integration/query_node_test.rb

  • Committer: Gaspard Bucher
  • Date: 2014-04-18 16:58:54 UTC
  • Revision ID: git-v1:25dbdf29fde0e9d8047f2111072d4fdd528d6fa5
Implemented 'fulltext match' or 'sphinx match' to use fulltext search in node query. Fix #74.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
require 'test_helper'
2
2
require 'yamltest'
3
3
 
 
4
# Mock sphinx search
 
5
 
 
6
# add 'sphinx match xxxx' to QueryNode
 
7
Node.query_compiler.add_fulltext_field('sphinx') do |processor, table, right|
 
8
  helper = processor.instance_variable_get(:@rubyless_helper)
 
9
  case right[0]
 
10
  when :string, :dstring, :real, :integer
 
11
    value = RubyLess.translate_string(helper, right[1])
 
12
  when :rubyless
 
13
    value = RubyLess.translate(helper, right[1])
 
14
  else
 
15
    raise ::QueryBuilder::Error.new("Can only match against literal or rubyless values.")
 
16
  end
 
17
  "#{table}.zip IN (#{processor.send(:insert_bind, "test_search_for_ids(#{value})")})"
 
18
end
 
19
 
 
20
def test_search_for_ids(fld)
 
21
  [11, 18, 29]
 
22
end
 
23
 
4
24
class QueryNodeTest < Zena::Unit::TestCase
5
25
  include RubyLess
6
26
  safe_method :date => Time