freelancing-god-thinking-sphinx 1.1.15 → 1.1.16
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +2 -0
- data/lib/thinking_sphinx.rb +1 -1
- data/lib/thinking_sphinx/search.rb +1 -1
- data/lib/thinking_sphinx/tasks.rb +7 -0
- data/spec/unit/thinking_sphinx/search_spec.rb +58 -22
- metadata +2 -2
data/README.textile
CHANGED
data/lib/thinking_sphinx.rb
CHANGED
@@ -684,7 +684,7 @@ module ThinkingSphinx
|
|
684
684
|
client.sort_by = order.to_s
|
685
685
|
end
|
686
686
|
when String
|
687
|
-
client.sort_mode = :extended
|
687
|
+
client.sort_mode = :extended unless options[:sort_mode]
|
688
688
|
client.sort_by = sorted_fields_to_attributes(order, fields)
|
689
689
|
else
|
690
690
|
# do nothing
|
@@ -6,6 +6,11 @@ namespace :thinking_sphinx do
|
|
6
6
|
Rake::Task[:merb_env].invoke if defined?(Merb)
|
7
7
|
end
|
8
8
|
|
9
|
+
desc "Output the current Thinking Sphinx version"
|
10
|
+
task :version => :app_env do
|
11
|
+
puts "Thinking Sphinx v" + ThinkingSphinx::Version::String
|
12
|
+
end
|
13
|
+
|
9
14
|
desc "Stop if running, then start a Sphinx searchd daemon using Thinking Sphinx's settings"
|
10
15
|
task :running_start => :app_env do
|
11
16
|
Rake::Task["thinking_sphinx:stop"].invoke if sphinx_running?
|
@@ -96,6 +101,8 @@ namespace :thinking_sphinx do
|
|
96
101
|
end
|
97
102
|
|
98
103
|
namespace :ts do
|
104
|
+
desc "Output the current Thinking Sphinx version"
|
105
|
+
task :version => "thinking_sphinx:version"
|
99
106
|
desc "Stop if running, then start a Sphinx searchd daemon using Thinking Sphinx's settings"
|
100
107
|
task :run => "thinking_sphinx:running_start"
|
101
108
|
desc "Start a Sphinx searchd daemon using Thinking Sphinx's settings"
|
@@ -3,28 +3,27 @@ require 'will_paginate/collection'
|
|
3
3
|
|
4
4
|
describe ThinkingSphinx::Search do
|
5
5
|
describe "search method" do
|
6
|
-
before :each do
|
7
|
-
@client = Riddle::Client.stub_instance(
|
8
|
-
:filters => [],
|
9
|
-
:filters= => true,
|
10
|
-
:id_range= => true,
|
11
|
-
:sort_mode => :asc,
|
12
|
-
:limit => 5,
|
13
|
-
:offset= => 0,
|
14
|
-
:sort_mode= => true,
|
15
|
-
:query => {
|
16
|
-
:matches => [],
|
17
|
-
:total => 50
|
18
|
-
}
|
19
|
-
)
|
20
|
-
|
21
|
-
ThinkingSphinx::Search.stub_methods(
|
22
|
-
:client_from_options => @client,
|
23
|
-
:search_conditions => ["", []]
|
24
|
-
)
|
25
|
-
end
|
26
|
-
|
27
6
|
describe ":star option" do
|
7
|
+
before :each do
|
8
|
+
@client = Riddle::Client.stub_instance(
|
9
|
+
:filters => [],
|
10
|
+
:filters= => true,
|
11
|
+
:id_range= => true,
|
12
|
+
:sort_mode => :asc,
|
13
|
+
:limit => 5,
|
14
|
+
:offset= => 0,
|
15
|
+
:sort_mode= => true,
|
16
|
+
:query => {
|
17
|
+
:matches => [],
|
18
|
+
:total => 50
|
19
|
+
}
|
20
|
+
)
|
21
|
+
|
22
|
+
ThinkingSphinx::Search.stub_methods(
|
23
|
+
:client_from_options => @client,
|
24
|
+
:search_conditions => ["", []]
|
25
|
+
)
|
26
|
+
end
|
28
27
|
|
29
28
|
it "should not apply by default" do
|
30
29
|
ThinkingSphinx::Search.search "foo bar"
|
@@ -47,7 +46,44 @@ describe ThinkingSphinx::Search do
|
|
47
46
|
ThinkingSphinx::Search.search "foo@bar.com -foo-bar", :star => /[\w@.-]+/u
|
48
47
|
@client.should have_received(:query).with("*foo@bar.com* -*foo-bar*")
|
49
48
|
end
|
50
|
-
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "sort modes" do
|
52
|
+
before :each do
|
53
|
+
@client = Riddle::Client.new
|
54
|
+
@client.stub_method(:query => {:matches => []})
|
55
|
+
Riddle::Client.stub_method(:new => @client)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should use :relevance as a default" do
|
59
|
+
ThinkingSphinx::Search.search "foo"
|
60
|
+
@client.sort_mode.should == :relevance
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should use :attr_asc if a symbol is supplied to :order" do
|
64
|
+
ThinkingSphinx::Search.search "foo", :order => :created_at
|
65
|
+
@client.sort_mode.should == :attr_asc
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should use :attr_desc if a symbol is supplied and :desc is the mode" do
|
69
|
+
ThinkingSphinx::Search.search "foo", :order => :created_at, :sort_mode => :desc
|
70
|
+
@client.sort_mode.should == :attr_desc
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should use :extended if a string is supplied to :order" do
|
74
|
+
ThinkingSphinx::Search.search "foo", :order => "created_at ASC"
|
75
|
+
@client.sort_mode.should == :extended
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should use :expr if explicitly requested with a string supplied to :order" do
|
79
|
+
ThinkingSphinx::Search.search "foo", :order => "created_at ASC", :sort_mode => :expr
|
80
|
+
@client.sort_mode.should == :expr
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should use :attr_desc if explicitly requested with a string supplied to :order" do
|
84
|
+
ThinkingSphinx::Search.search "foo", :order => "created_at", :sort_mode => :desc
|
85
|
+
@client.sort_mode.should == :attr_desc
|
86
|
+
end
|
51
87
|
end
|
52
88
|
end
|
53
89
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: freelancing-god-thinking-sphinx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pat Allan
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-23 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|