diff options
author | Matthew Landauer <matthew@openaustralia.org> | 2013-03-25 17:49:34 +1100 |
---|---|---|
committer | Matthew Landauer <matthew@openaustralia.org> | 2013-03-25 17:57:12 +1100 |
commit | 349348ef2d78906eaa707b95e829d4892dce0580 (patch) | |
tree | ab0539895b2b7bc4e5bd6fddaed8bd74d527b2ed /spec/models | |
parent | d09758c79fff462906b48dda6601ced25a8865da (diff) |
Fix word highlighting in acts_as_xapian for non-ascii characters. Fixes #505
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/xapian_spec.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/models/xapian_spec.rb b/spec/models/xapian_spec.rb index 8c99d550f..923ee4165 100644 --- a/spec/models/xapian_spec.rb +++ b/spec/models/xapian_spec.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe User, " when indexing users with Xapian" do @@ -368,3 +369,28 @@ describe PublicBody, " when only indexing selected things on a rebuild" do end end +# I would expect ActsAsXapian to have some tests under vendor/plugins/acts_as_xapian, but +# it looks like this is not the case. Putting a test here instead. +describe ActsAsXapian::Search, "#words_to_highlight" do + it "should return a list of words used in the search" do + s = ActsAsXapian::Search.new([PublicBody], "albatross words", :limit => 100) + s.words_to_highlight.should == ["albatross", "words"] + end + + it "should remove any operators" do + s = ActsAsXapian::Search.new([PublicBody], "albatross words tag:mice", :limit => 100) + s.words_to_highlight.should == ["albatross", "words"] + end + + # This is the current behaviour but it seems a little simplistic to me + it "should separate punctuation" do + s = ActsAsXapian::Search.new([PublicBody], "The doctor's patient", :limit => 100) + s.words_to_highlight.should == ["The", "doctor", "s", "patient"] + end + + it "should handle non-ascii characters" do + s = ActsAsXapian::Search.new([PublicBody], "adatigénylés words tag:mice", :limit => 100) + s.words_to_highlight.should == ["adatigénylés", "words"] + end + +end |