thinking-sphinx 1.5.0 → 2.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +15 -48
- data/VERSION +1 -0
- data/features/attribute_transformation.feature +7 -7
- data/features/attribute_updates.feature +16 -18
- data/features/deleting_instances.feature +13 -16
- data/features/excerpts.feature +0 -8
- data/features/facets.feature +19 -25
- data/features/handling_edits.feature +20 -25
- data/features/searching_across_models.feature +1 -1
- data/features/searching_by_index.feature +5 -6
- data/features/searching_by_model.feature +29 -29
- data/features/sphinx_scopes.feature +0 -26
- data/features/step_definitions/common_steps.rb +6 -18
- data/features/step_definitions/scope_steps.rb +0 -4
- data/features/step_definitions/search_steps.rb +4 -9
- data/features/support/env.rb +10 -3
- data/features/thinking_sphinx/db/fixtures/alphas.rb +10 -8
- data/features/thinking_sphinx/db/fixtures/cats.rb +1 -1
- data/features/thinking_sphinx/db/fixtures/dogs.rb +1 -1
- data/features/thinking_sphinx/db/fixtures/foxes.rb +1 -1
- data/features/thinking_sphinx/db/fixtures/people.rb +1 -1
- data/features/thinking_sphinx/db/fixtures/posts.rb +1 -5
- data/features/thinking_sphinx/db/migrations/create_posts.rb +0 -1
- data/features/thinking_sphinx/models/alpha.rb +0 -1
- data/features/thinking_sphinx/models/beta.rb +0 -5
- data/features/thinking_sphinx/models/developer.rb +1 -6
- data/features/thinking_sphinx/models/music.rb +1 -3
- data/features/thinking_sphinx/models/person.rb +1 -2
- data/features/thinking_sphinx/models/post.rb +0 -1
- data/lib/cucumber/thinking_sphinx/external_world.rb +4 -8
- data/lib/cucumber/thinking_sphinx/internal_world.rb +27 -36
- data/lib/thinking_sphinx.rb +60 -132
- data/lib/thinking_sphinx/active_record.rb +98 -124
- data/lib/thinking_sphinx/active_record/attribute_updates.rb +13 -17
- data/lib/thinking_sphinx/active_record/delta.rb +15 -21
- data/lib/thinking_sphinx/active_record/has_many_association.rb +23 -16
- data/lib/thinking_sphinx/active_record/scopes.rb +0 -18
- data/lib/thinking_sphinx/adapters/abstract_adapter.rb +15 -63
- data/lib/thinking_sphinx/adapters/mysql_adapter.rb +0 -4
- data/lib/thinking_sphinx/adapters/postgresql_adapter.rb +24 -65
- data/lib/thinking_sphinx/association.rb +11 -36
- data/lib/thinking_sphinx/attribute.rb +85 -92
- data/lib/thinking_sphinx/auto_version.rb +3 -21
- data/lib/thinking_sphinx/class_facet.rb +3 -8
- data/lib/thinking_sphinx/configuration.rb +58 -114
- data/lib/thinking_sphinx/context.rb +20 -22
- data/lib/thinking_sphinx/core/array.rb +13 -0
- data/lib/thinking_sphinx/deltas.rb +0 -2
- data/lib/thinking_sphinx/deltas/default_delta.rb +22 -18
- data/lib/thinking_sphinx/deploy/capistrano.rb +31 -30
- data/lib/thinking_sphinx/excerpter.rb +1 -2
- data/lib/thinking_sphinx/facet.rb +35 -45
- data/lib/thinking_sphinx/facet_search.rb +24 -58
- data/lib/thinking_sphinx/field.rb +0 -18
- data/lib/thinking_sphinx/index.rb +36 -38
- data/lib/thinking_sphinx/index/builder.rb +59 -74
- data/lib/thinking_sphinx/property.rb +45 -66
- data/lib/thinking_sphinx/railtie.rb +35 -0
- data/lib/thinking_sphinx/search.rb +250 -506
- data/lib/thinking_sphinx/source.rb +31 -50
- data/lib/thinking_sphinx/source/internal_properties.rb +3 -8
- data/lib/thinking_sphinx/source/sql.rb +31 -71
- data/lib/thinking_sphinx/tasks.rb +27 -48
- data/spec/thinking_sphinx/active_record/delta_spec.rb +41 -36
- data/spec/thinking_sphinx/active_record/has_many_association_spec.rb +0 -96
- data/spec/thinking_sphinx/active_record/scopes_spec.rb +29 -29
- data/spec/thinking_sphinx/active_record_spec.rb +169 -140
- data/spec/thinking_sphinx/association_spec.rb +2 -20
- data/spec/thinking_sphinx/attribute_spec.rb +97 -101
- data/spec/thinking_sphinx/auto_version_spec.rb +11 -75
- data/spec/thinking_sphinx/configuration_spec.rb +62 -63
- data/spec/thinking_sphinx/context_spec.rb +66 -66
- data/spec/thinking_sphinx/facet_search_spec.rb +99 -99
- data/spec/thinking_sphinx/facet_spec.rb +4 -30
- data/spec/thinking_sphinx/field_spec.rb +3 -17
- data/spec/thinking_sphinx/index/builder_spec.rb +132 -169
- data/spec/thinking_sphinx/index_spec.rb +39 -45
- data/spec/thinking_sphinx/search_methods_spec.rb +33 -37
- data/spec/thinking_sphinx/search_spec.rb +269 -491
- data/spec/thinking_sphinx/source_spec.rb +48 -62
- data/spec/thinking_sphinx_spec.rb +49 -49
- data/tasks/distribution.rb +46 -0
- data/tasks/testing.rb +74 -0
- metadata +123 -199
- data/features/field_sorting.feature +0 -18
- data/features/thinking_sphinx/db/.gitignore +0 -1
- data/features/thinking_sphinx/db/fixtures/post_keywords.txt +0 -1
- data/features/thinking_sphinx/models/andrew.rb +0 -17
- data/lib/thinking-sphinx.rb +0 -1
- data/lib/thinking_sphinx/active_record/has_many_association_with_scopes.rb +0 -21
- data/lib/thinking_sphinx/bundled_search.rb +0 -40
- data/lib/thinking_sphinx/connection.rb +0 -71
- data/lib/thinking_sphinx/deltas/delete_job.rb +0 -16
- data/lib/thinking_sphinx/deltas/index_job.rb +0 -17
- data/lib/thinking_sphinx/rails_additions.rb +0 -181
- data/spec/fixtures/data.sql +0 -32
- data/spec/fixtures/database.yml.default +0 -3
- data/spec/fixtures/models.rb +0 -161
- data/spec/fixtures/structure.sql +0 -146
- data/spec/spec_helper.rb +0 -54
- data/spec/sphinx_helper.rb +0 -67
- data/spec/thinking_sphinx/adapters/abstract_adapter_spec.rb +0 -163
- data/spec/thinking_sphinx/connection_spec.rb +0 -77
- data/spec/thinking_sphinx/rails_additions_spec.rb +0 -203
@@ -1,203 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ThinkingSphinx::HashExcept do
|
4
|
-
before(:each) do
|
5
|
-
@hash = { :number => 20, :letter => 'b', :shape => 'rectangle' }
|
6
|
-
end
|
7
|
-
|
8
|
-
describe "except method" do
|
9
|
-
it "returns a hash without the specified keys" do
|
10
|
-
new_hash = @hash.except(:number)
|
11
|
-
new_hash.should_not have_key(:number)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "except! method" do
|
16
|
-
it "modifies hash removing specified keys" do
|
17
|
-
@hash.except!(:number)
|
18
|
-
@hash.should_not have_key(:number)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe "extends Hash" do
|
23
|
-
before :each do
|
24
|
-
@instance_methods = Hash.instance_methods.collect { |m| m.to_s }
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'with except' do
|
28
|
-
@instance_methods.include?('except').should be_true
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'with except!' do
|
32
|
-
@instance_methods.include?('except!').should be_true
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe ThinkingSphinx::ArrayExtractOptions do
|
38
|
-
describe 'extract_options! method' do
|
39
|
-
it 'returns a hash' do
|
40
|
-
array = []
|
41
|
-
array.extract_options!.should be_kind_of(Hash)
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'returns the last option if it is a hash' do
|
45
|
-
array = ['a', 'b', {:c => 'd'}]
|
46
|
-
array.extract_options!.should == {:c => 'd'}
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe "extends Array" do
|
51
|
-
it 'with extract_options!' do
|
52
|
-
Array.instance_methods.collect { |m| m.to_s }.include?('extract_options!').should be_true
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
describe ThinkingSphinx::AbstractQuotedTableName do
|
58
|
-
describe 'quote_table_name method' do
|
59
|
-
it 'calls quote_column_name' do
|
60
|
-
adapter = ActiveRecord::ConnectionAdapters::AbstractAdapter.new(defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql')
|
61
|
-
adapter.should_receive(:quote_column_name).with('messages')
|
62
|
-
adapter.quote_table_name('messages')
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe "extends ActiveRecord::ConnectionAdapters::AbstractAdapter" do
|
67
|
-
it 'with quote_table_name' do
|
68
|
-
ActiveRecord::ConnectionAdapters::AbstractAdapter.instance_methods.collect { |m|
|
69
|
-
m.to_s
|
70
|
-
}.include?('quote_table_name').should be_true
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
describe ThinkingSphinx::MysqlQuotedTableName do
|
76
|
-
describe "quote_table_name method" do
|
77
|
-
it 'correctly quotes' do
|
78
|
-
adapter = ActiveRecord::Base.connection
|
79
|
-
adapter.quote_table_name('thinking_sphinx.messages').should == "`thinking_sphinx`.`messages`"
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
describe "extends ActiveRecord::ConnectionAdapters::MysqlAdapter" do
|
84
|
-
it 'with quote_table_name' do
|
85
|
-
adapter = defined?(JRUBY_VERSION) ? :JdbcAdapter : :MysqlAdapter
|
86
|
-
ActiveRecord::ConnectionAdapters.const_get(adapter).instance_methods.collect { |m|
|
87
|
-
m.to_s
|
88
|
-
}.include?("quote_table_name").should be_true
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
describe ThinkingSphinx::ActiveRecordQuotedName do
|
94
|
-
describe "quoted_table_name method" do
|
95
|
-
it 'returns table name wrappd in quotes' do
|
96
|
-
Person.quoted_table_name.should == '`people`'
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
describe "extends ActiveRecord::Base" do
|
101
|
-
it 'with quoted_table_name' do
|
102
|
-
ActiveRecord::Base.respond_to?("quoted_table_name").should be_true
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
describe ThinkingSphinx::ActiveRecordStoreFullSTIClass do
|
108
|
-
describe "store_full_sti_class method" do
|
109
|
-
it 'returns false' do
|
110
|
-
Person.store_full_sti_class.should be_false
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
describe "extends ActiveRecord::Base" do
|
115
|
-
it 'with store_full_sti_class' do
|
116
|
-
ActiveRecord::Base.respond_to?(:store_full_sti_class).should be_true
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
describe ThinkingSphinx::SingletonClass do
|
122
|
-
describe 'singleton_class' do
|
123
|
-
it "should exist as an instance method in Object" do
|
124
|
-
Object.new.should respond_to('singleton_class')
|
125
|
-
end
|
126
|
-
|
127
|
-
it "should return the meta/eigen/singleton class" do
|
128
|
-
Object.new.singleton_class.should be_a(Class)
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
class TestModel
|
134
|
-
@@squares = 89
|
135
|
-
@@circles = 43
|
136
|
-
|
137
|
-
def number_of_polygons
|
138
|
-
@@polygons
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
describe ThinkingSphinx::ClassAttributeMethods do
|
143
|
-
describe "cattr_reader method" do
|
144
|
-
it 'creates getters' do
|
145
|
-
TestModel.cattr_reader :herbivores
|
146
|
-
test_model = TestModel.new
|
147
|
-
test_model.respond_to?(:herbivores).should be_true
|
148
|
-
end
|
149
|
-
|
150
|
-
it 'sets the initial value to nil' do
|
151
|
-
TestModel.cattr_reader :carnivores
|
152
|
-
test_model = TestModel.new
|
153
|
-
test_model.carnivores.should be_nil
|
154
|
-
end
|
155
|
-
|
156
|
-
it 'does not override an existing definition' do
|
157
|
-
TestModel.cattr_reader :squares
|
158
|
-
test_model = TestModel.new
|
159
|
-
test_model.squares.should == 89
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
describe "cattr_writer method" do
|
164
|
-
it 'creates setters' do
|
165
|
-
TestModel.cattr_writer :herbivores
|
166
|
-
test_model = TestModel.new
|
167
|
-
test_model.respond_to?(:herbivores=).should be_true
|
168
|
-
end
|
169
|
-
|
170
|
-
it 'does not override an existing definition' do
|
171
|
-
TestModel.cattr_writer :polygons
|
172
|
-
test_model = TestModel.new
|
173
|
-
test_model.polygons = 100
|
174
|
-
test_model.number_of_polygons.should == 100
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
describe "cattr_accessor method" do
|
179
|
-
it 'calls cattr_reader' do
|
180
|
-
Class.should_receive(:cattr_reader).with('polygons')
|
181
|
-
Class.cattr_accessor('polygons')
|
182
|
-
end
|
183
|
-
|
184
|
-
it 'calls cattr_writer' do
|
185
|
-
Class.should_receive(:cattr_writer).with('polygons')
|
186
|
-
Class.cattr_accessor('polygons')
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
describe "extends Class" do
|
191
|
-
it 'with cattr_reader' do
|
192
|
-
Class.respond_to?('cattr_reader').should be_true
|
193
|
-
end
|
194
|
-
|
195
|
-
it 'with cattr_writer' do
|
196
|
-
Class.respond_to?('cattr_writer').should be_true
|
197
|
-
end
|
198
|
-
|
199
|
-
it 'with cattr_accessor' do
|
200
|
-
Class.respond_to?('cattr_accessor').should be_true
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|