thinking-sphinx 3.2.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +6 -2
- data/Appraisals +13 -0
- data/Gemfile +2 -1
- data/HISTORY +19 -0
- data/README.textile +3 -2
- data/gemfiles/rails_3_2.gemfile +2 -1
- data/gemfiles/rails_4_0.gemfile +2 -1
- data/gemfiles/rails_4_1.gemfile +2 -1
- data/gemfiles/rails_4_2.gemfile +2 -1
- data/gemfiles/rails_5_0.gemfile +12 -0
- data/lib/thinking_sphinx.rb +2 -0
- data/lib/thinking_sphinx/active_record/attribute/type.rb +17 -3
- data/lib/thinking_sphinx/active_record/callbacks/delta_callbacks.rb +12 -4
- data/lib/thinking_sphinx/active_record/database_adapters.rb +1 -1
- data/lib/thinking_sphinx/active_record/sql_builder/query.rb +4 -0
- data/lib/thinking_sphinx/active_record/sql_source.rb +1 -1
- data/lib/thinking_sphinx/configuration.rb +3 -2
- data/lib/thinking_sphinx/connection.rb +23 -10
- data/lib/thinking_sphinx/deltas/index_job.rb +6 -2
- data/lib/thinking_sphinx/errors.rb +25 -0
- data/lib/thinking_sphinx/middlewares/active_record_translator.rb +14 -2
- data/lib/thinking_sphinx/railtie.rb +1 -1
- data/lib/thinking_sphinx/rake_interface.rb +71 -23
- data/lib/thinking_sphinx/real_time/callbacks/real_time_callbacks.rb +15 -7
- data/lib/thinking_sphinx/real_time/populator.rb +3 -3
- data/lib/thinking_sphinx/tasks.rb +7 -8
- data/lib/thinking_sphinx/wildcard.rb +1 -1
- data/spec/acceptance/association_scoping_spec.rb +5 -5
- data/spec/acceptance/attribute_access_spec.rb +4 -4
- data/spec/acceptance/attribute_updates_spec.rb +3 -3
- data/spec/acceptance/batch_searching_spec.rb +4 -4
- data/spec/acceptance/big_integers_spec.rb +6 -6
- data/spec/acceptance/connection_spec.rb +23 -0
- data/spec/acceptance/excerpts_spec.rb +8 -8
- data/spec/acceptance/facets_spec.rb +13 -13
- data/spec/acceptance/geosearching_spec.rb +8 -8
- data/spec/acceptance/grouping_by_attributes_spec.rb +10 -10
- data/spec/acceptance/index_options_spec.rb +16 -16
- data/spec/acceptance/indexing_spec.rb +3 -3
- data/spec/acceptance/paginating_search_results_spec.rb +3 -3
- data/spec/acceptance/real_time_updates_spec.rb +4 -4
- data/spec/acceptance/remove_deleted_records_spec.rb +12 -12
- data/spec/acceptance/search_counts_spec.rb +2 -2
- data/spec/acceptance/search_for_just_ids_spec.rb +2 -2
- data/spec/acceptance/searching_across_models_spec.rb +6 -6
- data/spec/acceptance/searching_across_schemas_spec.rb +10 -10
- data/spec/acceptance/searching_on_fields_spec.rb +9 -9
- data/spec/acceptance/searching_with_filters_spec.rb +16 -16
- data/spec/acceptance/searching_with_sti_spec.rb +9 -9
- data/spec/acceptance/searching_within_a_model_spec.rb +17 -17
- data/spec/acceptance/sorting_search_results_spec.rb +6 -6
- data/spec/acceptance/specifying_sql_spec.rb +62 -62
- data/spec/acceptance/sphinx_scopes_spec.rb +9 -9
- data/spec/acceptance/sql_deltas_spec.rb +7 -7
- data/spec/acceptance/support/database_cleaner.rb +1 -1
- data/spec/acceptance/support/sphinx_controller.rb +4 -1
- data/spec/acceptance/support/sphinx_helpers.rb +4 -0
- data/spec/acceptance/suspended_deltas_spec.rb +9 -9
- data/spec/internal/app/indices/article_index.rb +2 -2
- data/spec/internal/app/indices/book_index.rb +2 -1
- data/spec/internal/app/indices/product_index.rb +0 -2
- data/spec/internal/app/models/categorisation.rb +8 -1
- data/spec/spec_helper.rb +2 -0
- data/spec/support/json_column.rb +5 -1
- data/spec/support/multi_schema.rb +3 -1
- data/spec/support/sphinx_yaml_helpers.rb +1 -1
- data/spec/thinking_sphinx/active_record/association_spec.rb +1 -1
- data/spec/thinking_sphinx/active_record/attribute/type_spec.rb +41 -38
- data/spec/thinking_sphinx/active_record/base_spec.rb +29 -29
- data/spec/thinking_sphinx/active_record/callbacks/delete_callbacks_spec.rb +10 -10
- data/spec/thinking_sphinx/active_record/callbacks/delta_callbacks_spec.rb +48 -25
- data/spec/thinking_sphinx/active_record/callbacks/update_callbacks_spec.rb +8 -8
- data/spec/thinking_sphinx/active_record/column_spec.rb +13 -13
- data/spec/thinking_sphinx/active_record/column_sql_presenter_spec.rb +5 -5
- data/spec/thinking_sphinx/active_record/database_adapters/abstract_adapter_spec.rb +5 -5
- data/spec/thinking_sphinx/active_record/database_adapters/mysql_adapter_spec.rb +11 -11
- data/spec/thinking_sphinx/active_record/database_adapters/postgresql_adapter_spec.rb +13 -13
- data/spec/thinking_sphinx/active_record/database_adapters_spec.rb +48 -48
- data/spec/thinking_sphinx/active_record/field_spec.rb +7 -7
- data/spec/thinking_sphinx/active_record/filter_reflection_spec.rb +32 -32
- data/spec/thinking_sphinx/active_record/index_spec.rb +35 -36
- data/spec/thinking_sphinx/active_record/interpreter_spec.rb +51 -51
- data/spec/thinking_sphinx/active_record/polymorpher_spec.rb +14 -14
- data/spec/thinking_sphinx/active_record/property_sql_presenter_spec.rb +67 -67
- data/spec/thinking_sphinx/active_record/sql_builder_spec.rb +140 -140
- data/spec/thinking_sphinx/active_record/sql_source_spec.rb +97 -95
- data/spec/thinking_sphinx/configuration_spec.rb +81 -81
- data/spec/thinking_sphinx/connection_spec.rb +13 -13
- data/spec/thinking_sphinx/deletion_spec.rb +11 -11
- data/spec/thinking_sphinx/deltas/default_delta_spec.rb +20 -20
- data/spec/thinking_sphinx/deltas_spec.rb +12 -12
- data/spec/thinking_sphinx/errors_spec.rb +30 -30
- data/spec/thinking_sphinx/excerpter_spec.rb +7 -7
- data/spec/thinking_sphinx/facet_search_spec.rb +16 -16
- data/spec/thinking_sphinx/index_set_spec.rb +7 -7
- data/spec/thinking_sphinx/index_spec.rb +24 -24
- data/spec/thinking_sphinx/masks/pagination_mask_spec.rb +20 -20
- data/spec/thinking_sphinx/masks/scopes_mask_spec.rb +18 -18
- data/spec/thinking_sphinx/middlewares/active_record_translator_spec.rb +22 -22
- data/spec/thinking_sphinx/middlewares/geographer_spec.rb +9 -9
- data/spec/thinking_sphinx/middlewares/glazier_spec.rb +4 -4
- data/spec/thinking_sphinx/middlewares/inquirer_spec.rb +7 -7
- data/spec/thinking_sphinx/middlewares/sphinxql_spec.rb +53 -53
- data/spec/thinking_sphinx/middlewares/stale_id_checker_spec.rb +5 -5
- data/spec/thinking_sphinx/middlewares/stale_id_filter_spec.rb +15 -15
- data/spec/thinking_sphinx/panes/attributes_pane_spec.rb +1 -1
- data/spec/thinking_sphinx/panes/distance_pane_spec.rb +4 -4
- data/spec/thinking_sphinx/panes/excerpts_pane_spec.rb +5 -5
- data/spec/thinking_sphinx/panes/weight_pane_spec.rb +1 -1
- data/spec/thinking_sphinx/rake_interface_spec.rb +66 -53
- data/spec/thinking_sphinx/real_time/attribute_spec.rb +13 -13
- data/spec/thinking_sphinx/real_time/callbacks/real_time_callbacks_spec.rb +107 -23
- data/spec/thinking_sphinx/real_time/field_spec.rb +14 -14
- data/spec/thinking_sphinx/real_time/index_spec.rb +29 -30
- data/spec/thinking_sphinx/real_time/interpreter_spec.rb +30 -30
- data/spec/thinking_sphinx/scopes_spec.rb +5 -5
- data/spec/thinking_sphinx/search/glaze_spec.rb +15 -15
- data/spec/thinking_sphinx/search/query_spec.rb +10 -10
- data/spec/thinking_sphinx/search_spec.rb +28 -28
- data/spec/thinking_sphinx/wildcard_spec.rb +16 -11
- data/spec/thinking_sphinx_spec.rb +6 -6
- data/thinking-sphinx.gemspec +4 -4
- metadata +12 -9
|
@@ -8,9 +8,9 @@ describe ThinkingSphinx::Connection do
|
|
|
8
8
|
let(:translated_error) { ThinkingSphinx::SphinxError.new }
|
|
9
9
|
|
|
10
10
|
before :each do
|
|
11
|
-
ThinkingSphinx::Connection.
|
|
12
|
-
ThinkingSphinx::SphinxError.
|
|
13
|
-
pool.
|
|
11
|
+
allow(ThinkingSphinx::Connection).to receive_messages :pool => pool
|
|
12
|
+
allow(ThinkingSphinx::SphinxError).to receive_messages :new_from_mysql => translated_error
|
|
13
|
+
allow(pool).to receive(:take).and_yield(connection)
|
|
14
14
|
|
|
15
15
|
error.statement = 'SELECT * FROM article_core'
|
|
16
16
|
translated_error.statement = 'SELECT * FROM article_core'
|
|
@@ -18,41 +18,41 @@ describe ThinkingSphinx::Connection do
|
|
|
18
18
|
|
|
19
19
|
it "yields a connection from the pool" do
|
|
20
20
|
ThinkingSphinx::Connection.take do |c|
|
|
21
|
-
c.
|
|
21
|
+
expect(c).to eq(connection)
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
it "retries errors once" do
|
|
26
26
|
tries = 0
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
expect {
|
|
29
29
|
ThinkingSphinx::Connection.take do |c|
|
|
30
30
|
tries += 1
|
|
31
31
|
raise error if tries < 2
|
|
32
32
|
end
|
|
33
|
-
}.
|
|
33
|
+
}.not_to raise_error
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
it "retries errors twice" do
|
|
37
37
|
tries = 0
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
expect {
|
|
40
40
|
ThinkingSphinx::Connection.take do |c|
|
|
41
41
|
tries += 1
|
|
42
42
|
raise error if tries < 3
|
|
43
43
|
end
|
|
44
|
-
}.
|
|
44
|
+
}.not_to raise_error
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
it "raises a translated error if it fails three times" do
|
|
48
48
|
tries = 0
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
expect {
|
|
51
51
|
ThinkingSphinx::Connection.take do |c|
|
|
52
52
|
tries += 1
|
|
53
53
|
raise error if tries < 4
|
|
54
54
|
end
|
|
55
|
-
}.
|
|
55
|
+
}.to raise_error(ThinkingSphinx::SphinxError)
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
[ThinkingSphinx::SyntaxError, ThinkingSphinx::ParseError].each do |klass|
|
|
@@ -60,9 +60,9 @@ describe ThinkingSphinx::Connection do
|
|
|
60
60
|
let(:translated_error) { klass.new }
|
|
61
61
|
|
|
62
62
|
it "raises the error" do
|
|
63
|
-
|
|
63
|
+
expect {
|
|
64
64
|
ThinkingSphinx::Connection.take { |c| raise error }
|
|
65
|
-
}.
|
|
65
|
+
}.to raise_error(klass)
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
it "does not yield the connection more than once" do
|
|
@@ -77,7 +77,7 @@ describe ThinkingSphinx::Connection do
|
|
|
77
77
|
#
|
|
78
78
|
end
|
|
79
79
|
|
|
80
|
-
yields.
|
|
80
|
+
expect(yields).to eq(1)
|
|
81
81
|
end
|
|
82
82
|
end
|
|
83
83
|
end
|
|
@@ -7,13 +7,13 @@ describe ThinkingSphinx::Deletion do
|
|
|
7
7
|
:document_id_for_key => 14, :type => 'plain', :distributed? => false) }
|
|
8
8
|
|
|
9
9
|
before :each do
|
|
10
|
-
ThinkingSphinx::Connection.
|
|
11
|
-
Riddle::Query.
|
|
10
|
+
allow(ThinkingSphinx::Connection).to receive(:take).and_yield(connection)
|
|
11
|
+
allow(Riddle::Query).to receive_messages :update => 'UPDATE STATEMENT'
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
context 'index is SQL-backed' do
|
|
15
15
|
it "updates the deleted flag to false" do
|
|
16
|
-
connection.
|
|
16
|
+
expect(connection).to receive(:execute).with <<-SQL
|
|
17
17
|
UPDATE foo_core
|
|
18
18
|
SET sphinx_deleted = 1
|
|
19
19
|
WHERE id IN (14)
|
|
@@ -23,34 +23,34 @@ WHERE id IN (14)
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
it "doesn't care about Sphinx errors" do
|
|
26
|
-
connection.
|
|
26
|
+
allow(connection).to receive(:execute).
|
|
27
27
|
and_raise(ThinkingSphinx::ConnectionError.new(''))
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
expect {
|
|
30
30
|
ThinkingSphinx::Deletion.perform index, 7
|
|
31
|
-
}.
|
|
31
|
+
}.not_to raise_error
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
context "index is real-time" do
|
|
36
36
|
before :each do
|
|
37
|
-
index.
|
|
37
|
+
allow(index).to receive_messages :type => 'rt'
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
it "deletes the record to false" do
|
|
41
|
-
connection.
|
|
41
|
+
expect(connection).to receive(:execute).
|
|
42
42
|
with('DELETE FROM foo_core WHERE id = 14')
|
|
43
43
|
|
|
44
44
|
ThinkingSphinx::Deletion.perform index, 7
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
it "doesn't care about Sphinx errors" do
|
|
48
|
-
connection.
|
|
48
|
+
allow(connection).to receive(:execute).
|
|
49
49
|
and_raise(ThinkingSphinx::ConnectionError.new(''))
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
expect {
|
|
52
52
|
ThinkingSphinx::Deletion.perform index, 7
|
|
53
|
-
}.
|
|
53
|
+
}.not_to raise_error
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
56
|
end
|
|
@@ -9,11 +9,11 @@ describe ThinkingSphinx::Deltas::DefaultDelta do
|
|
|
9
9
|
describe '#clause' do
|
|
10
10
|
context 'for a delta source' do
|
|
11
11
|
before :each do
|
|
12
|
-
adapter.
|
|
12
|
+
allow(adapter).to receive_messages :boolean_value => 't'
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
it "limits results to those flagged as deltas" do
|
|
16
|
-
delta.clause(true).
|
|
16
|
+
expect(delta.clause(true)).to eq("articles.delta = t")
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
end
|
|
@@ -25,42 +25,42 @@ describe ThinkingSphinx::Deltas::DefaultDelta do
|
|
|
25
25
|
let(:instance) { double('instance', :id => 7) }
|
|
26
26
|
|
|
27
27
|
before :each do
|
|
28
|
-
ThinkingSphinx::Connection.
|
|
29
|
-
Riddle::Query.
|
|
28
|
+
allow(ThinkingSphinx::Connection).to receive(:take).and_yield(connection)
|
|
29
|
+
allow(Riddle::Query).to receive_messages :update => 'UPDATE STATEMENT'
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
it "updates the deleted flag to false" do
|
|
33
|
-
connection.
|
|
33
|
+
expect(connection).to receive(:execute).with('UPDATE STATEMENT')
|
|
34
34
|
|
|
35
35
|
delta.delete index, instance
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
it "builds the update query for the given index" do
|
|
39
|
-
Riddle::Query.
|
|
39
|
+
expect(Riddle::Query).to receive(:update).
|
|
40
40
|
with('foo_core', anything, anything).and_return('')
|
|
41
41
|
|
|
42
42
|
delta.delete index, instance
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
it "builds the update query for the sphinx document id" do
|
|
46
|
-
Riddle::Query.
|
|
46
|
+
expect(Riddle::Query).to receive(:update).
|
|
47
47
|
with(anything, 14, anything).and_return('')
|
|
48
48
|
|
|
49
49
|
delta.delete index, instance
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
it "builds the update query for setting sphinx_deleted to true" do
|
|
53
|
-
Riddle::Query.
|
|
53
|
+
expect(Riddle::Query).to receive(:update).
|
|
54
54
|
with(anything, anything, :sphinx_deleted => true).and_return('')
|
|
55
55
|
|
|
56
56
|
delta.delete index, instance
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
it "doesn't care about Sphinx errors" do
|
|
60
|
-
connection.
|
|
60
|
+
allow(connection).to receive(:execute).
|
|
61
61
|
and_raise(ThinkingSphinx::ConnectionError.new(''))
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
expect { delta.delete index, instance }.not_to raise_error
|
|
64
64
|
end
|
|
65
65
|
end
|
|
66
66
|
|
|
@@ -70,11 +70,11 @@ describe ThinkingSphinx::Deltas::DefaultDelta do
|
|
|
70
70
|
let(:controller) { double('controller') }
|
|
71
71
|
|
|
72
72
|
before :each do
|
|
73
|
-
ThinkingSphinx::Configuration.
|
|
73
|
+
allow(ThinkingSphinx::Configuration).to receive_messages :instance => config
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
it "indexes the given index" do
|
|
77
|
-
controller.
|
|
77
|
+
expect(controller).to receive(:index).with('foo_delta', :verbose => false)
|
|
78
78
|
|
|
79
79
|
delta.index double('index', :name => 'foo_delta')
|
|
80
80
|
end
|
|
@@ -82,9 +82,9 @@ describe ThinkingSphinx::Deltas::DefaultDelta do
|
|
|
82
82
|
|
|
83
83
|
describe '#reset_query' do
|
|
84
84
|
it "updates the table to set delta flags to false" do
|
|
85
|
-
adapter.
|
|
86
|
-
delta.reset_query.
|
|
87
|
-
|
|
85
|
+
allow(adapter).to receive(:boolean_value) { |value| value ? 't' : 'f' }
|
|
86
|
+
expect(delta.reset_query).
|
|
87
|
+
to eq('UPDATE articles SET delta = f WHERE delta = t')
|
|
88
88
|
end
|
|
89
89
|
end
|
|
90
90
|
|
|
@@ -92,7 +92,7 @@ describe ThinkingSphinx::Deltas::DefaultDelta do
|
|
|
92
92
|
let(:instance) { double('instance') }
|
|
93
93
|
|
|
94
94
|
it "sets instance's delta flag to true" do
|
|
95
|
-
instance.
|
|
95
|
+
expect(instance).to receive(:delta=).with(true)
|
|
96
96
|
|
|
97
97
|
delta.toggle(instance)
|
|
98
98
|
end
|
|
@@ -102,15 +102,15 @@ describe ThinkingSphinx::Deltas::DefaultDelta do
|
|
|
102
102
|
let(:instance) { double('instance') }
|
|
103
103
|
|
|
104
104
|
it "returns the delta flag value when true" do
|
|
105
|
-
instance.
|
|
105
|
+
allow(instance).to receive_messages :delta? => true
|
|
106
106
|
|
|
107
|
-
delta.toggled?(instance).
|
|
107
|
+
expect(delta.toggled?(instance)).to be_truthy
|
|
108
108
|
end
|
|
109
109
|
|
|
110
110
|
it "returns the delta flag value when false" do
|
|
111
|
-
instance.
|
|
111
|
+
allow(instance).to receive_messages :delta? => false
|
|
112
112
|
|
|
113
|
-
delta.toggled?(instance).
|
|
113
|
+
expect(delta.toggled?(instance)).to be_falsey
|
|
114
114
|
end
|
|
115
115
|
end
|
|
116
116
|
end
|
|
@@ -3,19 +3,19 @@ require 'spec_helper'
|
|
|
3
3
|
describe ThinkingSphinx::Deltas do
|
|
4
4
|
describe '.processor_for' do
|
|
5
5
|
it "returns the default processor class when given true" do
|
|
6
|
-
ThinkingSphinx::Deltas.processor_for(true).
|
|
7
|
-
|
|
6
|
+
expect(ThinkingSphinx::Deltas.processor_for(true)).
|
|
7
|
+
to eq(ThinkingSphinx::Deltas::DefaultDelta)
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
it "returns the class when given one" do
|
|
11
11
|
klass = Class.new
|
|
12
|
-
ThinkingSphinx::Deltas.processor_for(klass).
|
|
12
|
+
expect(ThinkingSphinx::Deltas.processor_for(klass)).to eq(klass)
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
it "instantiates a class from the name as a string" do
|
|
16
|
-
ThinkingSphinx::Deltas.
|
|
17
|
-
processor_for('ThinkingSphinx::Deltas::DefaultDelta').
|
|
18
|
-
|
|
16
|
+
expect(ThinkingSphinx::Deltas.
|
|
17
|
+
processor_for('ThinkingSphinx::Deltas::DefaultDelta')).
|
|
18
|
+
to eq(ThinkingSphinx::Deltas::DefaultDelta)
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
@@ -29,7 +29,7 @@ describe ThinkingSphinx::Deltas do
|
|
|
29
29
|
let(:processor) { double('processor', :index => true) }
|
|
30
30
|
|
|
31
31
|
before :each do
|
|
32
|
-
ThinkingSphinx::Configuration.
|
|
32
|
+
allow(ThinkingSphinx::Configuration).to receive_messages :instance => config
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
it "executes the given block" do
|
|
@@ -39,12 +39,12 @@ describe ThinkingSphinx::Deltas do
|
|
|
39
39
|
variable = :bar
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
-
variable.
|
|
42
|
+
expect(variable).to eq(:bar)
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
it "suspends deltas within the block" do
|
|
46
46
|
ThinkingSphinx::Deltas.suspend :user do
|
|
47
|
-
ThinkingSphinx::Deltas.
|
|
47
|
+
expect(ThinkingSphinx::Deltas).to be_suspended
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
|
|
@@ -53,11 +53,11 @@ describe ThinkingSphinx::Deltas do
|
|
|
53
53
|
#
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
-
ThinkingSphinx::Deltas.
|
|
56
|
+
expect(ThinkingSphinx::Deltas).not_to be_suspended
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
it "processes the delta indices for the given reference" do
|
|
60
|
-
processor.
|
|
60
|
+
expect(processor).to receive(:index).with(delta_index)
|
|
61
61
|
|
|
62
62
|
ThinkingSphinx::Deltas.suspend :user do
|
|
63
63
|
#
|
|
@@ -65,7 +65,7 @@ describe ThinkingSphinx::Deltas do
|
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
it "does not process the core indices for the given reference" do
|
|
68
|
-
processor.
|
|
68
|
+
expect(processor).not_to receive(:index).with(core_index)
|
|
69
69
|
|
|
70
70
|
ThinkingSphinx::Deltas.suspend :user do
|
|
71
71
|
#
|
|
@@ -6,73 +6,73 @@ describe ThinkingSphinx::SphinxError do
|
|
|
6
6
|
:backtrace => ['foo', 'bar'] }
|
|
7
7
|
|
|
8
8
|
it "translates syntax errors" do
|
|
9
|
-
error.
|
|
9
|
+
allow(error).to receive_messages :message => 'index foo: syntax error: something is wrong'
|
|
10
10
|
|
|
11
|
-
ThinkingSphinx::SphinxError.new_from_mysql(error).
|
|
12
|
-
|
|
11
|
+
expect(ThinkingSphinx::SphinxError.new_from_mysql(error)).
|
|
12
|
+
to be_a(ThinkingSphinx::SyntaxError)
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
it "translates parse errors" do
|
|
16
|
-
error.
|
|
16
|
+
allow(error).to receive_messages :message => 'index foo: parse error: something is wrong'
|
|
17
17
|
|
|
18
|
-
ThinkingSphinx::SphinxError.new_from_mysql(error).
|
|
19
|
-
|
|
18
|
+
expect(ThinkingSphinx::SphinxError.new_from_mysql(error)).
|
|
19
|
+
to be_a(ThinkingSphinx::ParseError)
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
it "translates query errors" do
|
|
23
|
-
error.
|
|
23
|
+
allow(error).to receive_messages :message => 'index foo: query error: something is wrong'
|
|
24
24
|
|
|
25
|
-
ThinkingSphinx::SphinxError.new_from_mysql(error).
|
|
26
|
-
|
|
25
|
+
expect(ThinkingSphinx::SphinxError.new_from_mysql(error)).
|
|
26
|
+
to be_a(ThinkingSphinx::QueryError)
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
it "translates connection errors" do
|
|
30
|
-
error.
|
|
30
|
+
allow(error).to receive_messages :message => "Can't connect to MySQL server on '127.0.0.1' (61)"
|
|
31
31
|
|
|
32
|
-
ThinkingSphinx::SphinxError.new_from_mysql(error).
|
|
33
|
-
|
|
32
|
+
expect(ThinkingSphinx::SphinxError.new_from_mysql(error)).
|
|
33
|
+
to be_a(ThinkingSphinx::ConnectionError)
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
it 'translates out-of-bounds errors' do
|
|
37
|
-
error.
|
|
37
|
+
allow(error).to receive_messages :message => "offset out of bounds (offset=1001, max_matches=1000)"
|
|
38
38
|
|
|
39
|
-
ThinkingSphinx::SphinxError.new_from_mysql(error).
|
|
40
|
-
|
|
39
|
+
expect(ThinkingSphinx::SphinxError.new_from_mysql(error)).
|
|
40
|
+
to be_a(ThinkingSphinx::OutOfBoundsError)
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
it 'prefixes the connection error message' do
|
|
44
|
-
error.
|
|
44
|
+
allow(error).to receive_messages :message => "Can't connect to MySQL server on '127.0.0.1' (61)"
|
|
45
45
|
|
|
46
|
-
ThinkingSphinx::SphinxError.new_from_mysql(error).message.
|
|
47
|
-
|
|
46
|
+
expect(ThinkingSphinx::SphinxError.new_from_mysql(error).message).
|
|
47
|
+
to eq("Error connecting to Sphinx via the MySQL protocol. Can't connect to MySQL server on '127.0.0.1' (61)")
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
it "translates jdbc connection errors" do
|
|
51
|
-
error.
|
|
51
|
+
allow(error).to receive_messages :message => "Communications link failure"
|
|
52
52
|
|
|
53
|
-
ThinkingSphinx::SphinxError.new_from_mysql(error).
|
|
54
|
-
|
|
53
|
+
expect(ThinkingSphinx::SphinxError.new_from_mysql(error)).
|
|
54
|
+
to be_a(ThinkingSphinx::ConnectionError)
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
it 'prefixes the jdbc connection error message' do
|
|
58
|
-
error.
|
|
58
|
+
allow(error).to receive_messages :message => "Communications link failure"
|
|
59
59
|
|
|
60
|
-
ThinkingSphinx::SphinxError.new_from_mysql(error).message.
|
|
61
|
-
|
|
60
|
+
expect(ThinkingSphinx::SphinxError.new_from_mysql(error).message).
|
|
61
|
+
to eq("Error connecting to Sphinx via the MySQL protocol. Communications link failure")
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
it "defaults to sphinx errors" do
|
|
65
|
-
error.
|
|
65
|
+
allow(error).to receive_messages :message => 'index foo: unknown error: something is wrong'
|
|
66
66
|
|
|
67
|
-
ThinkingSphinx::SphinxError.new_from_mysql(error).
|
|
68
|
-
|
|
67
|
+
expect(ThinkingSphinx::SphinxError.new_from_mysql(error)).
|
|
68
|
+
to be_a(ThinkingSphinx::SphinxError)
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
it "keeps the original error's backtrace" do
|
|
72
|
-
error.
|
|
72
|
+
allow(error).to receive_messages :message => 'index foo: unknown error: something is wrong'
|
|
73
73
|
|
|
74
|
-
ThinkingSphinx::SphinxError.new_from_mysql(error).
|
|
75
|
-
backtrace.
|
|
74
|
+
expect(ThinkingSphinx::SphinxError.new_from_mysql(error).
|
|
75
|
+
backtrace).to eq(error.backtrace)
|
|
76
76
|
end
|
|
77
77
|
end
|
|
78
78
|
end
|
|
@@ -7,13 +7,13 @@ describe ThinkingSphinx::Excerpter do
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
before :each do
|
|
10
|
-
ThinkingSphinx::Connection.
|
|
11
|
-
Riddle::Query.
|
|
10
|
+
allow(ThinkingSphinx::Connection).to receive(:take).and_yield(connection)
|
|
11
|
+
allow(Riddle::Query).to receive_messages :snippets => 'CALL SNIPPETS'
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
describe '#excerpt!' do
|
|
15
15
|
it "generates a snippets call" do
|
|
16
|
-
Riddle::Query.
|
|
16
|
+
expect(Riddle::Query).to receive(:snippets).
|
|
17
17
|
with('all of the words', 'index', 'all words',
|
|
18
18
|
ThinkingSphinx::Excerpter::DefaultOptions).
|
|
19
19
|
and_return('CALL SNIPPETS')
|
|
@@ -25,7 +25,7 @@ describe ThinkingSphinx::Excerpter do
|
|
|
25
25
|
excerpter = ThinkingSphinx::Excerpter.new('index', 'all words',
|
|
26
26
|
:before_match => '<b>', :chunk_separator => ' -- ')
|
|
27
27
|
|
|
28
|
-
Riddle::Query.
|
|
28
|
+
expect(Riddle::Query).to receive(:snippets).
|
|
29
29
|
with('all of the words', 'index', 'all words',
|
|
30
30
|
:before_match => '<b>', :after_match => '</span>',
|
|
31
31
|
:chunk_separator => ' -- ').
|
|
@@ -35,16 +35,16 @@ describe ThinkingSphinx::Excerpter do
|
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
it "sends the snippets call to Sphinx" do
|
|
38
|
-
connection.
|
|
38
|
+
expect(connection).to receive(:execute).with('CALL SNIPPETS').
|
|
39
39
|
and_return([{'snippet' => ''}])
|
|
40
40
|
|
|
41
41
|
excerpter.excerpt!('all of the words')
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
it "returns the first value returned by Sphinx" do
|
|
45
|
-
connection.
|
|
45
|
+
allow(connection).to receive_messages :execute => [{'snippet' => 'some highlighted words'}]
|
|
46
46
|
|
|
47
|
-
excerpter.excerpt!('all of the words').
|
|
47
|
+
expect(excerpter.excerpt!('all of the words')).to eq('some highlighted words')
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
end
|